Package org.mariadb.jdbc.client.socket
Interface Writer
-
- All Known Implementing Classes:
PacketWriter
public interface Writer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanbufIsDataAfterMark()voidclose()voidflush()Send packet to socket.voidflushBufferStopAtMark()Flush to last mark.longgetCmdLength()booleanhasFlushed()voidinitPacket()booleanisMarked()voidmark()voidpermitTrace(boolean permitTrace)intpos()voidpos(int pos)byte[]resetMark()Reset mark flag and send bytes after mark flag.voidsetMaxAllowedPacket(int maxAllowedPacket)voidsetServerThreadId(Long serverThreadId, HostAddress hostAddress)Set server thread id.booleanthrowMaxAllowedLength(int length)voidwriteAscii(String str)voidwriteByte(int value)Write byte into buf, flush buf to socket if needed.voidwriteBytes(byte[] arr)voidwriteBytes(byte[] arr, int off, int len)Write byte array to buf.voidwriteBytesAtPos(byte[] arr, int pos)voidwriteBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)Write escape bytes to socket.voidwriteDouble(double value)voidwriteEmptyPacket()Send empty packet.voidwriteFloat(float value)voidwriteInt(int value)Write int value into buf.voidwriteLength(long length)Write field length into buf, flush socket if needed.voidwriteLong(long value)Write long value into buf.voidwriteShort(short value)Write short value into buf.voidwriteString(String str)voidwriteStringEscaped(String str, boolean noBackslashEscapes)Write string to socket.
-
-
-
Method Detail
-
pos
int pos()
-
pos
void pos(int pos) throws IOException
- Throws:
IOException
-
writeByte
void writeByte(int value) throws IOExceptionWrite byte into buf, flush buf to socket if needed.- Parameters:
value- byte to send- Throws:
IOException- if socket error occur.
-
writeShort
void writeShort(short value) throws IOExceptionWrite short value into buf. flush buf if too small.- Parameters:
value- short value- Throws:
IOException- if socket error occur
-
writeInt
void writeInt(int value) throws IOExceptionWrite int value into buf. flush buf if too small.- Parameters:
value- int value- Throws:
IOException- if socket error occur
-
writeLong
void writeLong(long value) throws IOExceptionWrite long value into buf. flush buf if too small.- Parameters:
value- long value- Throws:
IOException- if socket error occur
-
writeDouble
void writeDouble(double value) throws IOException- Throws:
IOException
-
writeFloat
void writeFloat(float value) throws IOException- Throws:
IOException
-
writeBytes
void writeBytes(byte[] arr) throws IOException- Throws:
IOException
-
writeBytesAtPos
void writeBytesAtPos(byte[] arr, int pos)
-
writeBytes
void writeBytes(byte[] arr, int off, int len) throws IOExceptionWrite byte array to buf. If buf is full, flush socket.- Parameters:
arr- byte arrayoff- offsetlen- byte length to write- Throws:
IOException- if socket error occur
-
writeLength
void writeLength(long length) throws IOExceptionWrite field length into buf, flush socket if needed.- Parameters:
length- field length- Throws:
IOException- if socket error occur.
-
writeAscii
void writeAscii(String str) throws IOException
- Throws:
IOException
-
writeString
void writeString(String str) throws IOException
- Throws:
IOException
-
writeStringEscaped
void writeStringEscaped(String str, boolean noBackslashEscapes) throws IOException
Write string to socket.- Parameters:
str- stringnoBackslashEscapes- escape method- Throws:
IOException- if socket error occur
-
writeBytesEscaped
void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes) throws IOExceptionWrite escape bytes to socket.- Parameters:
bytes- byteslen- len to writenoBackslashEscapes- escape method- Throws:
IOException- if socket error occur
-
writeEmptyPacket
void writeEmptyPacket() throws IOExceptionSend empty packet.- Throws:
IOException- if socket error occur.
-
flush
void flush() throws IOExceptionSend packet to socket.- Throws:
IOException- if socket error occur.
-
throwMaxAllowedLength
boolean throwMaxAllowedLength(int length)
-
getCmdLength
long getCmdLength()
-
setMaxAllowedPacket
void setMaxAllowedPacket(int maxAllowedPacket)
-
permitTrace
void permitTrace(boolean permitTrace)
-
setServerThreadId
void setServerThreadId(Long serverThreadId, HostAddress hostAddress)
Set server thread id.- Parameters:
serverThreadId- current server thread id.hostAddress- host information
-
mark
void mark()
-
isMarked
boolean isMarked()
-
hasFlushed
boolean hasFlushed()
-
flushBufferStopAtMark
void flushBufferStopAtMark() throws IOExceptionFlush to last mark.- Throws:
IOException- if flush fail.
-
bufIsDataAfterMark
boolean bufIsDataAfterMark()
-
resetMark
byte[] resetMark()
Reset mark flag and send bytes after mark flag.- Returns:
- bytes after mark flag
-
initPacket
void initPacket()
-
close
void close() throws IOException- Throws:
IOException
-
-