Package com.strobel.reflection.emit
Class CodeStream
- java.lang.Object
-
- com.strobel.reflection.emit.CodeStream
-
public final class CodeStream extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]_dataThe content of this stream.private int_lengthActual number of bytes in this stream.private static intDEFAULT_SIZE
-
Constructor Summary
Constructors Constructor Description CodeStream()Constructs a newCodeStreamwith a default initial size.CodeStream(int initialSize)Constructs a newCodeStreamwith the given initial size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidensureCapacity(int size)Enlarge this byte stream so that it can receive n more bytes.byte[]getData()intgetLength()(package private) CodeStreamput11(int b1, int b2)Puts two bytes into this byte stream.(package private) CodeStreamput12(int b, int s)Puts a byte and a short into this byte stream.CodeStreamputByte(int b)Puts a byte into this byte stream.CodeStreamputByteArray(byte[] b, int offset, int length)Puts an array of bytes into this byte stream.CodeStreamputDouble(double d)Puts a double into this byte stream.CodeStreamputFloat(float f)Puts a float into this byte stream.CodeStreamputInt(int i)Puts an int into this byte stream.CodeStreamputLong(long l)Puts a long into this byte stream.CodeStreamputShort(int s)Puts a short into this byte stream.CodeStreamputUtf8(java.lang.String s)Puts an UTF8 string into this byte stream.voidreset()voidreset(int initialSize)
-
-
-
Field Detail
-
DEFAULT_SIZE
private static final int DEFAULT_SIZE
- See Also:
- Constant Field Values
-
_data
private byte[] _data
The content of this stream.
-
_length
private int _length
Actual number of bytes in this stream.
-
-
Constructor Detail
-
CodeStream
public CodeStream()
Constructs a newCodeStreamwith a default initial size.
-
CodeStream
public CodeStream(int initialSize)
Constructs a newCodeStreamwith the given initial size.- Parameters:
initialSize- the initial size of the byte stream to be constructed.
-
-
Method Detail
-
reset
public void reset()
-
reset
public void reset(int initialSize)
-
getData
public byte[] getData()
-
getLength
public int getLength()
-
putByte
public CodeStream putByte(int b)
Puts a byte into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b- a byte.- Returns:
- this byte stream.
-
put11
CodeStream put11(int b1, int b2)
Puts two bytes into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b1- a byte.b2- another byte.- Returns:
- this byte stream.
-
putShort
public CodeStream putShort(int s)
Puts a short into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
s- a short.- Returns:
- this byte stream.
-
put12
CodeStream put12(int b, int s)
Puts a byte and a short into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b- a byte.s- a short.- Returns:
- this byte stream.
-
putInt
public CodeStream putInt(int i)
Puts an int into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
i- an int.- Returns:
- this byte stream.
-
putLong
public CodeStream putLong(long l)
Puts a long into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
l- a long.- Returns:
- this byte stream.
-
putFloat
public CodeStream putFloat(float f)
Puts a float into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
f- a float.- Returns:
- this byte stream.
-
putDouble
public CodeStream putDouble(double d)
Puts a double into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
d- a double.- Returns:
- this byte stream.
-
putUtf8
public CodeStream putUtf8(java.lang.String s)
Puts an UTF8 string into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
s- a String.- Returns:
- this byte stream.
-
putByteArray
public CodeStream putByteArray(byte[] b, int offset, int length)
Puts an array of bytes into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b- an array of bytes. May be null to put length null bytes into this byte stream.offset- index of the fist byte of b that must be copied.length- number of bytes of b that must be copied.- Returns:
- this byte stream.
-
ensureCapacity
void ensureCapacity(int size)
Enlarge this byte stream so that it can receive n more bytes.- Parameters:
size- number of additional bytes that this byte stream should be able to receive.
-
-