joie
Class Member

java.lang.Object
  |
  +--joie.Member
All Implemented Interfaces:
FilterObject
Direct Known Subclasses:
Field, Method

public abstract class Member
extends java.lang.Object
implements FilterObject

Defines a Member of a class as it is represented in the classfile. field_info/method_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; }

Version:
0.9
Author:
Geoff Cohen, Olaf Görlitz

Field Summary
protected  Modifiers access_flags
           
protected  int acount
           
protected  ShortCount attr_count
           
protected  Attribute[] attribs
           
protected  ClassInfo cinfo
           
protected  ConstantPool cpool
           
protected  java.lang.String desc
           
protected  int desc_index
           
protected  java.lang.String name
           
protected  int name_index
           
 
Fields inherited from interface joie.io.FilterObject
APPENDED, CLEAN, DIRTY, DIRTY_IN_PLACE, DIRTY_SAME_SIZE
 
Constructor Summary
protected Member()
          Protected to prevent from unwanted instantiation.
protected Member(java.lang.String name, java.lang.String descriptor)
          Creates a new member with the given name and descriptor.
 
Method Summary
 void addAttribute(Attribute attr)
           
 void assignClassInfo(ClassInfo classinfo)
          Assigns a new ClassInfo reference to the class member.
 Attribute[] getAttributes()
           
 java.lang.String getClassName()
           
protected  int getDescIndex()
          Returns the desc_index.
 java.lang.String getDescriptor()
          Returns the descriptor of the Member.
 Modifiers getModifiers()
           
 java.lang.String getName()
          Returns the name of the Member.
protected  int getNameIndex()
          Returns the name_index.
 int getStatus()
           
protected  void init()
          Initialized a new object.
 void readFromByteStream(ByteStream in)
          Reads the Member information from the input stream.
protected  void rebind()
          Assigns new indexes into the Constant Pool depending on the currently set name and description.
 void resolve()
          Resolves the indexes.
 void serialize(ByteStream bs)
           
 void serializeAppend(ByteStream bs)
           
 void serializeInPlace(ByteStream bs)
           
protected  void setClassInfo(ClassInfo cinfo)
          Sets the new ClassInfo reference.
 java.lang.String toString()
           
static void write(ByteStream out, java.lang.Object[] members)
          Writes all member objects (fields or methods) in the given array to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

access_flags

protected Modifiers access_flags

name_index

protected int name_index

desc_index

protected int desc_index

attr_count

protected ShortCount attr_count

acount

protected int acount

attribs

protected Attribute[] attribs

cinfo

protected ClassInfo cinfo

cpool

protected ConstantPool cpool

name

protected java.lang.String name

desc

protected java.lang.String desc
Constructor Detail

Member

protected Member()
Protected to prevent from unwanted instantiation.


Member

protected Member(java.lang.String name,
                 java.lang.String descriptor)
Creates a new member with the given name and descriptor.

Parameters:
name - the member's name
descriptor - the member's descriptor
Method Detail

readFromByteStream

public void readFromByteStream(ByteStream in)
                        throws java.io.IOException
Reads the Member information from the input stream.

Parameters:
in - the input stream
Throws:
java.io.IOException - if an I/O Error occurs

write

public static void write(ByteStream out,
                         java.lang.Object[] members)
                  throws java.io.IOException
Writes all member objects (fields or methods) in the given array to the output stream.

Parameters:
out - the output stream
members - the array of Member objects
Throws:
java.io.IOException - if an I/O error occurs

addAttribute

public void addAttribute(Attribute attr)

assignClassInfo

public void assignClassInfo(ClassInfo classinfo)
Assigns a new ClassInfo reference to the class member. If the class member is uninitialized the new ClassInfo is set and the class member will be initialized. If the object is already initialized it will be rebound to the new ClassInfo reference. Therefore the indexes are resolved, the new ClassInfo reference is set and the indexes are bound to the new reference.

Parameters:
classinfo - the ClassInfo reference

setClassInfo

protected void setClassInfo(ClassInfo cinfo)
Sets the new ClassInfo reference.

Parameters:
cinfo - the ClassInfo

init

protected void init()
Initialized a new object.


rebind

protected void rebind()
Assigns new indexes into the Constant Pool depending on the currently set name and description.


resolve

public void resolve()
Resolves the indexes.

Throws:
JOIEException - if the name can not be resolved

getNameIndex

protected int getNameIndex()
Returns the name_index.

Returns:
the name_index

getName

public java.lang.String getName()
Returns the name of the Member.

Returns:
the name
Throws:
JOIEException - if the index is wrong

getDescIndex

protected int getDescIndex()
Returns the desc_index.

Returns:
the desc_index

getDescriptor

public java.lang.String getDescriptor()
Returns the descriptor of the Member.

Returns:
the descriptor
Throws:
JOIEException - if the index is wrong

getClassName

public java.lang.String getClassName()

getModifiers

public Modifiers getModifiers()

getAttributes

public Attribute[] getAttributes()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

serialize

public void serialize(ByteStream bs)
Specified by:
serialize in interface FilterObject

serializeAppend

public void serializeAppend(ByteStream bs)
Specified by:
serializeAppend in interface FilterObject

serializeInPlace

public void serializeInPlace(ByteStream bs)
Specified by:
serializeInPlace in interface FilterObject

getStatus

public int getStatus()
Specified by:
getStatus in interface FilterObject