Class Buffer
java.lang.Object
com.mysql.jdbc.Buffer
Buffer contains code to read and write packets from/to the MySQL server.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final longstatic final shortIt has the same signature as EOF, but may be issued by server only during handshake phasestatic final shortstatic final shortstatic final shortstatic final shortprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final voidclear()(package private) final voiddump()(package private) final Stringdump(int numBytes) (package private) final StringdumpClampedBytes(int numBytes) (package private) final void(package private) final voiddumpNBytes(int start, int nBytes) (package private) final voidensureCapacity(int additionalData) voidintSkip over a length-encoded stringprotected final byte[]intbyte[]Returns the array of bytes this Buffer is using to read from.(package private) final byte[]getBytes(int len) (package private) byte[]getBytes(int offset, int len) (package private) intintReturns the current position to write to/ read from(package private) final boolean(package private) final boolean(package private) final boolean(package private) final boolean(package private) final boolean(package private) final long(package private) final bytereadByte()(package private) final bytereadByte(int readAt) (package private) final long(package private) final intreadInt()(package private) final int(package private) final byte[]readLenByteArray(int offset) (package private) final long(package private) final longreadLong()(package private) final int(package private) final long(package private) final intfinal String(package private) final StringreadString(String encoding, ExceptionInterceptor exceptionInterceptor) Read string[NUL](package private) final StringreadString(String encoding, ExceptionInterceptor exceptionInterceptor, int expectedLength) Read string[$len]voidsetBufLength(int bufLengthToSet) voidsetByteBuffer(byte[] byteBufferToSet) Sets the array of bytes to use as a buffer to read from.voidsetPosition(int positionToSet) Set the current position to write to/ read fromvoidsetWasMultiPacket(boolean flag) Sets whether this packet was part of a multipackettoString()booleanWas this packet part of a multipacket?final voidwriteByte(byte b) final voidwriteBytesNoNull(byte[] bytes) (package private) final voidwriteBytesNoNull(byte[] bytes, int offset, int length) (package private) final voidwriteDouble(double d) (package private) final voidwriteFieldLength(long length) (package private) final voidwriteFloat(float f) (package private) final voidwriteInt(int i) (package private) final voidwriteLenBytes(byte[] b) (package private) final voidwriteLenString(String s, String encoding, String serverEncoding, SingleByteCharsetConverter converter, boolean parserKnowsUnicode, MySQLConnection conn) (package private) final voidwriteLong(long i) (package private) final voidwriteLongInt(int i) (package private) final voidwriteLongLong(long i) (package private) final void(package private) final voidwriteString(String s, String encoding, MySQLConnection conn) (package private) final void(package private) final voidwriteStringNoNull(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn)
-
Field Details
-
MAX_BYTES_TO_DUMP
static final int MAX_BYTES_TO_DUMP- See Also:
-
NO_LENGTH_LIMIT
static final int NO_LENGTH_LIMIT- See Also:
-
NULL_LENGTH
static final long NULL_LENGTH- See Also:
-
wasMultiPacket
protected boolean wasMultiPacket -
TYPE_ID_ERROR
public static final short TYPE_ID_ERROR- See Also:
-
TYPE_ID_EOF
public static final short TYPE_ID_EOF- See Also:
-
TYPE_ID_AUTH_SWITCH
public static final short TYPE_ID_AUTH_SWITCHIt has the same signature as EOF, but may be issued by server only during handshake phase- See Also:
-
TYPE_ID_LOCAL_INFILE
public static final short TYPE_ID_LOCAL_INFILE- See Also:
-
TYPE_ID_OK
public static final short TYPE_ID_OK- See Also:
-
-
Constructor Details
-
Buffer
public Buffer(byte[] buf) -
Buffer
Buffer(int size)
-
-
Method Details
-
clear
final void clear() -
dump
final void dump() -
dump
-
dumpClampedBytes
-
dumpHeader
final void dumpHeader() -
dumpNBytes
final void dumpNBytes(int start, int nBytes) -
ensureCapacity
- Throws:
SQLException
-
fastSkipLenString
public int fastSkipLenString()Skip over a length-encoded string- Returns:
- The position past the end of the string
-
fastSkipLenByteArray
public void fastSkipLenByteArray() -
getBufferSource
protected final byte[] getBufferSource() -
getBufLength
public int getBufLength() -
getByteBuffer
public byte[] getByteBuffer()Returns the array of bytes this Buffer is using to read from.- Returns:
- byte array being read from
-
getBytes
final byte[] getBytes(int len) -
getBytes
byte[] getBytes(int offset, int len) -
getCapacity
int getCapacity() -
getNioBuffer
-
getPosition
public int getPosition()Returns the current position to write to/ read from- Returns:
- the current position to write to/ read from
-
isEOFPacket
final boolean isEOFPacket() -
isAuthMethodSwitchRequestPacket
final boolean isAuthMethodSwitchRequestPacket() -
isOKPacket
final boolean isOKPacket() -
isResultSetOKPacket
final boolean isResultSetOKPacket() -
isRawPacket
final boolean isRawPacket() -
newReadLength
final long newReadLength() -
readByte
final byte readByte() -
readByte
final byte readByte(int readAt) -
readFieldLength
final long readFieldLength() -
readInt
final int readInt() -
readIntAsLong
final int readIntAsLong() -
readLenByteArray
final byte[] readLenByteArray(int offset) -
readLength
final long readLength() -
readLong
final long readLong() -
readLongInt
final int readLongInt() -
readLongLong
final long readLongLong() -
readnBytes
final int readnBytes() -
readString
-
readString
final String readString(String encoding, ExceptionInterceptor exceptionInterceptor) throws SQLException Read string[NUL]- Parameters:
encoding-exceptionInterceptor-- Throws:
SQLException
-
readString
final String readString(String encoding, ExceptionInterceptor exceptionInterceptor, int expectedLength) throws SQLException Read string[$len]- Throws:
SQLException
-
setBufLength
public void setBufLength(int bufLengthToSet) -
setByteBuffer
public void setByteBuffer(byte[] byteBufferToSet) Sets the array of bytes to use as a buffer to read from.- Parameters:
byteBuffer- the array of bytes to use as a buffer
-
setPosition
public void setPosition(int positionToSet) Set the current position to write to/ read from- Parameters:
position- the position (0-based index)
-
setWasMultiPacket
public void setWasMultiPacket(boolean flag) Sets whether this packet was part of a multipacket- Parameters:
flag- was this packet part of a multipacket?
-
toString
-
toSuperString
-
wasMultiPacket
public boolean wasMultiPacket()Was this packet part of a multipacket?- Returns:
- was this packet part of a multipacket?
-
writeByte
- Throws:
SQLException
-
writeBytesNoNull
- Throws:
SQLException
-
writeBytesNoNull
- Throws:
SQLException
-
writeDouble
- Throws:
SQLException
-
writeFieldLength
- Throws:
SQLException
-
writeFloat
- Throws:
SQLException
-
writeInt
- Throws:
SQLException
-
writeLenBytes
- Throws:
SQLException
-
writeLenString
final void writeLenString(String s, String encoding, String serverEncoding, SingleByteCharsetConverter converter, boolean parserKnowsUnicode, MySQLConnection conn) throws UnsupportedEncodingException, SQLException -
writeLong
- Throws:
SQLException
-
writeLongInt
- Throws:
SQLException
-
writeLongLong
- Throws:
SQLException
-
writeString
- Throws:
SQLException
-
writeString
- Throws:
SQLException
-
writeStringNoNull
- Throws:
SQLException
-
writeStringNoNull
final void writeStringNoNull(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn) throws UnsupportedEncodingException, SQLException
-