com.vladium.jcd.cls
Interface IMethodCollection

All Superinterfaces:
java.lang.Cloneable, IClassFormatOutput
All Known Implementing Classes:
MethodCollection

public interface IMethodCollection
extends java.lang.Cloneable, IClassFormatOutput

An abstraction of the 'methods' component of .class format. The contents are Method_info structures corresponding to all methods directly declared by this class/interface. The order in which they appear is unspecified.

Author:
(C) 2001, Vlad Roubtsov

Method Summary
 void accept(IClassDefVisitor visitor, java.lang.Object ctx)
           
 int add(Method_info method)
          Adds a new Method_info descriptor to this collection.
 java.lang.Object clone()
           
 int[] get(ClassDef cls, java.lang.String name)
          Returns an array of offsets for methods named 'name' (empty array if no matching fields found).
 Method_info get(int offset)
          Returns Method_info descriptor at a given offset.
 Method_info remove(int offset)
          Removes the Method_info descriptor at a given offset.
 Method_info set(int offset, Method_info method)
          Replaces the Method_info descriptor at a given offset.
 int size()
          Returns the number of methods in this collection [can be 0].
 
Methods inherited from interface com.vladium.jcd.compiler.IClassFormatOutput
writeInClassFormat
 

Method Detail

get

Method_info get(int offset)
Returns Method_info descriptor at a given offset.

Parameters:
offset - method offset [must be in [0, size()) range; input not checked]
Returns:
Method_info descriptor [never null]
Throws:
java.lang.IndexOutOfBoundsException - if 'offset' is outside of valid range

get

int[] get(ClassDef cls,
          java.lang.String name)
Returns an array of offsets for methods named 'name' (empty array if no matching fields found).

Parameters:
cls - class definition providing the constant pool against which to resolve names [may not be null]
name - method name [null or empty will result in no matches]
Returns:
array of method offsets in no particular order [never null; could be empty]
Throws:
java.lang.IllegalArgumentException - if 'cls' is null

size

int size()
Returns the number of methods in this collection [can be 0].


clone

java.lang.Object clone()

accept

void accept(IClassDefVisitor visitor,
            java.lang.Object ctx)

add

int add(Method_info method)
Adds a new Method_info descriptor to this collection. No duplicate checks are made. It is the responsibility of the caller to ensure that all data referenced in 'method' will eventually appear in the constant pool.

Parameters:
method - new method descriptor [may not be null]

set

Method_info set(int offset,
                Method_info method)
Replaces the Method_info descriptor at a given offset. No duplicate checks are made. No method type compatibility checks are made. It is the responsibility of the caller to ensure that all data referenced in 'method' will eventually appear in the constant pool.

Parameters:
offset - method offset [must be in [0, size()) range; input not checked]
method - new method descriptor [may not be null]
Returns:
previous method descriptor at this offset [never null]
Throws:
java.lang.IndexOutOfBoundsException - if 'offset' is outside of valid range

remove

Method_info remove(int offset)
Removes the Method_info descriptor at a given offset. It is the responsibility of the caller to ensure that the class definition remains consistent after this change.

Parameters:
offset - method offset [must be in [0, size()) range; input not checked]
Returns:
method descriptor at this offset [never null]
Throws:
java.lang.IndexOutOfBoundsException - if 'offset' is outside of valid range