Package org.mariadb.jdbc.client.socket
Interface Writer
- All Known Implementing Classes:
PacketWriter
public interface Writer
Packet Writer interface
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
buf()
Current bufferboolean
Buffer has data after marked positionvoid
close()
Close socket streamvoid
flush()
Send packet to socket.void
Flush to last mark.void
Send packet to buffered outputstream without flushinglong
Get current command lengthbyte
Get current sequence objectboolean
Current command has flushed packet to socketvoid
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[]
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
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 Details
-
pos
int pos()current buffer position- Returns:
- current buffer position
-
buf
byte[] buf()Current buffer- Returns:
- current buffer
-
pos
Set current buffer position- Parameters:
pos
- position- Throws:
IOException
- if buffer cannot grow to position
-
writeByte
Write byte into buf, flush buf to socket if needed.- Parameters:
value
- byte to send- Throws:
IOException
- if socket error occur.
-
writeShort
Write short value into buf. flush buf if too small.- Parameters:
value
- short value- Throws:
IOException
- if socket error occur
-
writeInt
Write int value into buf. flush buf if too small.- Parameters:
value
- int value- Throws:
IOException
- if socket error occur
-
writeLong
Write long value into buf. flush buf if too small.- Parameters:
value
- long value- Throws:
IOException
- if socket error occur
-
writeDouble
Write Double binary value to buffer- Parameters:
value
- double value- Throws:
IOException
- if socket error occur
-
writeFloat
Write float binary value to buffer- Parameters:
value
- float value- Throws:
IOException
- if socket error occur
-
writeBytes
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
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
Write field length into buf, flush socket if needed.- Parameters:
length
- field length- Throws:
IOException
- if socket error occur.
-
writeAscii
Write ascii string to buffer- Parameters:
str
- string- Throws:
IOException
- if socket error occurs
-
writeString
Write utf8 string to buffer- Parameters:
str
- string- Throws:
IOException
- if socket error occurs
-
writeStringEscaped
Write string to socket.- Parameters:
str
- stringnoBackslashEscapes
- escape method- Throws:
IOException
- if socket error occur
-
writeBytesEscaped
Write escape bytes to socket.- Parameters:
bytes
- byteslen
- len to writenoBackslashEscapes
- escape method- Throws:
IOException
- if socket error occur
-
writeEmptyPacket
Send empty packet.- Throws:
IOException
- if socket error occur.
-
flush
Send packet to socket.- Throws:
IOException
- if socket error occur.
-
flushPipeline
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
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
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
Close socket stream- Throws:
IOException
- if any error occurs
-
getSequence
byte getSequence()Get current sequence object- Returns:
- current sequence
-