Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.bcel.classfile
Class Attribute

    java.lang.Object
      org.apache.bcel.classfile.Attribute

All Implemented Interfaces:
  Serializable, Cloneable, Node

Direct Known Subclasses:
  Code, ConstantValue, Deprecated, ExceptionTable, InnerClasses, LineNumberTable, LocalVariableTable, PMGClass, Signature, SourceFile, StackMap, Synthetic, Unknown

    public abstract class Attribute

extends Object
implements Cloneable, Node, Serializable

Abstract super class for Attribute objects. Currently the ConstantValue, SourceFile, Code, Exceptiontable, LineNumberTable, LocalVariableTable, InnerClasses and Synthetic attributes are supported. The Unknown attribute stands for non-standard-attributes.

Version:
  $Id: Attribute.java 386056 2006-03-15 11:31:56Z tcurdt $
See Also:
  `ConstantValue`, `SourceFile`, `Code`, `Unknown`, `ExceptionTable`, `LineNumberTable`, `LocalVariableTable`, `InnerClasses`, `Synthetic`, `Deprecated`, `Signature`, Serialized Form

Field Summary
`protected ConstantPool` | `constant_pool`
`protected int` | `length`
`protected int` | `name_index`
`protected byte` | `tag`

Constructor Summary
`protected` | `Attribute(byte tag, int name_index, int length, ConstantPool constant_pool)`

Method Summary
`abstract void` | `accept(Visitor v)` Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
`static void` | `addAttributeReader(String name, AttributeReader r)` Add an Attribute reader capable of parsing (user-defined) attributes named "name".
`Object` | `clone()` Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.
`abstract Attribute` | `copy(ConstantPool _constant_pool)`
`void` | `dump(DataOutputStream file)` Dump attribute to file stream in binary format.
`ConstantPool` | `getConstantPool()`
`int` | `getLength()`
`int` | `getNameIndex()`
`byte` | `getTag()`
`static Attribute` | `readAttribute(DataInputStream file, ConstantPool constant_pool)`
`static void` | `removeAttributeReader(String name)` Remove attribute reader
`void` | `setConstantPool(ConstantPool constant_pool)`
`void` | `setLength(int length)`
`void` | `setNameIndex(int name_index)`
`String` | `toString()`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### name_index

    protected int name_index

### length

    protected int length

### tag

    protected byte tag

### constant_pool

    protected ConstantPool constant_pool

Constructor Detail

### Attribute

    protected Attribute(byte tag,
                        int name_index,
                        int length,
                        ConstantPool constant_pool)

Method Detail

### accept

    public abstract void accept(Visitor v)

  Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

  Specified by:
    `accept` in interface `Node`
  Parameters:
    `v` - Visitor object

### dump

    public void dump(DataOutputStream file)
              throws IOException

  Dump attribute to file stream in binary format.

  Parameters:
    `file` - Output file stream
  Throws:
    `IOException`

### addAttributeReader

    public static void addAttributeReader(String name,
                                          AttributeReader r)

  Add an Attribute reader capable of parsing (user-defined) attributes named "name". You should not add readers for the standard attributes such as "LineNumberTable", because those are handled internally.

  Parameters:
    `name` - the name of the attribute as stored in the class file
    `r` - the reader object

### removeAttributeReader

    public static void removeAttributeReader(String name)

  Remove attribute reader

  Parameters:
    `name` - the name of the attribute as stored in the class file

### readAttribute

    public static final Attribute readAttribute(DataInputStream file,
                                                ConstantPool constant_pool)
                                         throws IOException,
                                                ClassFormatException

  Throws:
    `IOException`
    `ClassFormatException`

### getLength

    public final int getLength()

  Returns:
    Length of attribute field in bytes.

### setLength

    public final void setLength(int length)

  Parameters:
    `length` - length in bytes.

### setNameIndex

    public final void setNameIndex(int name_index)

  Parameters:
    `name_index` - of attribute.

### getNameIndex

    public final int getNameIndex()

  Returns:
    Name index in constant pool of attribute name.

### getTag

    public final byte getTag()

  Returns:
    Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method.

### getConstantPool

    public final ConstantPool getConstantPool()

  Returns:
    Constant pool used by this object.
  See Also:
    `ConstantPool`

### setConstantPool

    public final void setConstantPool(ConstantPool constant_pool)

  Parameters:
    `constant_pool` - Constant pool to be used for this object.
  See Also:
    `ConstantPool`

### clone

    public Object clone()

  Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.

  Overrides:
    `clone` in class `Object`
  Returns:
    shallow copy of this attribute

### copy

    public abstract Attribute copy(ConstantPool _constant_pool)

  Returns:
    deep copy of this attribute

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  Returns:
    attribute name.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.