com.vladium.jcd.cls
Class AttributeCollection

java.lang.Object
  extended by com.vladium.jcd.cls.AttributeCollection
All Implemented Interfaces:
IAttributeCollection, IClassFormatOutput, java.lang.Cloneable

final class AttributeCollection
extends java.lang.Object
implements IAttributeCollection

Author:
(C) 2001, Vlad Roubtsov

Field Summary
private static boolean DISALLOW_MULTIPLE_SYNTHETIC_ATTRIBUTES
           
private  java.util.List m_attributes
           
private  int m_bridgeRefCount
           
private  int m_innerClassesAttributeOffset
           
private  int m_syntheticRefCount
           
 
Constructor Summary
AttributeCollection(int capacity)
           
 
Method Summary
 void accept(IClassDefVisitor visitor, java.lang.Object ctx)
           
 int add(Attribute_info attribute)
          Adds a new Attribute_info descriptor to this collection.
 java.lang.Object clone()
          Performs a deep copy.
 Attribute_info get(int offset)
          Returns the attribute descriptor at a given offset.
 InnerClassesAttribute_info getInnerClassesAttribute()
           
 boolean hasBridge()
           
 boolean hasSynthetic()
           
 long length()
          Returns the total length of this collection when converted to .class format [including 2 count bytes]
 Attribute_info remove(int offset)
          Removes the Attribute_info descriptor at a given offset.
 Attribute_info set(int offset, Attribute_info attribute)
          Replaces the Attribute_info descriptor at a given offset.
 int size()
          Returns the number of attributes in this collection [can be 0].
 void writeInClassFormat(UDataOutputStream out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_attributes

private java.util.List m_attributes

m_syntheticRefCount

private transient int m_syntheticRefCount

m_bridgeRefCount

private transient int m_bridgeRefCount

m_innerClassesAttributeOffset

private transient int m_innerClassesAttributeOffset

DISALLOW_MULTIPLE_SYNTHETIC_ATTRIBUTES

private static final boolean DISALLOW_MULTIPLE_SYNTHETIC_ATTRIBUTES
See Also:
Constant Field Values
Constructor Detail

AttributeCollection

AttributeCollection(int capacity)
Method Detail

get

public final Attribute_info get(int offset)
Description copied from interface: IAttributeCollection
Returns the attribute descriptor at a given offset.

Specified by:
get in interface IAttributeCollection
Parameters:
offset - attribute offset [must be in [0, size()) range; input not checked]
Returns:
Attribute_info descriptor [never null]

hasSynthetic

public final boolean hasSynthetic()
Specified by:
hasSynthetic in interface IAttributeCollection

hasBridge

public final boolean hasBridge()
Specified by:
hasBridge in interface IAttributeCollection

getInnerClassesAttribute

public final InnerClassesAttribute_info getInnerClassesAttribute()
Specified by:
getInnerClassesAttribute in interface IAttributeCollection

size

public final int size()
Description copied from interface: IAttributeCollection
Returns the number of attributes in this collection [can be 0].

Specified by:
size in interface IAttributeCollection

length

public final long length()
Description copied from interface: IAttributeCollection
Returns the total length of this collection when converted to .class format [including 2 count bytes]

Specified by:
length in interface IAttributeCollection

clone

public java.lang.Object clone()
Performs a deep copy.

Specified by:
clone in interface IAttributeCollection
Overrides:
clone in class java.lang.Object

writeInClassFormat

public void writeInClassFormat(UDataOutputStream out)
                        throws java.io.IOException
Specified by:
writeInClassFormat in interface IClassFormatOutput
Throws:
java.io.IOException

accept

public void accept(IClassDefVisitor visitor,
                   java.lang.Object ctx)
Specified by:
accept in interface IAttributeCollection

add

public int add(Attribute_info attribute)
Description copied from interface: IAttributeCollection
Adds a new Attribute_info descriptor to this collection. No duplicate checks are made. It is the responsibility of the caller to ensure that all data referenced in 'attribute' will eventually appear in the constant pool.

Specified by:
add in interface IAttributeCollection
Parameters:
attribute - new attribute descriptor [may not be null]

set

public Attribute_info set(int offset,
                          Attribute_info attribute)
Description copied from interface: IAttributeCollection
Replaces the Attribute_info descriptor at a given offset. No duplicate checks are made. It is the responsibility of the caller to ensure that all data referenced in 'attribute' will eventually appear in the constant pool.

Specified by:
set in interface IAttributeCollection
Parameters:
offset - attribute offset [must be in [0, size()) range; input not checked]
attribute - new attribute descriptor [may not be null]
Returns:
previous attribute descriptor at this offset [never null]

remove

public Attribute_info remove(int offset)
Description copied from interface: IAttributeCollection
Removes the Attribute_info descriptor at a given offset.

Specified by:
remove in interface IAttributeCollection
Parameters:
offset - attribute offset [must be in [0, size()) range; input not checked]
Returns:
current attribute descriptor at this offset [never null]