public abstract class AbstractStructure
extends java.lang.Object
Provides common services such as reading, writing and debugging.
Modifier and Type | Field and Description |
---|---|
protected ClassFile |
classFile
Parent class file for this structure.
|
protected boolean |
debug
Flag for debugging while reading and writing class files.
|
static java.lang.String |
SYSTEM_PROPERTY_DEBUG
Set this JVM System property to true to switch on debugging for
reading and writing class files.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractStructure()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
debug(java.lang.String message)
Utility method for derived structures.
|
ClassFile |
getClassFile()
Get parent class file.
|
boolean |
getDebug()
Get the debug mode for this structure.
|
protected int |
getLength(java.lang.Object array)
Utility method for derived structures.
|
protected java.lang.String |
printAccessFlags(int accessFlags)
Utility method for derived structures.
|
protected abstract java.lang.String |
printAccessFlagsVerbose(int accessFlags)
Utility method for derived structures.
|
protected java.lang.String |
printAccessFlagsVerbose(int[] availableAccessFlags,
java.lang.String[] availableAccessFlagsVerbose,
int accessFlags)
Utility method for derived structures.
|
protected java.lang.String |
printBytes(int bytes)
Utility method for derived structures.
|
void |
read(java.io.DataInput in)
Read this structure from the given DataInput.
|
void |
setClassFile(ClassFile classFile)
Set parent class file.
|
void |
setDebug(boolean debug)
Set the debug mode for this structure.
|
void |
write(java.io.DataOutput out)
Write this structure to the given DataOutput.
|
public static final java.lang.String SYSTEM_PROPERTY_DEBUG
protected ClassFile classFile
protected boolean debug
public ClassFile getClassFile()
public void setClassFile(ClassFile classFile)
Has to be called at least once on a structure.
classFile
- the new parent class filepublic void read(java.io.DataInput in) throws InvalidByteCodeException, java.io.IOException
Excpects DataInput to be in JVM class file format and just before a structure of this kind. No look ahead parsing since the class file format is deterministic.
in
- the DataInput from which to readInvalidByteCodeException
- if the byte code is invalidjava.io.IOException
- if an exception occurs with the DataInputpublic void write(java.io.DataOutput out) throws InvalidByteCodeException, java.io.IOException
The written bytes are in JVM class file format.
out
- the DataOutput to which to writeInvalidByteCodeException
- if the structure is internally inconsistentjava.io.IOException
- if an exception occurs with the DataOutputpublic boolean getDebug()
public void setDebug(boolean debug)
debug
- the new debug modeprotected int getLength(java.lang.Object array)
array
- the array for which the length is requestedprotected void debug(java.lang.String message)
message
- the debug messageprotected java.lang.String printBytes(int bytes)
bytes
- the int value to print as a hex stringprotected java.lang.String printAccessFlags(int accessFlags)
accessFlags
- the unsigned short value to print as a hex stringprotected abstract java.lang.String printAccessFlagsVerbose(int accessFlags)
accessFlags
- the unsigned short value to print as a hex stringprotected java.lang.String printAccessFlagsVerbose(int[] availableAccessFlags, java.lang.String[] availableAccessFlagsVerbose, int accessFlags)
availableAccessFlags
- array with the access flags available
for the derived structureavailableAccessFlagsVerbose
- array with verbose description
of the access flags available for the derived structureaccessFlags
- the unsigned short value to print as a hex string