com.vladium.jcd.cls
Class InterfaceCollection

java.lang.Object
  extended bycom.vladium.jcd.cls.InterfaceCollection
All Implemented Interfaces:
java.lang.Cloneable, IClassFormatOutput, IInterfaceCollection

final class InterfaceCollection
extends java.lang.Object
implements IInterfaceCollection

Author:
(C) 2001, Vlad Roubtsov

Field Summary
private  IntVector m_interfaces
           
 
Constructor Summary
(package private) InterfaceCollection(int capacity)
           
 
Method Summary
 void accept(IClassDefVisitor visitor, java.lang.Object ctx)
           
 int add(int interface_index)
          Appends a new superinterface pointer to the collection.
 java.lang.Object clone()
          Performs a deep copy.
 int get(int offset)
          Returns the CONSTANT_Class_info constant pool index for offset'th direct superinterface.
 int set(int offset, int interface_index)
          Replaces superinterface pointer number 'offset' with new value 'interface_index'.
 int size()
          Returns the number of direct superinterfaces for this class/interface.
 void writeInClassFormat(UDataOutputStream out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_interfaces

private IntVector m_interfaces
Constructor Detail

InterfaceCollection

InterfaceCollection(int capacity)
Method Detail

get

public int get(int offset)
Description copied from interface: IInterfaceCollection
Returns the CONSTANT_Class_info constant pool index for offset'th direct superinterface.

Specified by:
get in interface IInterfaceCollection
Parameters:
offset - superinterface number [must be in [0, size()) range]
Returns:
constant pool index [always positive]

size

public int size()
Description copied from interface: IInterfaceCollection
Returns the number of direct superinterfaces for this class/interface.

Specified by:
size in interface IInterfaceCollection
Returns:
int number of direct superinterfaces [can be 0]

clone

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

Specified by:
clone in interface IInterfaceCollection

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 IInterfaceCollection

add

public int add(int interface_index)
Description copied from interface: IInterfaceCollection
Appends a new superinterface pointer to the collection. No duplicate checks are made.

Specified by:
add in interface IInterfaceCollection
Parameters:
interface_index - constant pool index [must be positive; input not validated]
Returns:
offset of the new pointer [same as IInterfaceCollection.size()-1 when called after this method]

set

public int set(int offset,
               int interface_index)
Description copied from interface: IInterfaceCollection
Replaces superinterface pointer number 'offset' with new value 'interface_index'. No duplicate checks are made. It is the responsibility of the caller to ensure that the relevant CONSTANT_Class_info descriptor will be found in the constant pool, in the slot pointed to by 'interface_index'.

Specified by:
set in interface IInterfaceCollection
Parameters:
offset - offset of the superinterface pointer to replace [must be in [0, size()) range]
interface_index - constant pool index [must be positive; input not validated]
Returns:
previous value at the given index [always positive]