public class DataBuffer
extends java.lang.Object
Dynamic buffer for getting/setting data blocks.
Constructor and Description |
---|
DataBuffer()
Default constructor
|
DataBuffer(byte[] buf,
int off,
int len)
Create a data buffer to read data from
|
DataBuffer(int siz)
Create a data buffer to write data to
|
Modifier and Type | Method and Description |
---|---|
void |
appendData(byte[] buf,
int off,
int len)
Append a raw data block to the data buffer
|
int |
copyData(byte[] buf,
int off)
Copy all data from the data buffer to the user buffer, and update the read position
|
int |
copyData(byte[] buf,
int off,
int cnt)
Copy data from the data buffer to the user buffer, and update the current read position.
|
int |
getAvailableLength()
Return the available data length
|
byte[] |
getBuffer()
Return the data buffer
|
int |
getByte()
Get a byte from the buffer
|
int |
getDisplacement()
Return the displacement from the start of the buffer to the current buffer position
|
java.lang.String |
getFixedString(int len,
boolean uni)
Get a fixed length string from the buffer
|
int |
getInt()
Get an integer from the buffer
|
int |
getIntAt(int idx)
Get an integer from the buffer at the specified index
|
int |
getLength()
Return the data length
|
int |
getLengthInWords()
Return the data length in words
|
long |
getLong()
Get a long (64 bit) value from the buffer
|
long |
getLongAt(int idx)
Get a long (64 bit) value from the buffer at the specified index
|
int |
getOffset()
Return the buffer base offset
|
int |
getPosition()
Return the data position
|
int |
getShort()
Get a short from the buffer
|
int |
getShortAt(int idx)
Get a short from the buffer at the specified index
|
java.lang.String |
getString(boolean uni)
Get a string from the buffer
|
java.lang.String |
getString(int maxlen,
boolean uni)
Get a string from the buffer
|
int |
getUsedLength()
Return the used buffer length
|
protected boolean |
isExternalBuffer()
Check if the buffer is an externally allocated buffer
|
void |
longwordAlign()
Longword align the buffer position
|
void |
putByte(int bval)
Append a byte value to the buffer
|
void |
putFixedString(java.lang.String str,
int len)
Append a fixed length string to the buffer
|
int |
putFixedStringAt(java.lang.String str,
int len,
int pos)
Append a fixed length string to the buffer at the specified position
|
void |
putInt(int ival)
Append an integer to the buffer
|
void |
putIntAt(int idx,
int ival)
Append an integer to the buffer at the specified index
|
void |
putLong(long lval)
Append a long to the buffer
|
void |
putLongAt(int idx,
int lval)
Append a long to the buffer at the specified index
|
void |
putShort(int sval)
Append a short value to the buffer
|
void |
putShortAt(int idx,
int sval)
Append a short value to the buffer at the specified index
|
void |
putString(java.lang.String str,
boolean uni)
Append a string to the buffer
|
void |
putString(java.lang.String str,
boolean uni,
boolean nulTerm)
Append a string to the buffer
|
int |
putStringAt(java.lang.String str,
int pos,
boolean uni,
boolean nulTerm)
Append a string to the buffer at the specified buffer position
|
void |
putStringPointer(int off)
Append a string pointer to the specified buffer offset
|
void |
putZeros(int cnt)
Append zero bytes to the buffer
|
void |
resetBuffer()
Reset the data buffer
|
void |
setEndOfBuffer()
Set the end of buffer position, and reset the read position to the beginning of the buffer
|
void |
setEndOfBuffer(int endPos)
Set the end of buffer position, and reset the read position to the beginning of the buffer
|
void |
setLength(int len)
Set the data length
|
void |
setPosition(int pos)
Set the read/write buffer position
|
void |
skipBytes(int cnt)
Skip over a number of bytes
|
java.lang.String |
toString()
Return the data buffer details as a string
|
void |
wordAlign()
Word align the buffer position
|
public DataBuffer()
public DataBuffer(int siz)
siz
- intpublic DataBuffer(byte[] buf, int off, int len)
buf
- byte[]off
- intlen
- intpublic final byte[] getBuffer()
public final int getLength()
public final int getLengthInWords()
public final int getAvailableLength()
public final int getUsedLength()
public final int getDisplacement()
public final int getOffset()
public final int getByte()
public final int getShort()
public final int getInt()
public final long getLong()
public final java.lang.String getString(boolean uni)
uni
- booleanpublic final java.lang.String getString(int maxlen, boolean uni)
maxlen
- intuni
- booleanpublic final java.lang.String getFixedString(int len, boolean uni)
maxlen
- intuni
- booleanpublic final int getShortAt(int idx)
idx
- intpublic final int getIntAt(int idx)
idx
- intpublic final long getLongAt(int idx)
idx
- intpublic final void skipBytes(int cnt)
cnt
- intpublic final int getPosition()
public final void setPosition(int pos)
pos
- intpublic final void setEndOfBuffer()
public final void setEndOfBuffer(int endPos)
endPos
- intpublic final void setLength(int len)
len
- intpublic final void resetBuffer()
public final void putByte(int bval)
bval
- intpublic final void putShort(int sval)
sval
- intpublic final void putInt(int ival)
ival
- intpublic final void putLong(long lval)
lval
- longpublic final void putShortAt(int idx, int sval)
idx
- intsval
- intpublic final void putIntAt(int idx, int ival)
idx
- intival
- intpublic final void putLongAt(int idx, int lval)
idx
- intlval
- longpublic final void putString(java.lang.String str, boolean uni)
str
- Stringuni
- booleanpublic final void putString(java.lang.String str, boolean uni, boolean nulTerm)
str
- Stringuni
- booleannulTerm
- booleanpublic final void putFixedString(java.lang.String str, int len)
str
- Stringlen
- intpublic final int putStringAt(java.lang.String str, int pos, boolean uni, boolean nulTerm)
str
- Stringpos
- intuni
- booleannulTerm
- booleanpublic final int putFixedStringAt(java.lang.String str, int len, int pos)
str
- Stringlen
- intpos
- intpublic final void putStringPointer(int off)
off
- intpublic final void putZeros(int cnt)
cnt
- intpublic final void wordAlign()
public final void longwordAlign()
public final void appendData(byte[] buf, int off, int len)
buf
- byte[]off
- intlen
- intpublic final int copyData(byte[] buf, int off)
buf
- byte[]off
- intpublic final int copyData(byte[] buf, int off, int cnt)
buf
- byte[]off
- intcnt
- intprotected final boolean isExternalBuffer()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.