Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.bytecode
Class FieldInfo

java.lang.Object
  extended bynet.sf.jode.bytecode.BinaryInfo
      extended bynet.sf.jode.bytecode.FieldInfo
All Implemented Interfaces:
java.lang.Comparable

public final class FieldInfo
extends BinaryInfo
implements java.lang.Comparable

Represents a java bytecode field (class variable). A field consists of the following parts:

name
The field's name
type
The field's type signature in bytecode format.
signature
The field's type signature in bytecode format including template information.
modifiers
The modifiers of the field like private, public etc. These are created by or-ing the constants Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.STATIC, Modifier.FINAL, Modifier.VOLATILE, Modifier.TRANSIENT, Modifier.STRICT of class Modifier.
synthetic
true if this field is synthetic.
deprecated
true if this field is deprecated.
constant
Final static fields may have a constant value. This is either of type String, Integer, Long, Float or Double.

Author:
Jochen Hoenicke
See Also:
TypeSignature, BasicBlocks

Field Summary
 
Fields inherited from class net.sf.jode.bytecode.BinaryInfo
ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE
 
Constructor Summary
FieldInfo()
          Creates a new empty field info.
FieldInfo(java.lang.String name, java.lang.String typeSig, int modifier)
          Creates a new field with given name, type and modifiers.
 
Method Summary
 int compareTo(java.lang.Object other)
          Compares two FieldInfo objects for field order.
protected  void drop(int keep)
          Drops information from this info.
protected  int getAttributeCount()
          Returns the number of attributes of this class.
 java.lang.Object getConstant()
          Gets the constant value of the field.
 int getModifiers()
          Gets the modifier of the field.
 java.lang.String getName()
          Gets the name of the field.
 java.lang.String getSignature()
          Gets the type signature including template information of the field.
 java.lang.String getType()
          Gets the type signature of the field.
 boolean isDeprecated()
          Tells whether this field is deprecated.
 boolean isSynthetic()
          Tells whether this field is synthetic.
protected  void readAttribute(java.lang.String name, int length, ConstantPool cp, java.io.DataInputStream input, int howMuch)
          Reads in an attributes of this class.
 void setConstant(java.lang.Object newConstant)
           
 void setDeprecated(boolean flag)
           
 void setModifiers(int newModifier)
          Sets the modifier of the field.
 void setName(java.lang.String newName)
          Sets the name of the field.
 void setSynthetic(boolean flag)
           
 void setType(java.lang.String newType)
          Sets the type signature of the field.
 java.lang.String toString()
           
protected  void writeAttributes(GrowableConstantPool gcp, java.io.DataOutputStream output)
          Writes the attributes to the output stream.
 
Methods inherited from class net.sf.jode.bytecode.BinaryInfo
addAttribute, findAttribute, getAttributes, getAttributeSize, prepareAttributes, removeAllAttributes, removeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldInfo

public FieldInfo()
Creates a new empty field info.


FieldInfo

public FieldInfo(java.lang.String name,
                 java.lang.String typeSig,
                 int modifier)
Creates a new field with given name, type and modifiers.

Parameters:
name - the name of the field.
typeSig - the typeSig the type signature.
modifier - the modifier
See Also:
TypeSignature, Modifier
Method Detail

readAttribute

protected void readAttribute(java.lang.String name,
                             int length,
                             ConstantPool cp,
                             java.io.DataInputStream input,
                             int howMuch)
                      throws java.io.IOException
Description copied from class: BinaryInfo
Reads in an attributes of this class. Overwrite this method if you want to handle your own attributes. If you don't know how to handle an attribute call this method for the super class.

Overrides:
readAttribute in class BinaryInfo
Parameters:
name - the attribute name.
length - the length of the attribute.
cp - the constant pool of the class.
input - a data input stream where you can read the attribute from. It will protect you to read more over the attribute boundary.
howMuch - the constant that was given to the ClassInfo.load(int) function when loading this class.
Throws:
java.io.IOException

getAttributeCount

protected int getAttributeCount()
Description copied from class: BinaryInfo
Returns the number of attributes of this class. Overwrite this method if you want to add your own attributes by providing a writeAttributes method. You should call this method for the super class and add the number of your own attributes to the returned value.

Overrides:
getAttributeCount in class BinaryInfo
Returns:
the number of attributes of this class.

writeAttributes

protected void writeAttributes(GrowableConstantPool gcp,
                               java.io.DataOutputStream output)
                        throws java.io.IOException
Description copied from class: BinaryInfo

Writes the attributes to the output stream. Overwrite this method if you want to add your own attributes. All constants you need from the growable constant pool must have been previously registered by the BinaryInfo.prepareAttributes(net.sf.jode.bytecode.GrowableConstantPool) method. This method must not add new constants to the pool

First call the method of the super class. Afterwrites write each of your own attributes including the attribute header (name and length entry).

Overrides:
writeAttributes in class BinaryInfo
Parameters:
gcp - The growable constant pool, which is not growable anymore (see above).
output - the data output stream. You must write exactly as many bytes to it as you have told with the BinaryInfo.getAttributeSize() method.
Throws:
java.io.IOException

drop

protected void drop(int keep)
Description copied from class: BinaryInfo
Drops information from this info. Override this to drop your own info and don't forget to call the method of the super class.

Overrides:
drop in class BinaryInfo
Parameters:
keep - the constant representing how much information we should keep (see ClassInfo.load(int)).

getName

public java.lang.String getName()
Gets the name of the field.

Returns:
the name.

getType

public java.lang.String getType()
Gets the type signature of the field.

Returns:
the type signature.
See Also:
TypeSignature

getSignature

public java.lang.String getSignature()
Gets the type signature including template information of the field. WARNING: This field may disappear and merged into getType later.

Returns:
the type signature.
See Also:
TypeSignature

getModifiers

public int getModifiers()
Gets the modifier of the field.

Returns:
the modifiers.
See Also:
Modifier

isSynthetic

public boolean isSynthetic()
Tells whether this field is synthetic.

Returns:
true if the field is synthetic.

isDeprecated

public boolean isDeprecated()
Tells whether this field is deprecated.

Returns:
true if the field is deprecated.

getConstant

public java.lang.Object getConstant()
Gets the constant value of the field. For static final fields that have a simple String, int, float, double or long constant, this returns the corresponding constant as String, Integer, Float Double or long. For other fields it returns null.

Returns:
The constant, or null.

setName

public void setName(java.lang.String newName)
Sets the name of the field.

Parameters:
newName - the name.

setType

public void setType(java.lang.String newType)
Sets the type signature of the field.

Parameters:
newType - the type signature.
See Also:
TypeSignature

setModifiers

public void setModifiers(int newModifier)
Sets the modifier of the field.

Parameters:
newModifier - the modifiers.
See Also:
Modifier

setSynthetic

public void setSynthetic(boolean flag)

setDeprecated

public void setDeprecated(boolean flag)

setConstant

public void setConstant(java.lang.Object newConstant)

compareTo

public int compareTo(java.lang.Object other)
Compares two FieldInfo objects for field order. The field order is as follows: First the static class intializer followed by constructor with type signature sorted lexicographic. Then all other fields sorted lexicographically by name. If two fields have the same name, they are sorted by type signature, though that can only happen for obfuscated code.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
a positive number if this field follows the other in field order, a negative number if it preceeds the other, and 0 if they are equal.
Throws:
java.lang.ClassCastException - if other is not a ClassInfo.

toString

public java.lang.String toString()

Jode 1.90-CVS
Build Aug 6, 2004

Copyright © 1998-2004 by Jochen Hoenicke.