com.vladium.jcd.cls
Class MethodCollection

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

final class MethodCollection
extends java.lang.Object
implements IMethodCollection

Author:
(C) 2001, Vlad Roubtsov

Field Summary
private  java.util.List m_methods
           
 
Constructor Summary
MethodCollection(int capacity)
           
 
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()
          Performs a deep copy.
 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].
 void writeInClassFormat(UDataOutputStream out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_methods

private java.util.List m_methods
Constructor Detail

MethodCollection

MethodCollection(int capacity)
Method Detail

get

public Method_info get(int offset)
Description copied from interface: IMethodCollection
Returns Method_info descriptor at a given offset.

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

get

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

Specified by:
get in interface IMethodCollection
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]

size

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

Specified by:
size in interface IMethodCollection

clone

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

Specified by:
clone in interface IMethodCollection
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 IMethodCollection

add

public int add(Method_info method)
Description copied from interface: IMethodCollection
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.

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

set

public Method_info set(int offset,
                       Method_info method)
Description copied from interface: IMethodCollection
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.

Specified by:
set in interface IMethodCollection
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]

remove

public Method_info remove(int offset)
Description copied from interface: IMethodCollection
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.

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