java.lang.Object
org.glavo.classfile.impl.BufWriterImpl
- All Implemented Interfaces:
BufWriter
-
Constructor Summary
ConstructorsConstructorDescriptionBufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context) BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize) BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize, ClassEntry thisClass, int majorVersion) -
Method Summary
Modifier and TypeMethodDescriptionReturns aByteBufferview of the bytes in the buffer.booleancanWriteDirect(ConstantPool other) Returns whether the provided constant pool is index-compatible with this one.Returns the constant pool builder associated with this buffer.context()voidcopyTo(byte[] array, int bufferOffset) Copy the contents of the buffer into a byte array.intvoidpatchInt(int offset, int size, int value) Patch a previously written integer value.voidreserveSpace(int freeBytes) Ensure that the buffer has at leastfreeBytesbytes of unused spacevoidsetLabelContext(LabelContext labelContext) intsize()Returns the number of bytes that have been written to the buffer.voidwriteBytes(byte[] arr) Write the contents of a byte array to the buffervoidwriteBytes(byte[] arr, int start, int length) Write a range of a byte array to the buffervoidwriteBytes(BufWriter other) Write the contents of anotherBufWriterto the buffervoidwriteDouble(double x) Write a double value to the buffervoidwriteFloat(float x) Write a float value to the buffervoidwriteIndex(PoolEntry entry) Write the index of the specified constant pool entry, as au2, to the buffervoidwriteIndexOrZero(PoolEntry entry) Write the index of the specified constant pool entry, as au2, to the buffer, or zero if the entry is nullvoidwriteInt(int x) Write a signed int to the buffervoidwriteIntBytes(int intSize, long intValue) Write a 1, 2, 4, or 8 byte integer value to the buffer.<T extends WritableElement<?>>
voidWrite a list of entities to the buffer.voidwriteListIndices(List<? extends PoolEntry> list) Write a list of constant pool entry indexes to the buffer.voidwriteLong(long x) Write a long value to the buffervoidwriteU1(int x) Write an unsigned byte to the buffervoidwriteU2(int x) Write an unsigned short to the buffer
-
Constructor Details
-
BufWriterImpl
-
BufWriterImpl
-
BufWriterImpl
public BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize, ClassEntry thisClass, int majorVersion)
-
-
Method Details
-
constantPool
Description copied from interface:BufWriterReturns the constant pool builder associated with this buffer.- Specified by:
constantPoolin interfaceBufWriter- Returns:
- the constant pool builder associated with this buffer
-
labelContext
-
setLabelContext
-
canWriteDirect
Description copied from interface:BufWriterReturns whether the provided constant pool is index-compatible with this one. This may be because they are the same constant pool, or because this constant pool was copied from the other.- Specified by:
canWriteDirectin interfaceBufWriter- Parameters:
other- the other constant pool- Returns:
- whether the provided constant pool is index-compatible with this one
-
thisClass
-
getMajorVersion
public int getMajorVersion() -
context
-
writeU1
public void writeU1(int x) Description copied from interface:BufWriterWrite an unsigned byte to the buffer -
writeU2
public void writeU2(int x) Description copied from interface:BufWriterWrite an unsigned short to the buffer -
writeInt
public void writeInt(int x) Description copied from interface:BufWriterWrite a signed int to the buffer -
writeFloat
public void writeFloat(float x) Description copied from interface:BufWriterWrite a float value to the buffer- Specified by:
writeFloatin interfaceBufWriter- Parameters:
x- the float value
-
writeLong
public void writeLong(long x) Description copied from interface:BufWriterWrite a long value to the buffer -
writeDouble
public void writeDouble(double x) Description copied from interface:BufWriterWrite a double value to the buffer- Specified by:
writeDoublein interfaceBufWriter- Parameters:
x- the int value
-
writeBytes
public void writeBytes(byte[] arr) Description copied from interface:BufWriterWrite the contents of a byte array to the buffer- Specified by:
writeBytesin interfaceBufWriter- Parameters:
arr- the byte array
-
writeBytes
Description copied from interface:BufWriterWrite the contents of anotherBufWriterto the buffer- Specified by:
writeBytesin interfaceBufWriter- Parameters:
other- the other BufWriter
-
writeBytes
public void writeBytes(byte[] arr, int start, int length) Description copied from interface:BufWriterWrite a range of a byte array to the buffer- Specified by:
writeBytesin interfaceBufWriter- Parameters:
arr- the byte arraystart- the offset within the byte array of the rangelength- the length of the range
-
patchInt
public void patchInt(int offset, int size, int value) Description copied from interface:BufWriterPatch a previously written integer value. Depending on the specified size, the entire value, or the low 1 or 2 bytes, may be written. -
writeIntBytes
public void writeIntBytes(int intSize, long intValue) Description copied from interface:BufWriterWrite a 1, 2, 4, or 8 byte integer value to the buffer. Depending on the specified size, the entire value, or the low 1, 2, or 4 bytes, may be written.- Specified by:
writeIntBytesin interfaceBufWriter- Parameters:
intSize- the size of the integer value being written, in bytesintValue- the integer value
-
reserveSpace
public void reserveSpace(int freeBytes) Description copied from interface:BufWriterEnsure that the buffer has at leastfreeBytesbytes of unused space- Specified by:
reserveSpacein interfaceBufWriter- Parameters:
freeBytes- the number of bytes to reserve
-
size
public int size()Description copied from interface:BufWriterReturns the number of bytes that have been written to the buffer. -
asByteBuffer
Description copied from interface:BufWriterReturns aByteBufferview of the bytes in the buffer.- Specified by:
asByteBufferin interfaceBufWriter- Returns:
- a
ByteBufferview of the bytes in the buffer
-
copyTo
public void copyTo(byte[] array, int bufferOffset) Description copied from interface:BufWriterCopy the contents of the buffer into a byte array. -
writeIndex
Description copied from interface:BufWriterWrite the index of the specified constant pool entry, as au2, to the buffer- Specified by:
writeIndexin interfaceBufWriter- Parameters:
entry- the constant pool entry
-
writeIndexOrZero
Description copied from interface:BufWriterWrite the index of the specified constant pool entry, as au2, to the buffer, or zero if the entry is null- Specified by:
writeIndexOrZeroin interfaceBufWriter- Parameters:
entry- the constant pool entry
-
writeList
Description copied from interface:BufWriterWrite a list of entities to the buffer. The length of the list is written as au2, followed by the bytes corresponding to each element in the list. Writing of the entities is delegated to the entry. -
writeListIndices
Description copied from interface:BufWriterWrite a list of constant pool entry indexes to the buffer. The length of the list is written as au2, followed by au2for each entry in the list.- Specified by:
writeListIndicesin interfaceBufWriter- Parameters:
list- the list of entries
-