|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--calypso.util.ByteBuf
This class is similar to java/lang/StringBuffer with the following changes:
Constructor Summary | |
ByteBuf()
Constructs an empty String buffer. |
|
ByteBuf(byte[] bytes,
int offset,
int 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 | |
static ByteBuf |
Alloc()
Constructs an empty String buffer, reusing one from the recycler. |
ByteBuf |
append(boolean b)
Appends a boolean to the end of this buffer. |
ByteBuf |
append(byte b)
Appends a byte to the end of this buffer. |
ByteBuf |
append(byte[] str)
Appends an array of bytes to the end of this buffer. |
ByteBuf |
append(byte[] str,
int offset,
int len)
Appends a part of an array of characters to the end of this buffer. |
ByteBuf |
append(ByteBuf buf)
|
ByteBuf |
append(double d)
Appends a double to the end of this buffer. |
ByteBuf |
append(float f)
Appends a float to the end of this buffer. |
ByteBuf |
append(int i)
Appends an integer to the end of this buffer. |
ByteBuf |
append(long l)
Appends a long to the end of this buffer. |
ByteBuf |
append(java.lang.Object obj)
Appends an object to the end of this buffer. |
ByteBuf |
append(java.lang.String str)
Appends a String to the end of this buffer. |
byte |
byteAt(int index)
Returns the byte at the specified index. |
int |
capacity()
Returns the current capacity of the String buffer. |
static void |
EmptyRecycler()
Empty the recycler discarding any cached ByteBuf objects |
void |
ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum. |
boolean |
equals(ByteBuf anotherString)
Compares this ByteBuf to another ByteBuf. |
boolean |
equals(java.lang.Object aObject)
|
boolean |
equals(java.lang.String anotherString)
Compares this ByteBuf to another String. |
boolean |
equalsIgnoreCase(ByteBuf anotherString)
Compares this ByteBuf to another ByteBuf. |
void |
fullDump(java.io.PrintStream out)
Write to the given output stream a detailed description of each byte in this buffer. |
void |
fullDump(java.io.PrintStream out,
int start,
int end)
Write to the given output stream a detailed description of the given bytes in this buffer. |
void |
getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
Copies the characters of the specified substring (determined by srcBegin and srcEnd) into the character array, starting at the array's dstBegin location. |
int |
indexOf(int ch)
|
int |
indexOf(int ch,
int fromIndex)
|
ByteBuf |
insert(int offset,
boolean b)
Inserts a boolean into the String buffer. |
ByteBuf |
insert(int offset,
byte b)
Inserts a byte into the String buffer. |
ByteBuf |
insert(int offset,
byte[] str)
Inserts an array of bytes into the String buffer. |
ByteBuf |
insert(int offset,
double d)
Inserts a double into the String buffer. |
ByteBuf |
insert(int offset,
float f)
Inserts a float into the String buffer. |
ByteBuf |
insert(int offset,
int i)
Inserts an integer into the String buffer. |
ByteBuf |
insert(int offset,
long l)
Inserts a long into the String buffer. |
ByteBuf |
insert(int offset,
java.lang.Object obj)
Inserts an object into the String buffer. |
ByteBuf |
insert(int offset,
java.lang.String str)
Inserts a String into the String buffer. |
int |
length()
Returns the length (character count) of the buffer. |
java.io.InputStream |
makeInputStream()
Creates a new InputStream whose content is this ByteBuf. |
int |
read(java.io.InputStream file,
int max_bytes)
Invokes InputStream.read(), appending the bytes to this Bytebuf. |
int |
read(java.io.RandomAccessFile file,
int max_bytes)
Invokes RandomAccessFile.read(), appending the bytes to this Bytebuf. |
static void |
Recycle(ByteBuf aBuf)
Release a ByteBuf to the recycler. |
boolean |
regionMatches(boolean ignoreCase,
int toffset,
byte[] other,
int ooffset,
int len)
Tests if two byte regions are equal. |
boolean |
regionMatches(boolean ignoreCase,
int toffset,
ByteBuf other,
int ooffset,
int len)
|
boolean |
regionMatches(boolean ignoreCase,
int toffset,
java.lang.String other,
int ooffset,
int len)
Tests if two byte regions are equal. |
boolean |
regionMatches(int toffset,
byte[] other,
int ooffset,
int len)
Tests if two byte regions are equal. |
boolean |
regionMatches(int toffset,
ByteBuf other,
int ooffset,
int len)
|
boolean |
regionMatches(int toffset,
java.lang.String other,
int ooffset,
int len)
Tests if two byte regions are equal. |
void |
remove(int fromIndex)
|
void |
remove(int fromIndex,
int toIndex)
Remove characters from the ByteBuf starting at fromIndex and up to but not including toIndex. |
ByteBuf |
reverse()
Reverse the order of the characters in the String buffer. |
void |
setByteAt(int index,
byte b)
Changes the byte at the specified index to be ch. |
void |
setLength(int newLength)
Sets the length of the String. |
byte[] |
toBytes()
|
int |
toInteger()
|
java.lang.String |
toString()
Converts to a String representing the data in the buffer. |
ByteBuf |
trim()
|
void |
write(java.io.OutputStream out)
Writes the contents to the given output stream. |
void |
write(java.io.RandomAccessFile out)
Writes the contents to the given RandomAccessFile. |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ByteBuf()
public ByteBuf(int length)
length
- the initial lengthpublic ByteBuf(java.lang.String str)
str
- the initial value of the bufferpublic ByteBuf(byte[] bytes, int offset, int length)
Method Detail |
public static ByteBuf Alloc()
public static void Recycle(ByteBuf aBuf)
public static void EmptyRecycler()
public int length()
public int capacity()
public void ensureCapacity(int minimumCapacity)
minimumCapacity
- the minimum desired capacitypublic void setLength(int newLength)
newLength
- the new length of the bufferpublic byte byteAt(int index)
index
- the index of the desired characterpublic void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
srcBegin
- begin copy at this offset in the StringsrcEnd
- stop copying at this offset in the Stringdst
- the array to copy the data intodstBegin
- offset into dstpublic void setByteAt(int index, byte b)
index
- the index of the characterch
- the new characterpublic ByteBuf append(java.lang.Object obj)
obj
- the object to be appendedpublic ByteBuf append(java.lang.String str)
str
- the String to be appendedpublic ByteBuf append(byte[] str)
str
- the characters to be appendedpublic ByteBuf append(byte[] str, int offset, int len)
str
- the characters to be appendedoffset
- where to startlen
- the number of characters to addpublic ByteBuf append(ByteBuf buf)
public ByteBuf append(boolean b)
b
- the boolean to be appendedpublic ByteBuf append(byte b)
ch
- the character to be appendedpublic ByteBuf append(int i)
i
- the integer to be appendedpublic ByteBuf append(long l)
l
- the long to be appendedpublic ByteBuf append(float f)
f
- the float to be appendedpublic ByteBuf append(double d)
d
- the double to be appendedpublic ByteBuf insert(int offset, java.lang.Object obj)
offset
- the offset at which to insertobj
- the object to insertpublic ByteBuf insert(int offset, java.lang.String str)
offset
- the offset at which to insertstr
- the String to insertpublic ByteBuf insert(int offset, byte[] str)
offset
- the offset at which to insertstr
- the characters to insertpublic ByteBuf insert(int offset, boolean b)
offset
- the offset at which to insertb
- the boolean to insertpublic ByteBuf insert(int offset, byte b)
offset
- the offset at which to insertch
- the character to insertpublic ByteBuf insert(int offset, int i)
offset
- the offset at which to inserti
- the integer to insertpublic ByteBuf insert(int offset, long l)
offset
- the offset at which to insertl
- the long to insertpublic ByteBuf insert(int offset, float f)
offset
- the offset at which to insertf
- the float to insertpublic ByteBuf insert(int offset, double d)
offset
- the offset at which to insertd
- the double to insertpublic ByteBuf reverse()
public java.lang.String toString()
public byte[] toBytes()
public boolean equalsIgnoreCase(ByteBuf anotherString)
anotherString
- the String to compare this String againstpublic boolean equals(java.lang.Object aObject)
public boolean equals(ByteBuf anotherString)
anotherString
- the String to compare this String againstpublic boolean equals(java.lang.String anotherString)
anotherString
- the String to compare this String againstpublic boolean regionMatches(int toffset, byte[] other, int ooffset, int len)
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this ByteBuf, or if
ooffset
+length
is greater than the
length of the argument, then this method returns
false
.
toffset
- the starting offset of the subregion in this ByteBuf.other
- the other bytes.ooffset
- the starting offset of the subregion in the argument.len
- the number of bytes to compare.true
if the specified subregion of this ByteBuf
exactly matches the specified subregion of the argument;
false
otherwise.public boolean regionMatches(boolean ignoreCase, int toffset, byte[] other, int ooffset, int len)
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this ByteBuf, or if
ooffset
+length
is greater than the
length of the argument, then this method returns
false
.
ignoreCase
- if true
, ignore case when comparing
bytes (treating them as characters).toffset
- the starting offset of the subregion in this
ByteBuf.other
- the other bytes.ooffset
- the starting offset of the subregion in the
argument.len
- the number of bytes to compare.true
if the specified subregion of this ByteBuf
matches the specified subregion of the argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.public boolean regionMatches(int toffset, ByteBuf other, int ooffset, int len)
public boolean regionMatches(boolean ignoreCase, int toffset, ByteBuf other, int ooffset, int len)
public boolean regionMatches(int toffset, java.lang.String other, int ooffset, int len)
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this ByteBuf, or if
ooffset
+length
is greater than the
length of the argument, then this method returns
false
.
toffset
- the starting offset of the subregion in this ByteBuf.other
- the other String.ooffset
- the starting offset of the subregion in the argument.len
- the number of bytes/characters to compare.true
if the specified subregion of this ByteBuf
exactly matches the specified subregion of the String argument;
false
otherwise.public boolean regionMatches(boolean ignoreCase, int toffset, java.lang.String other, int ooffset, int len)
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this ByteBuf, or if
ooffset
+length
is greater than the
length of the argument, then this method returns
false
.
ignoreCase
- if true
, ignore case when comparing
bytes (treating them as characters).toffset
- the starting offset of the subregion in this
ByteBuf.other
- the other String.ooffset
- the starting offset of the subregion in the
String argument.len
- the number of bytes to compare.true
if the specified subregion of this ByteBuf
matches the specified subregion of the String argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.public int indexOf(int ch)
public int indexOf(int ch, int fromIndex)
public void remove(int fromIndex)
public void remove(int fromIndex, int toIndex)
public int toInteger() throws java.lang.NumberFormatException
public ByteBuf trim()
public void fullDump(java.io.PrintStream out)
public void fullDump(java.io.PrintStream out, int start, int end)
public int read(java.io.InputStream file, int max_bytes) throws java.io.IOException
public int read(java.io.RandomAccessFile file, int max_bytes) throws java.io.IOException
public void write(java.io.OutputStream out) throws java.io.IOException
public void write(java.io.RandomAccessFile out) throws java.io.IOException
public java.io.InputStream makeInputStream()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |