|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.amx.duet.tools.lang.ByteBuffer
This is similar to the Java StringBuffer class except that it deals with data at the byte level.
Constructor Summary | |
ByteBuffer()
Initializes a newly created byte[] object |
|
ByteBuffer(byte[] original)
Initializes a newly created byte[] object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string. |
|
ByteBuffer(byte[] value,
int offset,
int size)
Allocates a new byte[] that contains characters from a subarray of the byte array argument. |
|
ByteBuffer(char[] value)
Allocates a new byte[] so that it represents the sequence of characters currently contained in the character array argument. |
|
ByteBuffer(int b)
Initializes a newly created byte[] object so that it represents a single byte as the argument. |
|
ByteBuffer(java.lang.String value)
Allocates a new byte[] so that it represents the sequence of characters currently contained in the String
argument. |
Method Summary | |
void |
append(byte[] value)
|
void |
append(byte[] value,
int offset,
int size)
|
void |
append(char[] value)
|
void |
append(int b)
|
void |
append(java.lang.String value)
|
byte |
byteAt(int index)
Return a byte at the specified index |
char |
charAt(int index)
Return a character at the specified index |
void |
clear()
Clear all of the contents of the ByteBuffer |
ByteBuffer |
delete()
Removes the entire contents of this byte buffer from beginning to end. |
ByteBuffer |
delete(int len)
Removes the characters in a substring of this ByteBuffer
up to the specified length. |
ByteBuffer |
delete(int start,
int end)
Removes the characters in a substring of this ByteBuffer . |
boolean |
endsWith(java.lang.String str)
Tests if this byte buffer ends with the specified suffix. |
boolean |
getBoolean(int index)
Return the boolean value at the specified index |
char |
getChar(int index)
Return the char value at the specified index |
double |
getDouble(int index)
Return the double value at the specified index |
float |
getFloat(int index)
Return the float value at the specified index |
int |
getInt(int index)
Return the int value at the specified index |
long |
getLong(int index)
Return the long value at the specified index |
short |
getShort(int index)
Return the short value at the specified index |
java.lang.String |
getString(int index,
int length)
Return the double value at the specified index |
int |
indexof(byte[] value)
|
int |
indexof(byte[] value,
int fromIndex)
|
int |
indexof(char[] value)
|
int |
indexof(char[] value,
int fromIndex)
|
int |
indexof(int value)
Returns the index within this string of the first occurrence of the specified byte. |
int |
indexof(int value,
int fromIndex)
|
int |
indexof(java.lang.String value)
Returns the index within this ByteBuffer of the first occurrence of the specified substring. |
int |
indexof(java.lang.String value,
int fromIndex)
|
int |
length()
Returns the current size of the buffer. |
ByteBuffer |
replace(byte[][] pattern,
byte[][] replace)
Replaces a sequence of patterns with a sequence of replace values. |
ByteBuffer |
replace(byte[] pattern,
byte[] replace)
Removes every instance of the passed in pattern from the ByteBuffer and replaces them with the replace pattern. |
ByteBuffer |
replace(int start,
int end,
byte[] value)
Replaces the bytes in a substring of this ByteBuffer
with bytes in the specified byte[] . |
ByteBuffer |
replace(int start,
int end,
byte[][] pattern,
byte[][] replace)
Replaces a sequence of patterns with a sequence of replace values. |
ByteBuffer |
replace(int start,
int end,
byte[] pattern,
byte[] replace)
Removes every instance of the passed in pattern from the ByteBuffer and replaces them with the replace pattern. |
boolean |
startsWith(java.lang.String str)
Tests if this byte buffer starts with the specified prefix. |
ByteBuffer |
substring(int start)
Returns a new ByteBuffer that contains a subsequence of
bytes currently contained in this ByteBuffer .The
substring begins at the specified index and extends to the end of the
ByteBuffer . |
ByteBuffer |
substring(int start,
int end)
Returns a new ByteBuffer that contains a subsequence of
characters currently contained in this ByteBuffer . |
byte[] |
toByteArray()
|
static byte[] |
toBytes(boolean value)
Converts a byte value to a byte array. |
static byte[] |
toBytes(byte value)
Converts a byte value to a byte array. |
static byte[] |
toBytes(char value)
Converts a char value to a byte array. |
static byte[] |
toBytes(double value)
Converts a double value to a byte array. |
static byte[] |
toBytes(float value)
Converts a float value to a byte array. |
static byte[] |
toBytes(int value)
Converts an int value to a byte array. |
static byte[] |
toBytes(long value)
Converts a long value to a byte array. |
static byte[] |
toBytes(short value)
Converts a short value to a byte array. |
static byte[] |
toBytes(java.lang.String value)
Converts a String value to a byte array. |
char[] |
toCharArray()
|
java.lang.String |
toHex()
Generates an ASCII hex string from the stored byte array. |
java.lang.String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding. |
int |
UByteAt(int index)
Return an 8-bit unsigned byte at the specified index |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ByteBuffer()
public ByteBuffer(int b)
b
- the initial value of the byte arraypublic ByteBuffer(byte[] original)
original
is needed, use of this
constructor is unnecessary.
original
- a byte[].public ByteBuffer(byte[] value, int offset, int size)
offset
argument is the index of the first character of the subarray and
the size
argument specifies the length of the
subarray. The contents of the subarray are copied; subsequent
modification of the byte array does not affect the newly
created byte array.
value
- array that is the source of bytes.offset
- the initial offset.size
- the length.public ByteBuffer(java.lang.String value)
String
argument. The contents of the string are copied; subsequent
modification of the string does not affect the newly created
byte array.
value
- the initial value of the byte arraypublic ByteBuffer(char[] value)
value
- the initial value of the byte arrayMethod Detail |
public void append(int b)
b
- public void append(byte[] value)
value
- public void append(byte[] value, int offset, int size)
value
- offset
- size
- public void append(java.lang.String value)
value
- public void append(char[] value)
value
- public byte byteAt(int index)
index
-
public int UByteAt(int index)
index
-
public char charAt(int index)
index
-
public boolean getBoolean(int index)
index
-
public char getChar(int index)
index
-
public short getShort(int index)
index
-
public int getInt(int index)
index
-
public long getLong(int index)
index
-
public float getFloat(int index)
index
-
public double getDouble(int index)
index
-
public java.lang.String getString(int index, int length)
index
- length
-
public byte[] toByteArray()
public char[] toCharArray()
public java.lang.String toString()
public java.lang.String toHex()
public int length()
public void clear()
public int indexof(int value)
value
occurs
in the byte sequence represented by this ByteBuffer
object, then the index of the first such occurrence is returned --
that is, the smallest value k such that:
isthis.byteAt(k) == value
true
. If no such byte occurs in this ByteBuffer,
then -1
is returned.
value
- a byte.
-1
if the byte does not occur.public int indexof(int value, int fromIndex)
value
- fromIndex
-
public int indexof(byte[] value)
value
-
public int indexof(byte[] value, int fromIndex)
value
- fromIndex
-
public int indexof(char[] value)
value
-
public int indexof(char[] value, int fromIndex)
value
- fromIndex
-
public int indexof(java.lang.String value)
isthis.startsWith(str, k)
true
.
-1
is returned.
java.lang.NullPointerException
- if str
is
null
.String.indexOf(java.lang.String)
public int indexof(java.lang.String value, int fromIndex)
value
- fromIndex
-
public boolean startsWith(java.lang.String str)
str
- the prefix
public boolean endsWith(java.lang.String str)
str
- the suffix.
public ByteBuffer delete()
public ByteBuffer delete(int len)
ByteBuffer
up to the specified length. The substring starts from the beginning and
extends to the character at index len - 1
or to the end of the
ByteBuffer
if no such character exists.
len
- The number of characters to remove from beginning to len
.
public ByteBuffer delete(int start, int end)
ByteBuffer
.
The substring begins at the specified start
and extends to
the character at index end - 1
or to the end of the
ByteBuffer
if no such character exists. If
start
is equal to end
, no changes are made.
start
- The beginning index, inclusive.end
- The ending index, exclusive.
java.lang.StringIndexOutOfBoundsException
- if start
is negative, greater than length()
, or
greater than end
.public ByteBuffer replace(int start, int end, byte[] value)
ByteBuffer
with bytes in the specified byte[]
. The substring
begins at the specified start
and extends to the byte
at index end - 1
or to the end of the
ByteBuffer
if no such byte exists. First the
byte in the substring are removed and then the specified
byte[]
is inserted at start
. (The
ByteBuffer
will be lengthened to accommodate the
specified byte[] if necessary.)
start
- The beginning index, inclusive.end
- The ending index, exclusive.value
- Byte[] that will replace previous contents.
java.lang.StringIndexOutOfBoundsException
- if start
is negative, greater than length()
, or
greater than end
.public ByteBuffer replace(byte[] pattern, byte[] replace)
pattern
- Pattern to remove from source.replace
- Pattern to replace removed pattern with.
public ByteBuffer replace(int start, int end, byte[] pattern, byte[] replace)
start
- The beginning index, inclusive.end
- The ending index, exclusive.pattern
- Pattern to remove from source.replace
- Pattern to replace removed pattern with.
public ByteBuffer replace(byte[][] pattern, byte[][] replace)
pattern
- Patterns to remove from source.replace
- Patterns to replace removed patterns with.
public ByteBuffer replace(int start, int end, byte[][] pattern, byte[][] replace)
start
- The beginning index, inclusive.end
- The ending index, exclusive.pattern
- Patterns to remove from source.replace
- Patterns to replace removed patterns with.
public ByteBuffer substring(int start)
ByteBuffer
that contains a subsequence of
bytes currently contained in this ByteBuffer
.The
substring begins at the specified index and extends to the end of the
ByteBuffer
.
start
- The beginning index, inclusive.
java.lang.StringIndexOutOfBoundsException
- if start
is
less than zero, or greater than the length of this
ByteBuffer
.public ByteBuffer substring(int start, int end)
ByteBuffer
that contains a subsequence of
characters currently contained in this ByteBuffer
. The
substring begins at the specified start
and
extends to the byte at index end - 1
. An
exception is thrown if
start
- The beginning index, inclusive.end
- The ending index, exclusive.
java.lang.StringIndexOutOfBoundsException
- if start
or end
are negative or greater than
length()
, or start
is
greater than end
.public static byte[] toBytes(boolean value)
value
-
public static byte[] toBytes(byte value)
value
-
public static byte[] toBytes(char value)
value
-
public static byte[] toBytes(short value)
value
-
public static byte[] toBytes(int value)
value
-
public static byte[] toBytes(long value)
value
-
public static byte[] toBytes(float value)
value
-
public static byte[] toBytes(double value)
value
-
public static byte[] toBytes(java.lang.String value)
value
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |