Overview | Package | Class | Tree | Deprecated | Index | Help
| ej-technologies
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gjt.jclasslib.structures
Class AbstractStructure

    java.lang.Object
      org.gjt.jclasslib.structures.AbstractStructure

Direct Known Subclasses:
  AbstractStructureWithAttributes, CPInfo, ElementValue, ElementValuePair, ExceptionTableEntry, InnerClassesEntry, LineNumberTableEntry, LocalVariableCommonEntry

public abstract class AbstractStructure
extends Object

Base class for all structures defined in the class file format.

Provides common services such as reading, writing and debugging.

Version:
  $Revision: 1.5 $ $Date: 2004/12/28 13:04:32 $
Author:
  Ingo Kegel, Vitor Carreira

Field Summary
`protected ClassFile` | `classFile` Parent class file for this structure.
`protected boolean` | `debug` Flag for debugging while reading and writing class files.
`static String` | `SYSTEM_PROPERTY_DEBUG` Set this JVM System property to true to switch on debugging for reading and writing class files.

Constructor Summary
`protected` | `AbstractStructure()` Constructor.

Method Summary
`protected void` | `debug(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(Object array)` Utility method for derived structures.
`protected String` | `printAccessFlags(int accessFlags)` Utility method for derived structures.
`protected abstract String` | `printAccessFlagsVerbose(int accessFlags)` Utility method for derived structures.
`protected String` | `printAccessFlagsVerbose(int[] availableAccessFlags, String[] availableAccessFlagsVerbose, int accessFlags)` Utility method for derived structures.
`protected String` | `printBytes(int bytes)` Utility method for derived structures.
`void` | `read(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(DataOutput out)` Write this structure to the given `DataOutput`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SYSTEM_PROPERTY_DEBUG

    public static final String SYSTEM_PROPERTY_DEBUG

  Set this JVM System property to true to switch on debugging for reading and writing class files.

  See Also:
    Constant Field Values

### classFile

    protected ClassFile classFile

  Parent class file for this structure. `Null` for a `ClassFile` structure.

### debug

    protected boolean debug

  Flag for debugging while reading and writing class files.

Constructor Detail

### AbstractStructure

    protected AbstractStructure()

  Constructor.

Method Detail

### getClassFile

    public ClassFile getClassFile()

  Get parent class file.

  Returns:
    the class file

### setClassFile

    public void setClassFile(ClassFile classFile)

  Set parent class file.

  Has to be called at least once on a structure.

  Parameters:
    `classFile` - the new parent class file

### read

    public void read(DataInput in)
              throws InvalidByteCodeException,
                     IOException

  Read this structure from the given `DataInput`.

  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.

  Parameters:
    `in` - the `DataInput` from which to read
  Throws:
    `InvalidByteCodeException` - if the byte code is invalid
    `IOException` - if an exception occurs with the `DataInput`

### write

    public void write(DataOutput out)
               throws InvalidByteCodeException,
                      IOException

  Write this structure to the given `DataOutput`.

  The written bytes are in JVM class file format.

  Parameters:
    `out` - the `DataOutput` to which to write
  Throws:
    `InvalidByteCodeException` - if the structure is internally inconsistent
    `IOException` - if an exception occurs with the `DataOutput`

### getDebug

    public boolean getDebug()

  Get the debug mode for this structure.

  Returns:
    whether debug is on or not

### setDebug

    public void setDebug(boolean debug)

  Set the debug mode for this structure.

  Parameters:
    `debug` - the new debug mode

### getLength

    protected int getLength(Object array)

  Utility method for derived structures. Get the length of an arbitrary array which may hold primitive types or reference types or may be null.

  Parameters:
    `array` - the array for which the length is requested
  Returns:
    the length

### debug

    protected void debug(String message)

  Utility method for derived structures. Dump a specific debug message.

  Parameters:
    `message` - the debug message

### printBytes

    protected String printBytes(int bytes)

  Utility method for derived structures. Print an int value as a hex string.

  Parameters:
    `bytes` - the int value to print as a hex string
  Returns:
    the hex string

### printAccessFlags

    protected String printAccessFlags(int accessFlags)

  Utility method for derived structures. Print an access flag or an unsigned short value as a hex string.

  Parameters:
    `accessFlags` - the unsigned short value to print as a hex string
  Returns:
    the hex string

### printAccessFlagsVerbose

    protected abstract String printAccessFlagsVerbose(int accessFlags)

  Utility method for derived structures. Print an access flag as a space separated list of verbose java access modifiers.

  Parameters:
    `accessFlags` - the unsigned short value to print as a hex string
  Returns:
    the hex string

### printAccessFlagsVerbose

    protected String printAccessFlagsVerbose(int[] availableAccessFlags,
                                             String[] availableAccessFlagsVerbose,
                                             int accessFlags)

  Utility method for derived structures. Print an access flag as a space separated list of verbose java access modifiers.

  Parameters:
    `availableAccessFlags` - array with the access flags available for the derived structure
    `availableAccessFlagsVerbose` - array with verbose description of the access flags available for the derived structure
    `accessFlags` - the unsigned short value to print as a hex string
  Returns:
    the access flags verbose description

Overview | Package | Class | Tree | Deprecated | Index | Help
| ej-technologies
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD