final class ConstantCollection extends java.lang.Object implements IConstantCollection
Modifier and Type | Class and Description |
---|---|
private static class |
ConstantCollection.ConstantIterator |
IConstantCollection.IConstantComparator, IConstantCollection.IConstantIterator
Modifier and Type | Field and Description |
---|---|
private ObjectIntMap |
m_CONSTANT_Utf8_index |
private java.util.List |
m_constants |
private int |
m_size |
Constructor and Description |
---|
ConstantCollection(int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
accept(IClassDefVisitor visitor,
java.lang.Object ctx) |
int |
add(CONSTANT_info constant)
Appends 'constant' to the end of the collection.
|
java.lang.Object |
clone()
Performs a deep copy.
|
int |
find(int type,
IConstantCollection.IConstantComparator comparator)
Searches the pool for a matching constant of given type with equality
semantics expressed by 'comparator'.
|
int |
findCONSTANT_Utf8(java.lang.String value)
Convenience method that can lookup CONSTANT_Utf8 entries in O(1) time
on average.
|
CONSTANT_info |
get(int index)
Returns a CONSTANT_info at a given pool index.
|
private ObjectIntMap |
getCONSTANT_Utf8_index() |
IConstantCollection.IConstantIterator |
iterator()
Returns a fail-fast iterator over all valid entries in the pool.
|
CONSTANT_info |
set(int index,
CONSTANT_info constant)
Replaces an existing constant pool entry.
|
int |
size()
Returns the number of CONSTANT_info entries in this collection.
|
void |
writeInClassFormat(UDataOutputStream out) |
private java.util.List m_constants
private int m_size
private transient ObjectIntMap m_CONSTANT_Utf8_index
public CONSTANT_info get(int index)
IConstantCollection
IConstantCollection.iterator()
to iterate only over valid entries
in a transparent fashion.get
in interface IConstantCollection
index
- constant pool index [must be in [1, size()] range]public IConstantCollection.IConstantIterator iterator()
IConstantCollection
iterator
in interface IConstantCollection
public int find(int type, IConstantCollection.IConstantComparator comparator)
IConstantCollection
find
in interface IConstantCollection
type
- type of constants to filter by [not validated]comparator
- [may not be null]public int findCONSTANT_Utf8(java.lang.String value)
IConstantCollection
findCONSTANT_Utf8
in interface IConstantCollection
value
- string value on which to match [may not be null]public int size()
IConstantCollection
size
in interface IConstantCollection
public java.lang.Object clone()
clone
in interface IConstantCollection
clone
in class java.lang.Object
public void writeInClassFormat(UDataOutputStream out) throws java.io.IOException
writeInClassFormat
in interface IClassFormatOutput
java.io.IOException
public void accept(IClassDefVisitor visitor, java.lang.Object ctx)
accept
in interface IConstantCollection
public CONSTANT_info set(int index, CONSTANT_info constant)
IConstantCollection
set
in interface IConstantCollection
index
- constant pool index [must be in [1, size()] range]constant
- new entry to set [may not be null; input unchecked]public int add(CONSTANT_info constant)
IConstantCollection
add
in interface IConstantCollection
constant
- new constant [may not be null; input unchecked]private ObjectIntMap getCONSTANT_Utf8_index()