jef.dna.attributes
Interface Attribute

All Superinterfaces:
BytesCountable, java.lang.Cloneable
All Known Subinterfaces:
CodeAttribute, ConstantValueAttribute, DeprecatedAttribute, EnclosingMethodAttribute, ExceptionAttribute, ExceptionsAttribute, InnerClassesAttribute, LineNumberTableAttribute, LocalVariableTableAttribute, SignatureAttribute, SourceDebugExtensionAttribute, SourceFileAttribute, SyntheticAttribute
All Known Implementing Classes:
Code, ConstantValue, DeprecatedAttribute, EnclosingMethod, ExceptionAttr, GenericAttribute, InnerClasses, LineNumberTableAttribute, LocalVariableTableAttribute, Signature, SourceDebugExtension, SourceFileAttribute, SyntheticAttribute

public interface Attribute
extends java.lang.Cloneable, BytesCountable

This is the ancestor of all the interfaces implemented by those classes representing the Attributes entities.

Author:
Francesco Russo frusso@cs.unibo.it

Method Summary
 java.lang.Object clone()
           
 void fromStream(java.io.DataInputStream dis, Dna dna, int nameIndex, int length)
          This method reads the data with which the attribute has to be initialized.
 Dna getDna()
          Get the Dna instance which will contain the current Attribute
 int getLength()
          Returns the length expressed in bytes of the attribute's payload.
 int getNameIndex()
          Returns the attribute's name index,
 void setDna(Dna dna)
          Set the Dna instance which will contain the current Attribute
 void setNameIndex(int index)
          Set a valid index into the constant pool table.
 void toStream(java.io.DataOutputStream dos)
          This method writes the attribute to the provided output stream.
 void updateRefs(int offset)
          This method updates all the references pointing to constant pool table's entries this attributes holds.
 boolean validate()
          This method has to perform a validation process over the Attribute according to what specified by the JVM Official Specification.
 
Methods inherited from interface jef.dna.util.BytesCountable
getBytesCount
 

Method Detail

setNameIndex

void setNameIndex(int index)
Set a valid index into the constant pool table. This index has to point to an entry of type ConstantUtf8 exposing as value, the literal representation of the current Attribute. I.e., should the attribute be a Code attribute, the constant pool table entry at the provided index would be of type ConstantUtf8, with the string Code as value.

Parameters:
index - A valid index in the constant pool table

getNameIndex

int getNameIndex()
Returns the attribute's name index,

Returns:
int The index into the constant pool table at which the attribute's logical name can be found

getLength

int getLength()
Returns the length expressed in bytes of the attribute's payload.

Returns:
int The length (in bytes) of the attribute's payload

updateRefs

void updateRefs(int offset)
This method updates all the references pointing to constant pool table's entries this attributes holds.

Parameters:
offset - The offset

setDna

void setDna(Dna dna)
Set the Dna instance which will contain the current Attribute

Parameters:
dna - The "container" Dna

getDna

Dna getDna()
Get the Dna instance which will contain the current Attribute

Returns:
Dna The "container" Dna

validate

boolean validate()
                 throws AttributeValidationException,
                        AttributeOutOfRangeException,
                        MissingDnaContainerException,
                        MissingCPTableException
This method has to perform a validation process over the Attribute according to what specified by the JVM Official Specification.

Returns:
boolean Exit status
Throws:
AttributeValidationException - Something failed with the validation process; further information are stored within the raised exception
AttributeOutOfRangeException - Something failed with the validation process; further information are stored within the raised exception
MissingDnaContainerException - The validation process cannot be accomplished since any of the examined entities is missing its own Dna container
MissingCPTableException - The validation process cannot be accomplished since there is no reference to the ConstantPoolTable in the current Dna instance

fromStream

void fromStream(java.io.DataInputStream dis,
                Dna dna,
                int nameIndex,
                int length)
                throws DnaDeserializationException,
                       MissingDnaContainerException
This method reads the data with which the attribute has to be initialized.

Parameters:
dis - The input stream
dna - The Dna instance this class belongs to
nameIndex - The value of the name index
length - The length of the attribute
Throws:
DnaDeserializationException - Errors while reading the attribute from the stream
MissingDnaContainerException - There is no reference to the current Dna container

toStream

void toStream(java.io.DataOutputStream dos)
              throws DnaSerializationException
This method writes the attribute to the provided output stream.

Parameters:
dos - The output stream
Throws:
DnaSerializationException - Errors while writing the attribute to the output stream

clone

java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException