类 ByteVector
java.lang.Object
cn.taketoday.bytecode.ByteVector
A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream
on top of a ByteArrayOutputStream, but is more efficient.
- 作者:
- Eric Bruneton
-
字段概要
字段 -
构造器概要
构造器构造器说明Constructs a newByteVectorwith a default initial capacity.ByteVector(byte[] data) Constructs a newByteVectorfrom the given initial data.ByteVector(int initialCapacity) Constructs a newByteVectorwith the given initial capacity. -
方法概要
修饰符和类型方法说明(专用程序包) final ByteVectorencodeUtf8(String stringValue, int offset, int maxByteLength) Puts an UTF8 string into this byte vector.private voidenlarge(byte[] data, int size) private voidenlarge(int size) Enlarges this byte vector so that it can receive 'size' more bytes.(专用程序包) final ByteVectorput11(int byteValue1, int byteValue2) Puts two bytes into this byte vector.(专用程序包) final ByteVectorput112(int byteValue1, int byteValue2, int shortValue) Puts two bytes and a short into this byte vector.(专用程序包) final ByteVectorput12(int byteValue, int shortValue) Puts a byte and a short into this byte vector.(专用程序包) final ByteVectorput122(int byteValue, int shortValue1, int shortValue2) Puts one byte and two shorts into this byte vector.putByte(int byteValue) Puts a byte into this byte vector.putByteArray(byte[] byteArrayValue, int byteOffset, int byteLength) Puts an array of bytes into this byte vector.putInt(int intValue) Puts an int into this byte vector.putLong(long longValue) Puts a long into this byte vector.putShort(int shortValue) Puts a short into this byte vector.Puts an UTF8 string into this byte vector.intsize()Returns the actual number of bytes in this vector.
-
字段详细资料
-
data
byte[] dataThe content of this vector. Only the firstlengthbytes contain real data. -
length
int lengthThe actual number of bytes in this vector.
-
-
构造器详细资料
-
ByteVector
public ByteVector()Constructs a newByteVectorwith a default initial capacity. -
ByteVector
public ByteVector(int initialCapacity) Constructs a newByteVectorwith the given initial capacity.- 参数:
initialCapacity- the initial capacity of the byte vector to be constructed.
-
ByteVector
ByteVector(byte[] data) Constructs a newByteVectorfrom the given initial data.- 参数:
data- the initial data of the new byte vector.
-
-
方法详细资料
-
size
public int size()Returns the actual number of bytes in this vector.- 返回:
- the actual number of bytes in this vector.
-
putByte
Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteValue- a byte.- 返回:
- this byte vector.
-
put11
Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteValue1- a byte.byteValue2- another byte.- 返回:
- this byte vector.
-
putShort
Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
shortValue- a short.- 返回:
- this byte vector.
-
put12
Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteValue- a byte.shortValue- a short.- 返回:
- this byte vector.
-
put112
Puts two bytes and a short into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteValue1- a byte.byteValue2- another byte.shortValue- a short.- 返回:
- this byte vector.
-
putInt
Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
intValue- an int.- 返回:
- this byte vector.
-
put122
Puts one byte and two shorts into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteValue- a byte.shortValue1- a short.shortValue2- another short.- 返回:
- this byte vector.
-
putLong
Puts a long into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
longValue- a long.- 返回:
- this byte vector.
-
putUTF8
Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
stringValue- a String whose UTF8 encoded length must be less than 65536.- 返回:
- this byte vector.
-
encodeUtf8
Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary. The string length is encoded in two bytes before the encoded characters, if there is space for that (i.e. if this.length - offset - 2 >= 0).- 参数:
stringValue- the String to encode.offset- the index of the first character to encode. The previous characters are supposed to have already been encoded, using only one byte per character.maxByteLength- the maximum byte length of the encoded string, including the already encoded characters.- 返回:
- this byte vector.
-
putByteArray
Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.- 参数:
byteArrayValue- an array of bytes. May be null to putbyteLengthnull 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.- 返回:
- this byte vector.
-
enlarge
private void enlarge(int size) Enlarges this byte vector so that it can receive 'size' more bytes.- 参数:
size- number of additional bytes that this byte vector should be able to receive.
-
enlarge
private void enlarge(byte[] data, int size)
-