public class NativePacketPayload extends java.lang.Object implements Message
| Modifier and Type | Field and Description |
|---|---|
static long |
NULL_LENGTH |
static short |
TYPE_ID_AUTH_SWITCH
It has the same signature as EOF, but may be issued by server only during handshake phase
|
static short |
TYPE_ID_EOF |
static short |
TYPE_ID_ERROR |
static short |
TYPE_ID_LOCAL_INFILE |
static short |
TYPE_ID_OK |
| Constructor and Description |
|---|
NativePacketPayload(byte[] buf) |
NativePacketPayload(int size) |
| Modifier and Type | Method and Description |
|---|---|
void |
ensureCapacity(int additionalData)
Checks that underlying buffer has enough space to store additionalData bytes starting from current position.
|
static java.lang.String |
extractSqlFromPacket(java.lang.String possibleSqlQuery,
NativePacketPayload packet,
int endOfQueryPacketPosition,
int maxQuerySizeToLog) |
byte[] |
getByteBuffer()
Returns the array of bytes this Buffer is using to read from.
|
int |
getCapacity() |
int |
getPayloadLength()
Get the actual length of payload the buffer contains.
|
int |
getPosition()
Returns the current position to write to/ read from
|
boolean |
isAuthMethodSwitchRequestPacket()
Is it a Protocol::AuthSwitchRequest packet.
|
boolean |
isAuthMoreData()
Is it a Protocol::AuthMoreData packet.
|
boolean |
isEOFPacket()
Is it a EOF packet.
|
boolean |
isErrorPacket()
Is it a ERROR packet.
|
boolean |
isOKPacket()
Is it an OK packet.
|
boolean |
isResultSetOKPacket()
Is it an OK packet for ResultSet.
|
byte[] |
readBytes(NativeConstants.StringLengthDataType type,
int len)
Read len bytes from internal buffer starting from current position into the new byte array.
|
byte[] |
readBytes(NativeConstants.StringSelfDataType type)
Read bytes from internal buffer starting from current position into the new byte array.
|
long |
readInteger(NativeConstants.IntegerDataType type)
Read data according to provided Integer type.
|
java.lang.String |
readString(NativeConstants.StringLengthDataType type,
java.lang.String encoding,
int len)
Read len bytes from internal buffer starting from current position decoding them into String using the specified character encoding.
|
java.lang.String |
readString(NativeConstants.StringSelfDataType type,
java.lang.String encoding)
Read bytes from internal buffer starting from current position decoding them into String using the specified character encoding.
|
void |
setByteBuffer(byte[] byteBufferToSet)
Sets the array of bytes to use as a buffer to read from.
|
void |
setPayloadLength(int bufLengthToSet)
Set the actual length of payload written to buffer.
|
void |
setPosition(int positionToSet)
Set the current position to write to/ read from
|
void |
skipBytes(NativeConstants.StringSelfDataType type)
Set position to next value in internal buffer skipping the current value according to
NativeConstants.StringSelfDataType. |
java.lang.String |
toString() |
java.lang.String |
toSuperString() |
void |
writeBytes(NativeConstants.StringLengthDataType type,
byte[] b)
Write all bytes from given byte array into internal buffer starting with current buffer position.
|
void |
writeBytes(NativeConstants.StringLengthDataType type,
byte[] b,
int offset,
int len)
Write len bytes from given byte array into internal buffer.
|
void |
writeBytes(NativeConstants.StringSelfDataType type,
byte[] b)
Write all bytes from given byte array into internal buffer starting with current buffer position.
|
void |
writeBytes(NativeConstants.StringSelfDataType type,
byte[] b,
int offset,
int len)
Write len bytes from given byte array into internal buffer.
|
void |
writeInteger(NativeConstants.IntegerDataType type,
long l)
Write data according to provided Integer type.
|
public static final long NULL_LENGTH
public static final short TYPE_ID_ERROR
public static final short TYPE_ID_EOF
public static final short TYPE_ID_AUTH_SWITCH
public static final short TYPE_ID_LOCAL_INFILE
public static final short TYPE_ID_OK
public NativePacketPayload(byte[] buf)
public NativePacketPayload(int size)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toSuperString()
public int getCapacity()
public final void ensureCapacity(int additionalData)
additionalData - additional data size in bytespublic byte[] getByteBuffer()
MessagegetByteBuffer in interface Messagepublic void setByteBuffer(byte[] byteBufferToSet)
byteBufferToSet - the array of bytes to use as a bufferpublic int getPayloadLength()
public void setPayloadLength(int bufLengthToSet)
bufLengthToSet - lengthpublic int getPosition()
MessagegetPosition in interface Messagepublic void setPosition(int positionToSet)
positionToSet - the position (0-based index)public boolean isErrorPacket()
public final boolean isEOFPacket()
public final boolean isAuthMethodSwitchRequestPacket()
public final boolean isOKPacket()
public final boolean isResultSetOKPacket()
public final boolean isAuthMoreData()
public void writeInteger(NativeConstants.IntegerDataType type, long l)
type - NativeConstants.IntegerDataTypel - valuepublic final long readInteger(NativeConstants.IntegerDataType type)
type - NativeConstants.IntegerDataTypepublic final void writeBytes(NativeConstants.StringSelfDataType type, byte[] b)
type - on-wire data typeb - from byte arraypublic final void writeBytes(NativeConstants.StringLengthDataType type, byte[] b)
type - on-wire data typeb - from byte arraypublic void writeBytes(NativeConstants.StringSelfDataType type, byte[] b, int offset, int len)
type - on-wire data typeb - from byte arrayoffset - starting index of blen - number of bytes to be writtenpublic void writeBytes(NativeConstants.StringLengthDataType type, byte[] b, int offset, int len)
type - on-wire data typeb - from byte arrayoffset - starting index of blen - number of bytes to be writtenpublic byte[] readBytes(NativeConstants.StringSelfDataType type)
NativeConstants.StringSelfDataType.type - NativeConstants.StringSelfDataTypepublic void skipBytes(NativeConstants.StringSelfDataType type)
NativeConstants.StringSelfDataType.type - NativeConstants.StringSelfDataTypepublic byte[] readBytes(NativeConstants.StringLengthDataType type, int len)
type - NativeConstants.StringLengthDataTypelen - lengthpublic java.lang.String readString(NativeConstants.StringSelfDataType type, java.lang.String encoding)
NativeConstants.StringSelfDataType.type - NativeConstants.StringSelfDataTypeencoding - if null then platform default encoding is usedpublic java.lang.String readString(NativeConstants.StringLengthDataType type, java.lang.String encoding, int len)
type - NativeConstants.StringLengthDataTypeencoding - if null then platform default encoding is usedlen - lengthpublic static java.lang.String extractSqlFromPacket(java.lang.String possibleSqlQuery,
NativePacketPayload packet,
int endOfQueryPacketPosition,
int maxQuerySizeToLog)