fr.umlv.corosol.classfile.member.impl
Class DefaultJClassMember

java.lang.Object
  extended by fr.umlv.corosol.classfile.member.impl.DefaultJClassMember
All Implemented Interfaces:
JClassFileItem, JClassMember, JObject

public class DefaultJClassMember
extends java.lang.Object
implements JClassMember

The default implementation of JClassMember interface.

Author:
Christophe Deleray

Constructor Summary
DefaultJClassMember()
          The default constructor.
DefaultJClassMember(JConstantPool cpool, int accessFlags, int nameIndex, int descriptorIndex, JAttribute[] attributes)
          Creates a new DefaultJClassMember object.
 
Method Summary
 void addAttribute(JAttribute attribute)
          Adds the specified attribute.
 int getAccessFlags()
          Returns the mask of flags used to denote access permission to and properties of this class member.
 JAttribute getAttribute(java.lang.String name)
          Returns the attribute whose name is specified.
 JAttribute[] getAttributes()
          Returns an array of attributes of this class member.
 JConstantPool getConstantPool()
          Returns the constant pool of this classfile item.
 java.lang.String getDescriptor()
          Returns the descriptor of this class member.
 int getDescriptorIndex()
          Returns the index of the CONSTANT_Utf8_info constant pool entry, representing the descriptor of this class member.
 java.lang.String getName()
          Returns the name of this class member.
 int getNameIndex()
          Returns the index of the CONSTANT_Utf8_info constant pool entry, representing the name of this class member.
 void readItem(JClassFileInput in)
          Extracts the data of this classfile part from the specified input stream.
 void removeAttribute(java.lang.String name)
          Removes the attribute whose name is specified.
 void setAccessFlags(int accessFlags)
          Sets the mask of flags used to denote access permission to and properties of this class member.
 void setAttributes(JAttribute[] attributes)
          Sets the array of attributes of this class member.
 void setConstantPool(JConstantPool constantPool)
          Sets the constant pool of this classfile item.
 void setDescriptorIndex(int descriptorIndex)
          Sets the index of the CONSTANT_Utf8_info constant pool entry, representing the descriptor of this class member.
 void setNameIndex(int nameIndex)
          Sets the index of the CONSTANT_Utf8_info constant pool entry, representing the name of this class member.
 java.lang.String toString()
          Returns a string representation of this class member.
 void writeItem(JClassFileOutput out)
          Writes the data of this classfile part into a file via the specified output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultJClassMember

public DefaultJClassMember()
The default constructor.


DefaultJClassMember

public DefaultJClassMember(JConstantPool cpool,
                           int accessFlags,
                           int nameIndex,
                           int descriptorIndex,
                           JAttribute[] attributes)
Creates a new DefaultJClassMember object.

Parameters:
cpool - the constant pool
accessFlags - the access flags
nameIndex - an index of a Constant_UTF8_info constant pool entry
descriptorIndex - an index of a Constant_UTF8_info constant pool entry
attributes - an array of attributes
Method Detail

getAccessFlags

public int getAccessFlags()
Returns the mask of flags used to denote access permission to and properties of this class member.

Specified by:
getAccessFlags in interface JClassMember
Returns:
the access flags of the class

setAccessFlags

public void setAccessFlags(int accessFlags)
Sets the mask of flags used to denote access permission to and properties of this class member.

Specified by:
setAccessFlags in interface JClassMember
Parameters:
accessFlags - the access flags of the class

getNameIndex

public int getNameIndex()
Returns the index of the CONSTANT_Utf8_info constant pool entry, representing the name of this class member.

Specified by:
getNameIndex in interface JClassMember
Returns:
the index of a constant pool entry representing the name of this class member

setNameIndex

public void setNameIndex(int nameIndex)
Sets the index of the CONSTANT_Utf8_info constant pool entry, representing the name of this class member.

Specified by:
setNameIndex in interface JClassMember
Parameters:
nameIndex - the index of a constant pool entry representing the name of this class member

getDescriptorIndex

public int getDescriptorIndex()
Returns the index of the CONSTANT_Utf8_info constant pool entry, representing the descriptor of this class member.

Specified by:
getDescriptorIndex in interface JClassMember
Returns:
the index of a constant pool entry representing the descriptor of this class member

setDescriptorIndex

public void setDescriptorIndex(int descriptorIndex)
Sets the index of the CONSTANT_Utf8_info constant pool entry, representing the descriptor of this class member.

Specified by:
setDescriptorIndex in interface JClassMember
Parameters:
descriptorIndex - the index of a constant pool entry representing the descriptor of this class member

getName

public java.lang.String getName()
Returns the name of this class member.

Specified by:
getName in interface JClassMember

getDescriptor

public java.lang.String getDescriptor()
Returns the descriptor of this class member.

Specified by:
getDescriptor in interface JClassMember
Returns:
the descriptor of this class member.

getAttributes

public JAttribute[] getAttributes()
Returns an array of attributes of this class member.

Specified by:
getAttributes in interface JClassMember
Returns:
an array of attributes

setAttributes

public void setAttributes(JAttribute[] attributes)
Sets the array of attributes of this class member.

Specified by:
setAttributes in interface JClassMember
Parameters:
attributes - an array of attributes

toString

public java.lang.String toString()
Returns a string representation of this class member.

Specified by:
toString in interface JClassMember
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this class member

readItem

public void readItem(JClassFileInput in)
              throws java.io.IOException
Extracts the data of this classfile part from the specified input stream.

Specified by:
readItem in interface JClassFileItem
Parameters:
in - an input stream
Throws:
java.io.IOException - if an I/O error occurs when reading the datas corresponding to this class member description

writeItem

public void writeItem(JClassFileOutput out)
               throws java.io.IOException
Writes the data of this classfile part into a file via the specified output stream.

Specified by:
writeItem in interface JClassFileItem
Parameters:
out - a class file output stream
Throws:
java.io.IOException - if an I/O error occurs when writing into the classfile

getAttribute

public JAttribute getAttribute(java.lang.String name)
Returns the attribute whose name is specified.

Specified by:
getAttribute in interface JClassMember
Parameters:
name - the name of an attribute
Returns:
the attribute whose name is specified or null if it doesn't exist.

addAttribute

public void addAttribute(JAttribute attribute)
Adds the specified attribute.

Specified by:
addAttribute in interface JClassMember
Parameters:
attribute - an attribute

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the attribute whose name is specified.

Specified by:
removeAttribute in interface JClassMember
Parameters:
name - the name of an attribute

getConstantPool

public JConstantPool getConstantPool()
Returns the constant pool of this classfile item.

Specified by:
getConstantPool in interface JClassFileItem

setConstantPool

public void setConstantPool(JConstantPool constantPool)
Sets the constant pool of this classfile item.

Specified by:
setConstantPool in interface JClassFileItem
Parameters:
constantPool - the constant Pool