Package org.datanucleus.enhancer.asm
Class ByteVector
- java.lang.Object
-
- org.datanucleus.enhancer.asm.ByteVector
-
public class ByteVector extends Object
A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.- Author:
- Eric Bruneton
-
-
Constructor Summary
Constructors Constructor Description ByteVector()
Constructs a newByteVector
with a default initial capacity.ByteVector(int initialCapacity)
Constructs a newByteVector
with the given initial capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteVector
putByte(int byteValue)
Puts a byte into this byte vector.ByteVector
putByteArray(byte[] byteArrayValue, int byteOffset, int byteLength)
Puts an array of bytes into this byte vector.ByteVector
putInt(int intValue)
Puts an int into this byte vector.ByteVector
putLong(long longValue)
Puts a long into this byte vector.ByteVector
putShort(int shortValue)
Puts a short into this byte vector.ByteVector
putUTF8(String stringValue)
Puts an UTF8 string into this byte vector.int
size()
Returns the actual number of bytes in this vector.
-
-
-
Constructor Detail
-
ByteVector
public ByteVector()
Constructs a newByteVector
with a default initial capacity.
-
ByteVector
public ByteVector(int initialCapacity)
Constructs a newByteVector
with the given initial capacity.- Parameters:
initialCapacity
- the initial capacity of the byte vector to be constructed.
-
-
Method Detail
-
size
public int size()
Returns the actual number of bytes in this vector.- Returns:
- the actual number of bytes in this vector.
-
putByte
public ByteVector putByte(int byteValue)
Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
byteValue
- a byte.- Returns:
- this byte vector.
-
putShort
public ByteVector putShort(int shortValue)
Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
shortValue
- a short.- Returns:
- this byte vector.
-
putInt
public ByteVector putInt(int intValue)
Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
intValue
- an int.- Returns:
- this byte vector.
-
putLong
public ByteVector putLong(long longValue)
Puts a long into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
longValue
- a long.- Returns:
- this byte vector.
-
putUTF8
public ByteVector putUTF8(String stringValue)
Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
stringValue
- a String whose UTF8 encoded length must be less than 65536.- Returns:
- this byte vector.
-
putByteArray
public ByteVector putByteArray(byte[] byteArrayValue, int byteOffset, int byteLength)
Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
byteArrayValue
- an array of bytes. May be null to putbyteLength
null bytes into this byte vector.byteOffset
- index of the first byte of byteArrayValue that must be copied.byteLength
- number of bytes of byteArrayValue that must be copied.- Returns:
- this byte vector.
-
-