Package org.mariadb.jdbc.client.socket
Interface Writer
-
public interface Writer
Packet Writer interface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
buf()
Current bufferboolean
bufIsDataAfterMark()
Buffer has data after marked positionvoid
close()
Close socket streamvoid
flush()
Send packet to socket.void
flushBufferStopAtMark()
Flush to last mark.void
flushPipeline()
Send packet to buffered outputstream without flushinglong
getCmdLength()
Get current command lengthboolean
hasFlushed()
Current command has flushed packet to socketvoid
initPacket()
reset sequences and position for sending a new packetboolean
isMarked()
has some position been markedvoid
mark()
mark positionvoid
permitTrace(boolean permitTrace)
Indicate if logging trace are permittedint
pos()
current buffer positionvoid
pos(int pos)
Set current buffer positionbyte[]
resetMark()
Reset mark flag and send bytes after mark flag.void
setServerThreadId(Long serverThreadId, HostAddress hostAddress)
Set server thread id.boolean
throwMaxAllowedLength(int length)
must a max allowed length exception be thrownvoid
writeAscii(String str)
Write ascii string to buffervoid
writeByte(int value)
Write byte into buf, flush buf to socket if needed.void
writeBytes(byte[] arr)
Write byte array to buffervoid
writeBytes(byte[] arr, int off, int len)
Write byte array to buf.void
writeBytesAtPos(byte[] arr, int pos)
Write byte array to buffer at a specific positionvoid
writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)
Write escape bytes to socket.void
writeDouble(double value)
Write Double binary value to buffervoid
writeEmptyPacket()
Send empty packet.void
writeFloat(float value)
Write float binary value to buffervoid
writeInt(int value)
Write int value into buf.void
writeLength(long length)
Write field length into buf, flush socket if needed.void
writeLong(long value)
Write long value into buf.void
writeShort(short value)
Write short value into buf.void
writeString(String str)
Write utf8 string to buffervoid
writeStringEscaped(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 IOException
Write 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 IOException
Write 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 IOException
Write 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 IOException
Write 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
Write Double binary value to buffer- Parameters:
value
- double value- Throws:
IOException
- if socket error occur
-
writeFloat
void writeFloat(float value) throws IOException
Write float binary value to buffer- Parameters:
value
- float value- Throws:
IOException
- if socket error occur
-
writeBytes
void writeBytes(byte[] arr) throws IOException
Write 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 IOException
Write 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 IOException
Write 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 IOException
Write escape bytes to socket.- Parameters:
bytes
- byteslen
- len to writenoBackslashEscapes
- escape method- Throws:
IOException
- if socket error occur
-
writeEmptyPacket
void writeEmptyPacket() throws IOException
Send empty packet.- Throws:
IOException
- if socket error occur.
-
flush
void flush() throws IOException
Send packet to socket.- Throws:
IOException
- if socket error occur.
-
flushPipeline
void flushPipeline() throws IOException
Send 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 IOException
Flush 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 IOException
Close socket stream- Throws:
IOException
- if any error occurs
-
-