Top Description Fields Constructors Methods
org.easymock.bytebuddy.jar.asm

public Class ByteVector

extends Object
Class Inheritance

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

Field Summary

Modifier and TypeField and Description
pack-priv byte[]
data

The content of this vector.

pack-priv int
length

The actual number of bytes in this vector.

Constructor Summary

AccessConstructor and Description
public
ByteVector()

Constructs a new ByteVector with a default initial capacity.

public
ByteVector(final int
the initial capacity of the byte vector to be constructed.
initialCapacity
)

Constructs a new ByteVector with the given initial capacity.

pack-priv
ByteVector(final byte[]
the initial data of the new byte vector.
data
)

Constructs a new ByteVector from the given initial data.

Method Summary

Modifier and TypeMethod and Description
pack-priv final ByteVector

Returns:

this byte vector.
encodeUtf8
(final String
the String to encode.
stringValue
,
final int
the index of the first character to encode. The previous characters are supposed to have already been encoded, using only one byte per character.
offset
,
final int
the maximum byte length of the encoded string, including the already encoded characters.
maxByteLength
)

Puts an UTF8 string into this byte vector.

private void
enlarge(final int
number of additional bytes that this byte vector should be able to receive.
size
)

Enlarges this byte vector so that it can receive 'size' more bytes.

pack-priv final ByteVector

Returns:

this byte vector.
put11
(final int
a byte.
byteValue1
,
final int
another byte.
byteValue2
)

Puts two bytes into this byte vector.

pack-priv final ByteVector

Returns:

this byte vector.
put112
(final int
a byte.
byteValue1
,
final int
another byte.
byteValue2
,
final int
a short.
shortValue
)

Puts two bytes and a short into this byte vector.

pack-priv final ByteVector

Returns:

this byte vector.
put12
(final int
a byte.
byteValue
,
final int
a short.
shortValue
)

Puts a byte and a short into this byte vector.

pack-priv final ByteVector

Returns:

this byte vector.
put122
(final int
a byte.
byteValue
,
final int
a short.
shortValue1
,
final int
another short.
shortValue2
)

Puts one byte and two shorts into this byte vector.

public ByteVector

Returns:

this byte vector.
putByte
(final int
a byte.
byteValue
)

Puts a byte into this byte vector.

public ByteVector

Returns:

this byte vector.
putByteArray
(final byte[]
an array of bytes. May be null to put byteLength null bytes into this byte vector.
byteArrayValue
,
final int
index of the first byte of byteArrayValue that must be copied.
byteOffset
,
final int
number of bytes of byteArrayValue that must be copied.
byteLength
)

Puts an array of bytes into this byte vector.

public ByteVector

Returns:

this byte vector.
putInt
(final int
an int.
intValue
)

Puts an int into this byte vector.

public ByteVector

Returns:

this byte vector.
putLong
(final long
a long.
longValue
)

Puts a long into this byte vector.

public ByteVector

Returns:

this byte vector.
putShort
(final int
a short.
shortValue
)

Puts a short into this byte vector.

public ByteVector

Returns:

this byte vector.
putUTF8
(final String
a String whose UTF8 encoded length must be less than 65536.
stringValue
)

Puts an UTF8 string into this byte vector.

public int

Returns:

the actual number of bytes in this vector.
size
()

Returns the actual number of bytes in this vector.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
pack-priv byte[] data

The content of this vector. Only the first length bytes contain real data.

lengthback to summary
pack-priv int length

The actual number of bytes in this vector.

Constructor Detail

ByteVectorback to summary
public ByteVector()

Constructs a new ByteVector with a default initial capacity.

ByteVectorback to summary
public ByteVector(final int initialCapacity)

Constructs a new ByteVector with the given initial capacity.

Parameters
initialCapacity:int

the initial capacity of the byte vector to be constructed.

ByteVectorback to summary
pack-priv ByteVector(final byte[] data)

Constructs a new ByteVector from the given initial data.

Parameters
data:byte[]

the initial data of the new byte vector.

Method Detail

encodeUtf8back to summary
pack-priv final ByteVector encodeUtf8(final String stringValue, final int offset, final int maxByteLength)

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).

Parameters
stringValue:String

the String to encode.

offset:int

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:int

the maximum byte length of the encoded string, including the already encoded characters.

Returns:ByteVector

this byte vector.

enlargeback to summary
private void enlarge(final int size)

Enlarges this byte vector so that it can receive 'size' more bytes.

Parameters
size:int

number of additional bytes that this byte vector should be able to receive.

put11back to summary
pack-priv final ByteVector put11(final int byteValue1, final int byteValue2)

Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteValue1:int

a byte.

byteValue2:int

another byte.

Returns:ByteVector

this byte vector.

put112back to summary
pack-priv final ByteVector put112(final int byteValue1, final int byteValue2, final int shortValue)

Puts two bytes and a short into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteValue1:int

a byte.

byteValue2:int

another byte.

shortValue:int

a short.

Returns:ByteVector

this byte vector.

put12back to summary
pack-priv final ByteVector put12(final int byteValue, final int shortValue)

Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteValue:int

a byte.

shortValue:int

a short.

Returns:ByteVector

this byte vector.

put122back to summary
pack-priv final ByteVector put122(final int byteValue, final int shortValue1, final int shortValue2)

Puts one byte and two shorts into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteValue:int

a byte.

shortValue1:int

a short.

shortValue2:int

another short.

Returns:ByteVector

this byte vector.

putByteback to summary
public ByteVector putByte(final int byteValue)

Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteValue:int

a byte.

Returns:ByteVector

this byte vector.

putByteArrayback to summary
public ByteVector putByteArray(final byte[] byteArrayValue, final int byteOffset, final int byteLength)

Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
byteArrayValue:byte[]

an array of bytes. May be null to put byteLength null bytes into this byte vector.

byteOffset:int

index of the first byte of byteArrayValue that must be copied.

byteLength:int

number of bytes of byteArrayValue that must be copied.

Returns:ByteVector

this byte vector.

putIntback to summary
public ByteVector putInt(final int intValue)

Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
intValue:int

an int.

Returns:ByteVector

this byte vector.

putLongback to summary
public ByteVector putLong(final long longValue)

Puts a long into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
longValue:long

a long.

Returns:ByteVector

this byte vector.

putShortback to summary
public ByteVector putShort(final int shortValue)

Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
shortValue:int

a short.

Returns:ByteVector

this byte vector.

putUTF8back to summary
public ByteVector putUTF8(final String stringValue)

Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.

Parameters
stringValue:String

a String whose UTF8 encoded length must be less than 65536.

Returns:ByteVector

this byte vector.

sizeback to summary
public int size()

Returns the actual number of bytes in this vector.

Returns:int

the actual number of bytes in this vector.