|
LDAPJDK 4.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--netscape.ldap.util.ByteBuf
This class is similar to the java.lang.StringBuffer
class. Instead of storing a string, an object of this class
stores an array of bytes. (This is referred to as a "byte buffer".)
This class also differs from StringBuffer
in the
following ways:
Alloc
and Recycle
methods are provided. You can "recycle"
any ByteBuf
objects you no longer need by using the
Recycle
method. Calling the Alloc
method will reuse objects that have been "recycled." To
To clear out the cache of these "recycled" objects, use
the EmptyRecycler
method.
Constructor Summary | |
ByteBuf()
Constructs an empty byte buffer with the default length of 16. |
|
ByteBuf(byte[] bytes,
int offset,
int length)
Constructs a byte buffer with the specified length. |
|
ByteBuf(int length)
Constructs an empty byte buffer with the specified initial length. |
|
ByteBuf(java.lang.String str)
Constructs a byte buffer with the specified initial value. |
Method Summary | |
ByteBuf |
append(boolean b)
Appends a boolean to the end of this byte buffer. |
ByteBuf |
append(byte b)
Appends a byte to the end of this byte buffer. |
ByteBuf |
append(byte[] str)
Appends an array of bytes to the end of this byte buffer. |
ByteBuf |
append(byte[] str,
int offset,
int len)
Appends a part of an array of bytes to the end of this byte buffer. |
ByteBuf |
append(ByteBuf buf)
Appends a byte buffer to the end of this byte buffer. |
ByteBuf |
append(double d)
Appends a double to the end of this byte buffer. |
ByteBuf |
append(float f)
Appends a float to the end of this byte buffer. |
ByteBuf |
append(int i)
Appends an integer to the end of this byte buffer. |
ByteBuf |
append(long l)
Appends a long value to the end of this byte buffer. |
ByteBuf |
append(java.lang.Object obj)
Appends an object to the end of this byte buffer. |
ByteBuf |
append(java.lang.String str)
Appends a string to the end of this byte buffer. |
byte |
byteAt(int index)
Returns the byte at the specified index. |
int |
capacity()
Returns the current capacity of the byte buffer. |
void |
ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum capacity. |
void |
getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
Copies the bytes (from the section of the byte buffer from the index srcBegin to the index srcEnd - 1 )
into the specified byte array. |
int |
length()
Returns the length (character count) of the byte buffer. |
int |
read(java.io.InputStream file,
int max_bytes)
Invokes the InputStream.read method and appends the
the bytes read to this byte buffer. |
int |
read(java.io.RandomAccessFile file,
int max_bytes)
Invokes the RandomAccessFile.read method, appending
the bytes read to this byte buffer. |
void |
setByteAt(int index,
byte b)
Sets the value of the byte at the specified index. |
void |
setLength(int newLength)
Sets the length of the byte buffer. |
byte[] |
toBytes()
Returns the data in the byte buffer as a byte array. |
java.lang.String |
toString()
Returns the data in the byte buffer to a string. |
void |
write(java.io.OutputStream out)
Writes the contents of the byte buffer to the specified output stream. |
void |
write(java.io.RandomAccessFile out)
Writes the contents of the byte buffer to the specified RandomAccessFile object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ByteBuf()
public ByteBuf(int length)
length
- initial number of bytes that this buffer should holdpublic ByteBuf(java.lang.String str)
str
- initial value that this buffer should holdpublic ByteBuf(byte[] bytes, int offset, int length)
bytes
- array of bytes to initially store in the bufferoffset
- index where you want the initial value to start in the arraylength
- length of the buffer to allocateMethod Detail |
public int length()
public int capacity()
public void ensureCapacity(int minimumCapacity)
minimumCapacity
- the minimum number of bytes that you want
the byte buffer to holdpublic void setLength(int newLength)
newLength
- the new length of the bufferpublic byte byteAt(int index)
index
- index of the byte to findpublic void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
srcBegin
to the index srcEnd - 1
)
into the specified byte array. The copied
bytes are inserted in the byte array at the index specified by
dstBegin
. Both srcBegin
and
srcEnd
must be valid indexes in the buffer.srcBegin
- index identifying the start of the section
of the byte buffer to copysrcEnd
- index identifying the end of the section
of the byte buffer to copy. (Copy all bytes
before the byte identified by this index.)dst
- the byte array to copy the data todstBegin
- index of the byte array identifying the
location to which the byte buffer is copiedpublic void setByteAt(int index, byte b)
index
- the index of the byte to setb
- the new value to setpublic ByteBuf append(java.lang.Object obj)
obj
- the object to append to the bufferByteBuf
object (not a new object)
with the string representation of the specified object appended.public ByteBuf append(java.lang.String str)
If you want to retain all bits in the character (not just
the lower 8 bits), use append(String.getBytes())
instead.
str
- the string that you want appended to the bufferByteBuf
object (not a new object)
with the specified string appendedpublic ByteBuf append(byte[] str)
str
- the array of bytes to append to this bufferByteBuf
object (not a new object)
with the specified bytes appended.public ByteBuf append(byte[] str, int offset, int len)
str
- the array of bytes to append to this bufferoffset
- the index in the array marking the start of the
section to copylen
- the number of bytes to addByteBuf
object (not a new object)
with the specified section of the byte array appendedpublic ByteBuf append(ByteBuf buf)
buf
- the byte buffer to append to this bufferByteBuf
object (not a new object)
with bytes from the specified byte buffer appended.public ByteBuf append(boolean b)
b
- the boolean value that you want appended to this bufferByteBuf
object (not a new object)
with bytes from the string representation of the boolean value appended.public ByteBuf append(byte b)
ch
- the byte to append to this bufferByteBuf
object (not a new object)
with the specified byte appended.public ByteBuf append(int i)
i
- the integer to append to this byte bufferByteBuf
object (not a new object)
with the string representation of the specified integer appended.public ByteBuf append(long l)
long
value to the end of this byte buffer.l
- the long
value to append to this bufferByteBuf
object (not a new object)
with the string representation of the specified long
value appended.public ByteBuf append(float f)
float
to the end of this byte buffer.f
- the float
value to append to this bufferByteBuf
object (not a new object)
with the string representation of the specified float
value appended.public ByteBuf append(double d)
double
to the end of this byte buffer.d
- the double
value to append to this bufferByteBuf
object (not a new object)
with the string representation of the specified double
value appended.public java.lang.String toString()
public byte[] toBytes()
public int read(java.io.InputStream file, int max_bytes) throws java.io.IOException
InputStream.read
method and appends the
the bytes read to this byte buffer.file
- the input stream from which to read the bytesmax_bytes
- the maximum number of bytes to read into the
byte bufferpublic int read(java.io.RandomAccessFile file, int max_bytes) throws java.io.IOException
RandomAccessFile.read
method, appending
the bytes read to this byte buffer.file
- the RandomAccessFile
object from which
to read the bytesmax_bytes
- the maximum number of bytes to read into the
byte bufferpublic void write(java.io.OutputStream out) throws java.io.IOException
out
- the output streampublic void write(java.io.RandomAccessFile out) throws java.io.IOException
RandomAccessFile
object.out
- the RandomAccessFile
object
dexception IOException An I/O error has occurred.
|
LDAPJDK 4.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |