Package org.mariadb.jdbc.client.socket
Interface Writer
-
public interface WriterPacket Writer interface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]buf()Current bufferbooleanbufIsDataAfterMark()Buffer has data after marked positionvoidclose()Close socket streamvoidflush()Send packet to socket.voidflushBufferStopAtMark()Flush to last mark.voidflushPipeline()Send packet to buffered outputstream without flushinglonggetCmdLength()Get current command lengthbooleanhasFlushed()Current command has flushed packet to socketvoidinitPacket()reset sequences and position for sending a new packetbooleanisMarked()has some position been markedvoidmark()mark positionvoidpermitTrace(boolean permitTrace)Indicate if logging trace are permittedintpos()current buffer positionvoidpos(int pos)Set current buffer positionbyte[]resetMark()Reset mark flag and send bytes after mark flag.voidsetServerThreadId(Long serverThreadId, HostAddress hostAddress)Set server thread id.booleanthrowMaxAllowedLength(int length)must a max allowed length exception be thrownvoidwriteAscii(String str)Write ascii string to buffervoidwriteByte(int value)Write byte into buf, flush buf to socket if needed.voidwriteBytes(byte[] arr)Write byte array to buffervoidwriteBytes(byte[] arr, int off, int len)Write byte array to buf.voidwriteBytesAtPos(byte[] arr, int pos)Write byte array to buffer at a specific positionvoidwriteBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)Write escape bytes to socket.voidwriteDouble(double value)Write Double binary value to buffervoidwriteEmptyPacket()Send empty packet.voidwriteFloat(float value)Write float binary value to buffervoidwriteInt(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)Write utf8 string to buffervoidwriteStringEscaped(String str, boolean noBackslashEscapes)Write string to socket.
-
-
-
Method Detail
-
pos
int pos()
current buffer position- Returns:
- current buffer position
-
buf
byte[] buf()
Current buffer- Returns:
- current buffer
-
pos
void pos(int pos) throws IOException
Set current buffer position- Parameters:
pos- position- Throws:
IOException- if buffer cannot grow to position
-
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 IOExceptionWrite Double binary value to buffer- Parameters:
value- double value- Throws:
IOException- if socket error occur
-
writeFloat
void writeFloat(float value) throws IOExceptionWrite float binary value to buffer- Parameters:
value- float value- Throws:
IOException- if socket error occur
-
writeBytes
void writeBytes(byte[] arr) throws IOExceptionWrite byte array to buffer- Parameters:
arr- bytes- Throws:
IOException- if socket error occur
-
writeBytesAtPos
void writeBytesAtPos(byte[] arr, int pos)Write byte array to buffer at a specific position- Parameters:
arr- bytespos- position
-
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
Write ascii string to buffer- Parameters:
str- string- Throws:
IOException- if socket error occurs
-
writeString
void writeString(String str) throws IOException
Write utf8 string to buffer- Parameters:
str- string- Throws:
IOException- if socket error occurs
-
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.
-
flushPipeline
void flushPipeline() throws IOExceptionSend packet to buffered outputstream without flushing- Throws:
IOException- if socket error occur.
-
throwMaxAllowedLength
boolean throwMaxAllowedLength(int length)
must a max allowed length exception be thrown- Parameters:
length- command length- Returns:
- true if too big
-
getCmdLength
long getCmdLength()
Get current command length- Returns:
- command length
-
permitTrace
void permitTrace(boolean permitTrace)
Indicate if logging trace are permitted- Parameters:
permitTrace- permits trace to be logged
-
setServerThreadId
void setServerThreadId(Long serverThreadId, HostAddress hostAddress)
Set server thread id.- Parameters:
serverThreadId- current server thread id.hostAddress- host information
-
mark
void mark()
mark position
-
isMarked
boolean isMarked()
has some position been marked- Returns:
- is marked
-
hasFlushed
boolean hasFlushed()
Current command has flushed packet to socket- Returns:
- indicate if some packet have been flushed
-
flushBufferStopAtMark
void flushBufferStopAtMark() throws IOExceptionFlush to last mark.- Throws:
IOException- if flush fail.
-
bufIsDataAfterMark
boolean bufIsDataAfterMark()
Buffer has data after marked position- Returns:
- indicate if there is data after marked position
-
resetMark
byte[] resetMark()
Reset mark flag and send bytes after mark flag.- Returns:
- bytes after mark flag
-
initPacket
void initPacket()
reset sequences and position for sending a new packet
-
close
void close() throws IOExceptionClose socket stream- Throws:
IOException- if any error occurs
-
-