|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjef.dna.Dna
public class Dna
The Dna class is the object oriented representation of a Java class file's
content. Each item can be accessed through getter and setter methods. A Dna
instance is returned by the DnaReader class, and can thereon be written to a file
leveraging on the DnaWriter class.
| Field Summary | |
|---|---|
int |
ACC_ABSTRACT
Bit mask for the ABSTRACT access modifier |
int |
ACC_FINAL
Bit mask for the FINAL access modifier |
int |
ACC_INTERFACE
Bit mask for the INTERFACE access modifier |
int |
ACC_PUBLIC
Bit mask for the PUBLIC access modifier |
int |
ACC_SUPER
Bit mask for the SUPER access modifier |
| Constructor Summary | |
|---|---|
Dna()
Constructor. |
|
Dna(int magicNumber)
Parameterized constructor. |
|
| Method Summary | |
|---|---|
void |
fromStream(java.io.DataInputStream dis)
Reads a Java class file from the specified stream, and fills in the current Dna
instance. |
int |
getAccessFlags()
Return the current class access modifier. |
AttribFactory |
getAttribFactory()
Returns the AttribFactory configured in the Dna configuration
file, needed for instantiating Attributes instances. |
int |
getAttributeCount()
Returns the number of attributes of the Java class represented by the current Dna instance or -1 if any attribute has been set. |
AttributesTable |
getAttributes()
Returns the AttributesTable representing the attributes exposed by the Java
class represented by the current Dna instance. |
AttributesTableFactory |
getAttributesTableFactory()
Returns the AttributesTableFactory configured in the Dna
configuration file, needed for instantiating Attribute instances. |
int |
getConstantPoolCount()
Returns the number of entries in the Constant Pool Table. |
ConstantPoolTable |
getConstantPoolTable()
Returns the Constant Pool Table. |
ConstantPoolTableFactory |
getConstantPoolTableFactory()
Returns the ConstantPoolTableFactory configured in the Dna
configuration file, needed for instantiating ConstantPoolTable instances. |
ConstInfoFactory |
getConstInfoFactory()
Returns the ConstantInfoFactory configured in the Dna
configuration file, needed for instantiating ConstantInfo instances. |
FieldsTable |
getFields()
Returns the fields of the Java class represented by the current Dna instance,
as a FieldsTable instance. |
int |
getFieldsCount()
This method returns the number of field declared by the Java class represented by this Dna instance, or -1 if the fields property has not already
been set. |
FieldsTableFactory |
getFieldsTableFactory()
Returns the FieldsTableFactory configured in the Dna
configuration file, needed for instantiating FieldInfoStructure instances. |
java.lang.String |
getFqnAsString(int index)
This method returns the FQN of the class associated with the given Dna
instance. |
int |
getFqnReference()
This method returns the index of the constant pool table's entry containig the constant UTF8 info storing the current Dna instance's FQN. |
InfoStructuresFactory |
getInfoStructuresFactory()
Returns the factory class used for instantiating InfoStructure components. |
MethodInfoStructure |
getInitMethod()
|
InstructionFactory |
getInstructionFactory()
Returns the InstructionFactory configured in the Dna
configuration file, needed for instantiating Instruction instances. |
int |
getInterfaceCount()
Returns the number of implemented interfaces or -1 if the interfaces property has not been set. |
java.util.List<java.lang.Integer> |
getInterfaces()
Returns the set of references to the constant pool table. |
int |
getMagicNumber()
Returns the class' file magic number. |
int |
getMajorNumber()
Returns the Dna instance magic number. |
int |
getMethodCount()
Returns the number of methods declared by the Java class represented by the current Dna instance or -1 if the methods property has not been set. |
MethodsTable |
getMethods()
Returns the MethodsTable instance containing all the methods declared by the
Java class represented by the current Dna instance. |
MethodsTableFactory |
getMethodsTableFactory()
Returns the MethodsTableFactory configured in the Dna
configuration file, needed for instantiating MethodInfoStructure instances. |
int |
getMinorNumber()
Returns the class' file minor number. |
int |
getSuperClass()
Returns the index of the Constant Class Info representing the direct
superclass of the current class, into the constant pool table. |
int |
getThisClass()
Returns the reference to the constant pool table entry of type
Constant Class Info representing the current class. |
void |
setAccessFlags(int flags)
This method sets the current class access modifier. |
void |
setAttributes(AttributesTable attributes)
Sets the attributes exposed by the Java class represented by the current Dna
instance. |
void |
setConstantPoolTable(ConstantPoolTable table)
Sets the Constant Pool Table in the current Dna instance. |
void |
setFields(FieldsTable fields)
Sets the fields declared by the Java class represented by this Dna instance. |
void |
setInitMethod(MethodInfoStructure initMethod)
|
void |
setInterfaces(java.util.List<java.lang.Integer> interfaces)
Set the array of references to the constant pool table entries of type Constant Class Info associated with this class' implemented interfaces. |
void |
setMajorNumber(int major)
Sets the major number in the Dna instance. |
void |
setMethods(MethodsTable methods)
Sets the MethodsTable instance containing all the methods defined by the Java
class represented by the current Dna instance. |
void |
setMinorNumber(int minor)
Sets the class' file minor number in the Dna instance. |
void |
setSuperClass(int superClass)
Set the reference to the constant pool table entry representing the direct superclass of the class associated with the current Dna instance |
void |
setThisClass(int thisClass)
Sets the reference to the constant pool table entry of type
Constant Class Info
representing the current class. |
void |
toStream(java.io.DataOutputStream dos)
This method writes the Dna instance's content to the specified
DataOutputStream |
void |
validate()
This method launches the validation process over the current Dna instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final int ACC_PUBLIC
public final int ACC_FINAL
public final int ACC_SUPER
public final int ACC_INTERFACE
public final int ACC_ABSTRACT
| Constructor Detail |
|---|
public Dna()
throws InstantiatorException
InstantiatorException - The jef.config.Instantiator was unable to perform one the required
instantiationspublic Dna(int magicNumber)
magicNumber - The java class file magic number| Method Detail |
|---|
public int getMagicNumber()
public void setMinorNumber(int minor)
Dna instance.
minor - The minor number.public int getMinorNumber()
public void setMajorNumber(int major)
Dna instance.
major - The major number.public int getMajorNumber()
Dna instance magic number.
public int getConstantPoolCount()
constantPoolCount property depends
on the presence of the constantPoolTabl property,
this method might return -1 should the constantPoolTable
be null.
ConstantPoolTable
is not already set.public void setConstantPoolTable(ConstantPoolTable table)
Dna instance.
This method has also impact over the constantPoolCount property:
its value is set to equal the constantPoolTable's size plus one.
table - The ConstantPoolTable instance containing all the constant pool
table entries.public ConstantPoolTable getConstantPoolTable()
ConstantPoolTable representing the Constant Pool Table.public void setAccessFlags(int flags)
flags - The valid mask of flagspublic int getAccessFlags()
int accessFlagpublic void setThisClass(int thisClass)
Constant Class Info
representing the current class.
thisClass - The reference to the constant pool table entry representing the class defined by
this Dna instancepublic int getThisClass()
Constant Class Info representing the current class.
int thisClasspublic void setSuperClass(int superClass)
Dna instance
superClass - superClasspublic int getSuperClass()
Constant Class Info representing the direct
superclass of the current class, into the constant pool table.
int superClasspublic int getInterfaceCount()
interfaces property has not been set.
int interfaceCount or -1public void setInterfaces(java.util.List<java.lang.Integer> interfaces)
Constant Class Info associated with this class' implemented interfaces.
interfaces - interfaces interfaces Each entry of interfaces has to be of
type Integerpublic java.util.List<java.lang.Integer> getInterfaces()
List is an Integer referring to a constant pool table's entry
of type Constant Class Info
List interfacespublic int getFieldsCount()
Dna instance, or -1 if the fields property has not already
been set.
public void setFields(FieldsTable fields)
Dna instance.
The fields are represented by a FieldsTable instance.
fields - The FieldsTable instance representing the current Java class'
fieldspublic FieldsTable getFields()
Dna instance,
as a FieldsTable instance.
public int getMethodCount()
Dna instance or -1 if the methods property has not been set.
public void setMethods(MethodsTable methods)
MethodsTable instance containing all the methods defined by the Java
class represented by the current Dna instance. The length of the above
MethodsTable has to be equal to the number of methods specified via the
setMethodCount method.
methods - The MethodsTable containing the definitions of all the methods
declared by the current Java classpublic MethodsTable getMethods()
MethodsTable instance containing all the methods declared by the
Java class represented by the current Dna instance.
MethodsTable which stores the current Java class' methodspublic int getAttributeCount()
Dna instance or -1 if any attribute has been set.
public void setAttributes(AttributesTable attributes)
Dna
instance. These attributes are stored within an AttributesTable instance.
attributes - The AttributesTable representing the current class' attributespublic AttributesTable getAttributes()
AttributesTable representing the attributes exposed by the Java
class represented by the current Dna instance.
AttributesTable
public void toStream(java.io.DataOutputStream dos)
throws DnaSerializationException,
MissingDnaContainerException
Dna instance's content to the specified
DataOutputStream
dos - DataOutputStream used for writing the Dna content to
DnaSerializationException - Thrown should an error occour while writing to the output stream
MissingDnaContainerException - This exception can only be thrown by inner components should they be missing a
reference to their Dna-container.
public void fromStream(java.io.DataInputStream dis)
throws DnaDeserializationException,
MissingDnaContainerException
Dna
instance.
dis - The DataInputStream the Java class should be read from
MissingDnaContainerException - One of the inner components is missing a reference to the current
Dna container
DnaDeserializationException - An error occourred during the Dna deserialization process
public void validate()
throws DnaValidationException
Dna instance.
DnaValidationException - The validation process failed.
public int getFqnReference()
throws WrongReferenceInConstantPoolTableException
Dna instance's FQN. In order to get the associated
String representation, please use the
public String getFqnAsString(int index) method.
int The index of the constant UTF8 entry storing the FQN of this
Dna instance
WrongReferenceInConstantPoolTableException - One of the inner Dna components has a wrong reference to one of
the ConstantPoolTable's entry
public java.lang.String getFqnAsString(int index)
throws WrongReferenceInConstantPoolTableException
Dna
instance. The required int index argument can be obtained through the
public int getFqnReference() method.
index - The index of the ConstantPoolTable entry storing the fully
qualified name of the Java class represented by the current Dna
instance
WrongReferenceInConstantPoolTableException
WrongReferenceInConstantPoolTableException - Trying to access a ConstantPoolTable entry of a type not matching
with the expected onepublic InfoStructuresFactory getInfoStructuresFactory()
InfoStructure components.
InfoStructuresFactorypublic ConstantPoolTableFactory getConstantPoolTableFactory()
ConstantPoolTableFactory configured in the Dna
configuration file, needed for instantiating ConstantPoolTable instances.
ConstantPoolTableFactory implementationpublic ConstInfoFactory getConstInfoFactory()
ConstantInfoFactory configured in the Dna
configuration file, needed for instantiating ConstantInfo instances.
ConstantInfoFactory implementationpublic AttribFactory getAttribFactory()
AttribFactory configured in the Dna configuration
file, needed for instantiating Attributes instances.
AttribFactory implementationpublic FieldsTableFactory getFieldsTableFactory()
FieldsTableFactory configured in the Dna
configuration file, needed for instantiating FieldInfoStructure instances.
FieldsTableFactory implementationpublic MethodsTableFactory getMethodsTableFactory()
MethodsTableFactory configured in the Dna
configuration file, needed for instantiating MethodInfoStructure instances.
MethodsTableFactory implementationpublic AttributesTableFactory getAttributesTableFactory()
AttributesTableFactory configured in the Dna
configuration file, needed for instantiating Attribute instances.
AttributesTableFactory implementationpublic InstructionFactory getInstructionFactory()
InstructionFactory configured in the Dna
configuration file, needed for instantiating Instruction instances.
InstructionFactory implementationpublic MethodInfoStructure getInitMethod()
public void setInitMethod(MethodInfoStructure initMethod)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||