Package septogeddon.pluginquery.utils
Class DataBuffer
java.lang.Object
septogeddon.pluginquery.utils.DataBuffer
- All Implemented Interfaces:
- DataInput,- DataOutput
- Direct Known Subclasses:
- ObjectBuffer
DataBuffer for PluginQuery. Hold objects in byte buffer to send later or read later.
- Author:
- Thito Yalasatria Sunarya
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a buffer with 32 byte length of initial sizeDataBuffer(byte[] buff) Create a buffer with existing byte arrayDataBuffer(int initialSize) Create a buffer with specific initial sizeDataBuffer(InputStream input) Read the input stream and copy it to the buffer
- 
Method SummaryModifier and TypeMethodDescriptionintGet readable bytes (basically the current buffer size)voidclear()Clear the buffervoidcopyTo(OutputStream output) Copy the buffer to the OutputStreamvoidfinalize()Flush the byte arrayintread()Read a byteintread(byte[] bytes) Read and fill the provided byte arrayintread(byte[] b, int off, int len) Read bytes at specific offset and lengthfinal booleanRead a booleanfinal bytereadByte()Read a byteRead a string (non charset)final charreadChar()Read a characterRead a string (using charset)final doubleRead a doublefinal floatRead a floatfinal voidreadFully(byte[] b) Read and fill the provided byte arrayfinal voidreadFully(byte[] b, int off, int len) Read and fill the provided byte array at specific offset and lengthfinal intreadInt()Read an integerfinal StringreadLine()Deprecated.final longreadLong()Read a longfinal shortRead a shortfinal intRead an unsigned bytefinal intRead an unsigned shortfinal StringreadUTF()Read a String (UTF)longskip(long n) Skip bytesfinal intskipBytes(int n) Skip bytesbyte[]Transform this buffer into a byte arrayvoidwrite(byte[] b) Write byte array to this buffervoidwrite(byte[] b, int off, int len) Write byte array at specific offset and length to this buffervoidwrite(int b) Write a byte to this bufferfinal voidwriteBoolean(boolean v) Write a boolean to this bufferfinal voidwriteByte(int v) Write a byte to this bufferfinal voidwriteBytes(String s) Write a String (non Charset)final voidwriteChar(int v) Write a characterfinal voidwriteChars(String s) Write a String (Charset)final voidwriteDouble(double v) Write a doublefinal voidwriteFloat(float v) Write a floatfinal voidwriteInt(int v) Write an integerfinal voidwriteLong(long v) Write a longfinal voidwriteShort(int v) Write a shortfinal voidWrite a String (UTF)
- 
Field Details- 
bufprotected byte[] buf
 
- 
- 
Constructor Details- 
DataBufferpublic DataBuffer()Create a buffer with 32 byte length of initial size
- 
DataBufferpublic DataBuffer(byte[] buff) Create a buffer with existing byte array- Parameters:
- buff-
 
- 
DataBufferRead the input stream and copy it to the buffer- Parameters:
- input-
- Throws:
- IOException
 
- 
DataBufferpublic DataBuffer(int initialSize) Create a buffer with specific initial size- Parameters:
- initialSize-
 
 
- 
- 
Method Details- 
copyToCopy the buffer to the OutputStream- Parameters:
- output-
- Throws:
- IOException
 
- 
availablepublic int available()Get readable bytes (basically the current buffer size)- Returns:
 
- 
clearpublic void clear()Clear the buffer
- 
finalizepublic void finalize()Flush the byte array
- 
readpublic int read()Read a byte- Returns:
 
- 
readpublic int read(byte[] b, int off, int len) Read bytes at specific offset and length- Parameters:
- b-
- off-
- len-
- Returns:
 
- 
readpublic int read(byte[] bytes) Read and fill the provided byte array- Parameters:
- bytes-
- Returns:
 
- 
readBooleanpublic final boolean readBoolean()Read a boolean- Specified by:
- readBooleanin interface- DataInput
 
- 
readBytepublic final byte readByte()Read a byte
- 
readBytesRead a string (non charset)- Returns:
 
- 
readCharpublic final char readChar()Read a character
- 
readCharsRead a string (using charset)- Returns:
 
- 
readDoublepublic final double readDouble()Read a double- Specified by:
- readDoublein interface- DataInput
 
- 
readFloatpublic final float readFloat()Read a float
- 
readFullypublic final void readFully(byte[] b) Read and fill the provided byte array
- 
readFullypublic final void readFully(byte[] b, int off, int len) Read and fill the provided byte array at specific offset and length
- 
readIntpublic final int readInt()Read an integer
- 
readLineDeprecated.Not supported
- 
readLongpublic final long readLong()Read a long
- 
readShortpublic final short readShort()Read a short
- 
readUnsignedBytepublic final int readUnsignedByte()Read an unsigned byte- Specified by:
- readUnsignedBytein interface- DataInput
 
- 
readUnsignedShortpublic final int readUnsignedShort()Read an unsigned short- Specified by:
- readUnsignedShortin interface- DataInput
 
- 
readUTFRead a String (UTF)
- 
skippublic long skip(long n) Skip bytes- Parameters:
- n-
- Returns:
 
- 
skipBytespublic final int skipBytes(int n) Skip bytes
- 
toByteArraypublic byte[] toByteArray()Transform this buffer into a byte array- Returns:
 
- 
writepublic void write(byte[] b, int off, int len) Write byte array at specific offset and length to this buffer- Specified by:
- writein interface- DataOutput
 
- 
writepublic void write(byte[] b) Write byte array to this buffer- Specified by:
- writein interface- DataOutput
 
- 
writepublic void write(int b) Write a byte to this buffer- Specified by:
- writein interface- DataOutput
 
- 
writeBooleanpublic final void writeBoolean(boolean v) Write a boolean to this buffer- Specified by:
- writeBooleanin interface- DataOutput
 
- 
writeBytepublic final void writeByte(int v) Write a byte to this buffer- Specified by:
- writeBytein interface- DataOutput
 
- 
writeBytesWrite a String (non Charset)- Specified by:
- writeBytesin interface- DataOutput
 
- 
writeCharpublic final void writeChar(int v) Write a character- Specified by:
- writeCharin interface- DataOutput
 
- 
writeCharsWrite a String (Charset)- Specified by:
- writeCharsin interface- DataOutput
 
- 
writeDoublepublic final void writeDouble(double v) Write a double- Specified by:
- writeDoublein interface- DataOutput
 
- 
writeFloatpublic final void writeFloat(float v) Write a float- Specified by:
- writeFloatin interface- DataOutput
 
- 
writeIntpublic final void writeInt(int v) Write an integer- Specified by:
- writeIntin interface- DataOutput
 
- 
writeLongpublic final void writeLong(long v) Write a long- Specified by:
- writeLongin interface- DataOutput
 
- 
writeShortpublic final void writeShort(int v) Write a short- Specified by:
- writeShortin interface- DataOutput
 
- 
writeUTFWrite a String (UTF)- Specified by:
- writeUTFin interface- DataOutput
 
 
-