com.mysql.jdbc
Class Buffer

java.lang.Object
  extended by com.mysql.jdbc.Buffer

 class Buffer
extends java.lang.Object

Buffer contains code to read and write packets from/to the MySQL server.


Field Summary
(package private) static int MAX_BYTES_TO_DUMP
           
(package private) static int NO_LENGTH_LIMIT
           
(package private) static long NULL_LENGTH
           
protected  boolean wasMultiPacket
           
 
Constructor Summary
Buffer(byte[] buf)
           
Buffer(int size)
           
 
Method Summary
(package private)  void clear()
           
(package private)  void dump()
           
(package private)  java.lang.String dump(int numBytes)
           
(package private)  java.lang.String dumpClampedBytes(int numBytes)
           
(package private)  void dumpHeader()
           
(package private)  void dumpNBytes(int start, int nBytes)
           
(package private)  void ensureCapacity(int additionalData)
           
 void fastSkipLenByteArray()
           
 int fastSkipLenString()
          Skip over a length-encoded string
protected  byte[] getBufferSource()
           
(package private)  int getBufLength()
           
 byte[] getByteBuffer()
          Returns the array of bytes this Buffer is using to read from.
(package private)  byte[] getBytes(int len)
           
(package private)  byte[] getBytes(int offset, int len)
           
(package private)  int getCapacity()
           
 java.nio.ByteBuffer getNioBuffer()
           
 int getPosition()
          Returns the current position to write to/ read from
(package private)  boolean isLastDataPacket()
           
(package private)  long newReadLength()
           
(package private)  byte readByte()
           
(package private)  byte readByte(int readAt)
           
(package private)  long readFieldLength()
           
(package private)  int readInt()
           
(package private)  int readIntAsLong()
           
(package private)  byte[] readLenByteArray(int offset)
           
(package private)  long readLength()
           
(package private)  long readLong()
           
(package private)  int readLongInt()
           
(package private)  long readLongLong()
           
(package private)  int readnBytes()
           
(package private)  java.lang.String readString()
           
(package private)  java.lang.String readString(java.lang.String encoding, ExceptionInterceptor exceptionInterceptor)
           
(package private)  void setBufLength(int bufLengthToSet)
           
 void setByteBuffer(byte[] byteBufferToSet)
          Sets the array of bytes to use as a buffer to read from.
 void setPosition(int positionToSet)
          Set the current position to write to/ read from
 void setWasMultiPacket(boolean flag)
          Sets whether this packet was part of a multipacket
 java.lang.String toString()
           
 java.lang.String toSuperString()
           
 boolean wasMultiPacket()
          Was this packet part of a multipacket?
(package private)  void writeByte(byte b)
           
(package private)  void writeBytesNoNull(byte[] bytes)
           
(package private)  void writeBytesNoNull(byte[] bytes, int offset, int length)
           
(package private)  void writeDouble(double d)
           
(package private)  void writeFieldLength(long length)
           
(package private)  void writeFloat(float f)
           
(package private)  void writeInt(int i)
           
(package private)  void writeLenBytes(byte[] b)
           
(package private)  void writeLenString(java.lang.String s, java.lang.String encoding, java.lang.String serverEncoding, SingleByteCharsetConverter converter, boolean parserKnowsUnicode, ConnectionImpl conn)
           
(package private)  void writeLong(long i)
           
(package private)  void writeLongInt(int i)
           
(package private)  void writeLongLong(long i)
           
(package private)  void writeString(java.lang.String s)
           
(package private)  void writeString(java.lang.String s, java.lang.String encoding, ConnectionImpl conn)
           
(package private)  void writeStringNoNull(java.lang.String s)
           
(package private)  void writeStringNoNull(java.lang.String s, java.lang.String encoding, java.lang.String serverEncoding, boolean parserKnowsUnicode, ConnectionImpl conn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_BYTES_TO_DUMP

static final int MAX_BYTES_TO_DUMP
See Also:
Constant Field Values

NO_LENGTH_LIMIT

static final int NO_LENGTH_LIMIT
See Also:
Constant Field Values

NULL_LENGTH

static final long NULL_LENGTH
See Also:
Constant Field Values

wasMultiPacket

protected boolean wasMultiPacket
Constructor Detail

Buffer

Buffer(byte[] buf)

Buffer

Buffer(int size)
Method Detail

clear

final void clear()

dump

final void dump()

dump

final java.lang.String dump(int numBytes)

dumpClampedBytes

final java.lang.String dumpClampedBytes(int numBytes)

dumpHeader

final void dumpHeader()

dumpNBytes

final void dumpNBytes(int start,
                      int nBytes)

ensureCapacity

final void ensureCapacity(int additionalData)
                   throws java.sql.SQLException
Throws:
java.sql.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

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

public java.nio.ByteBuffer getNioBuffer()

getPosition

public int getPosition()
Returns the current position to write to/ read from

Returns:
the current position to write to/ read from

isLastDataPacket

final boolean isLastDataPacket()

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

final java.lang.String readString()

readString

final java.lang.String readString(java.lang.String encoding,
                                  ExceptionInterceptor exceptionInterceptor)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

setBufLength

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

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toSuperString

public java.lang.String toSuperString()

wasMultiPacket

public boolean wasMultiPacket()
Was this packet part of a multipacket?

Returns:
was this packet part of a multipacket?

writeByte

final void writeByte(byte b)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

writeBytesNoNull

final void writeBytesNoNull(byte[] bytes)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

writeBytesNoNull

final void writeBytesNoNull(byte[] bytes,
                            int offset,
                            int length)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

writeDouble

final void writeDouble(double d)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

writeFieldLength

final void writeFieldLength(long length)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

writeFloat

final void writeFloat(float f)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

writeInt

final void writeInt(int i)
             throws java.sql.SQLException
Throws:
java.sql.SQLException

writeLenBytes

final void writeLenBytes(byte[] b)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

writeLenString

final void writeLenString(java.lang.String s,
                          java.lang.String encoding,
                          java.lang.String serverEncoding,
                          SingleByteCharsetConverter converter,
                          boolean parserKnowsUnicode,
                          ConnectionImpl conn)
                   throws java.io.UnsupportedEncodingException,
                          java.sql.SQLException
Throws:
java.io.UnsupportedEncodingException
java.sql.SQLException

writeLong

final void writeLong(long i)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

writeLongInt

final void writeLongInt(int i)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

writeLongLong

final void writeLongLong(long i)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

writeString

final void writeString(java.lang.String s)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

writeString

final void writeString(java.lang.String s,
                       java.lang.String encoding,
                       ConnectionImpl conn)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

writeStringNoNull

final void writeStringNoNull(java.lang.String s)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

writeStringNoNull

final void writeStringNoNull(java.lang.String s,
                             java.lang.String encoding,
                             java.lang.String serverEncoding,
                             boolean parserKnowsUnicode,
                             ConnectionImpl conn)
                      throws java.io.UnsupportedEncodingException,
                             java.sql.SQLException
Throws:
java.io.UnsupportedEncodingException
java.sql.SQLException