public class ByteArray
extends java.lang.Object
ByteArray.InternalInputStream
and OutputStream
Modifier and Type | Class and Description |
---|---|
(package private) class |
ByteArray.InternalInputStream
Internal Input stream for read the array
|
(package private) class |
ByteArray.InternalOutputStream
Internal output stream for write on the array
|
Modifier and Type | Field and Description |
---|---|
private byte[] |
array
Byte array
|
private int |
index
Read index
|
private ByteArray.InternalInputStream |
internalInputStream
Internal input stream for read the stream
|
private ByteArray.InternalOutputStream |
internalOutputStream
Internal output stream for write
|
private int |
mark
Actual mark
|
private int |
size
Actual size
|
Constructor and Description |
---|
ByteArray()
Create a new instance of ByteArray
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Number of bytes left to read
|
void |
clear()
Clear the array
|
private void |
expand(int more)
Expands, if need, the array
|
java.io.InputStream |
getInputStream()
Input stream for read
|
java.io.OutputStream |
getOutputStream()
Output stream for write
|
int |
getSize()
Array size
|
(package private) void |
mark()
Mark current read position
|
int |
read()
Read one byte
|
int |
read(byte[] b)
Read some bytes and fill an array.
|
int |
read(byte[] b,
int off,
int len)
Read some bytes and fill a part of array
|
<B extends Binarizable> |
readBinarizable(java.lang.Class<B> clas)
Read a
Binarizable from the byte array. |
<B extends Binarizable> |
readBinarizableArray(java.lang.Class<B> clas)
Read an array of
Binarizable . |
boolean |
readBoolean()
Read a boolean.
|
boolean[] |
readBooleanArray()
Read a boolean array from the byte array.
|
byte |
readByte()
Read a byte.
|
byte[] |
readByteArray()
Read a byte array.
|
char |
readChar()
Read a char.
|
char[] |
readCharArray()
Read a char array from the byte array
See writeCharArray(char...) |
double |
readDouble()
Read a double.
|
double[] |
readDoubleArray()
Read a double array from the byte array.
|
<E extends java.lang.Enum> |
readEnum(java.lang.Class<E> clas)
read an eum from the byte array.
|
<E extends java.lang.Enum> |
readEnumArray(java.lang.Class<E> clas)
Read an enum array from the byte array.
|
float |
readFloat()
Read a float.
|
float[] |
readFloatArray()
Read a float array from the byte array.
|
void |
readFromStart()
Restart the reading from start
|
int |
readInteger()
Read an integer.
|
int[] |
readIntegerArray()
Read an integer array from the byte array.
|
long |
readLong()
Read a long.
|
long[] |
readLongArray()
Read a long array from byte array.
|
short |
readShort()
Read a short.
|
short[] |
readShortArray()
read short array from data.
|
java.lang.String |
readString()
Read a String.
|
java.lang.String[] |
readStringArray()
read string array from the byte array.
|
(package private) void |
reset()
Return to last marked position and clear the mark
|
(package private) long |
skip(long n)
Skip a number of bytes
|
byte[] |
toArray()
Get an array
|
void |
write(byte[] b)
Write an array.
|
void |
write(byte[] b,
int off,
int len)
Write a part of array of bytes
|
void |
write(int b)
Write one byte
|
<B extends Binarizable> |
writeBinarizable(B binarizable)
Write a
Binarizable to the byte array. |
<B extends Binarizable> |
writeBinarizableArray(B... array)
Write
Binarizable array to the byte array. |
void |
writeBoolean(boolean booleanValue)
Write a boolean.
|
void |
writeBooleanArray(boolean... bools)
Write a boolean array to the byte array.
|
void |
writeByte(byte byteValue)
write a byte.
|
void |
writeByteArray(byte... array)
Write byte array.
|
void |
writeChar(char charValue)
Write a char.
|
void |
writeCharArray(char... array)
Write a char array.
|
void |
writeDouble(double doubleValue)
Write a double.
|
void |
writeDoubleArray(double... array)
Write double array.
|
<E extends java.lang.Enum> |
writeEnum(E e)
Write an enum.
|
<E extends java.lang.Enum> |
writeEnumArray(E... array)
Write an enum array.
|
void |
writeFloat(float floatValue)
Write a float.
|
void |
writeFloatArray(float... array)
Write a float array.
|
void |
writeInteger(int intValue)
Write an integer.
|
void |
writeIntegerArray(int... array)
Write integer array.
|
void |
writeLong(long longValue)
Write a long.
|
void |
writeLongArray(long... array)
Write long array.
|
void |
writeShort(short shortValue)
Write a short.
|
void |
writeShortArray(short... array)
Write short array.
|
void |
writeString(java.lang.String string)
Write a String.
|
void |
writeStringArray(java.lang.String... array)
Write String array.
|
private byte[] array
private int index
private final ByteArray.InternalInputStream internalInputStream
private final ByteArray.InternalOutputStream internalOutputStream
private int mark
private int size
private void expand(int more)
more
- Number of need free spacevoid mark()
void reset()
long skip(long n)
n
- Number of bytes to skippublic int available()
public void clear()
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public int getSize()
public int read()
public int read(byte[] b)
read(b, 0, b.length)
b
- Array to fillpublic int read(byte[] b, int off, int len)
b
- Array to filloff
- Where start fill the arraylen
- Number maximum of byte to readpublic <B extends Binarizable> B readBinarizable(java.lang.Class<B> clas) throws java.lang.Exception
B
- Type of Binarizable
clas
- Class of the Binarizable
to readBinarizable
java.lang.Exception
- If the actual read data in the byte array doesn't represents the Binarizable
askedpublic <B extends Binarizable> B[] readBinarizableArray(java.lang.Class<B> clas) throws java.lang.Exception
Binarizable
.writeBinarizableArray(Binarizable...)
for write an array of Binarizable
B
- Type of Binarizable
clas
- Class of the Binarizable
to readjava.lang.Exception
- If the byte array doesn't contains an array of desired Binarizable
at the actual read indexpublic boolean readBoolean()
writeBoolean(boolean)
public boolean[] readBooleanArray()
writeBooleanArray(boolean...)
for write the boolean arraypublic byte readByte()
writeByte(byte)
public byte[] readByteArray()
writeByteArray(byte...)
for write the byte arraypublic char readChar()
writeChar(char)
public char[] readCharArray()
writeCharArray(char...)
public double readDouble()
writeDouble(double)
public double[] readDoubleArray()
writeDoubleArray(double...)
public <E extends java.lang.Enum> E readEnum(java.lang.Class<E> clas) throws java.lang.Exception
writeEnum(Enum)
for write itE
- Enum typeclas
- Class of the enumjava.lang.Exception
- If data not corresponds to the asked enumpublic <E extends java.lang.Enum> E[] readEnumArray(java.lang.Class<E> clas) throws java.lang.Exception
writeEnumArray(Enum...)
for write itE
- Enum typeclas
- Enum class to readjava.lang.Exception
- If data not corresponds to an array of desired enumpublic float readFloat()
writeFloat(float)
public float[] readFloatArray()
writeFloatArray(float...)
public void readFromStart()
public int readInteger()
writeInteger(int)
public int[] readIntegerArray()
writeIntegerArray(int...)
public long readLong()
writeLong(long)
public long[] readLongArray()
writeLongArray(long...)
public short readShort()
writeShort(short)
public short[] readShortArray()
writeShortArray(short...)
public java.lang.String readString()
writeString(String)
public java.lang.String[] readStringArray()
writeStringArray(String...)
public byte[] toArray()
public void write(byte[] b)
write(b, 0, b.length)
b
- Array to writepublic void write(byte[] b, int off, int len)
b
- Array to writeoff
- Where start read in the arraylen
- Number of bytes to writepublic void write(int b)
b
- Byte to writepublic <B extends Binarizable> void writeBinarizable(B binarizable)
B
- Binarizable
typebinarizable
- Binarizable
to write. null
is acceptpublic <B extends Binarizable> void writeBinarizableArray(B... array)
B
- Binarizable
typearray
- Binarizable
array to writepublic void writeBoolean(boolean booleanValue)
readBoolean()
booleanValue
- Boolean to writepublic void writeBooleanArray(boolean... bools)
readBooleanArray()
for read it laterbools
- Boolean array to storepublic void writeByte(byte byteValue)
readByte()
byteValue
- Byte to writepublic void writeByteArray(byte... array)
readByteArray()
array
- Array to storepublic void writeChar(char charValue)
readChar()
charValue
- Char to writepublic void writeCharArray(char... array)
readCharArray()
for readarray
- Array to writepublic void writeDouble(double doubleValue)
readDouble()
doubleValue
- Double to writepublic void writeDoubleArray(double... array)
readDoubleArray()
for readarray
- Array of double to writepublic <E extends java.lang.Enum> void writeEnum(E e)
readEnum(Class)
to readE
- Enum typee
- Enum to writepublic <E extends java.lang.Enum> void writeEnumArray(E... array)
readEnumArray(Class)
for read itE
- Enum typearray
- Array of enum to writepublic void writeFloat(float floatValue)
readFloat()
floatValue
- Float to writepublic void writeFloatArray(float... array)
readFloatArray()
for readarray
- Array to readpublic void writeInteger(int intValue)
readInteger()
intValue
- Integer to writepublic void writeIntegerArray(int... array)
readIntegerArray()
for readarray
- Array of integer to writepublic void writeLong(long longValue)
readLong()
longValue
- Long to writepublic void writeLongArray(long... array)
readLongArray()
for readarray
- Array of long to writepublic void writeShort(short shortValue)
readShort()
shortValue
- Short to writepublic void writeShortArray(short... array)
readShortArray()
for readarray
- Array of short to writepublic void writeString(java.lang.String string)
readString()
string
- String to writepublic void writeStringArray(java.lang.String... array)
readStringArray()
for readarray
- Array of String to write