jparse
Class CompiledMethod

java.lang.Object
  extended byjparse.CompiledMethod
All Implemented Interfaces:
HasExceptions, Method

public final class CompiledMethod
extends Object
implements Method

Information on a Java method defined in a Java class file

Author:
Jerry James

Field Summary
private  Method theMethod
          The method object wrapped by this CompiledMethod object
 
Constructor Summary
(package private) CompiledMethod(Method meth)
          Create a new CompiledMethod object
 
Method Summary
 Method bestMatch(Method meth)
          Find the best match, given two matching methods
 boolean exactMatch(Method meth)
          Determine whether two methods are exact matches: i.e., whether the names are the same, they take the same number of parameters, and all the parameter types are exactly equal.
 Type getDeclaringClass()
          Returns the Type object representing the class or interface that declares the method represented by this object.
 Type[] getExceptionTypes()
          Returns an array of Type objects that represent the types of the exceptions declared to be thrown by this method.
 int getModifiers()
          Returns the Java language modifiers for the method represented by this object, as an integer.
 String getName()
          Return the name of this method
 Type[] getParameterTypes()
          Returns an array of Type objects that represent the formal parameter types, in declaration order, of this method.
 Type getReturnType()
          Returns a Type object that represents the formal return type of this method.
 boolean isAccessible(Type caller)
          Determines whether the method is accessible to a given caller
 boolean match(String name, Type[] params, Type caller)
          Determines whether this method matches the parameters given by a caller
 boolean match(Type[] params, Type caller)
          Determines whether this method matches the parameters given by a caller
 String toString()
          Return a string describing this CompiledMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theMethod

private final Method theMethod
The method object wrapped by this CompiledMethod object

Constructor Detail

CompiledMethod

CompiledMethod(Method meth)
Create a new CompiledMethod object

Parameters:
meth - the Method object to wrap
Method Detail

getDeclaringClass

public Type getDeclaringClass()
Returns the Type object representing the class or interface that declares the method represented by this object.

Specified by:
getDeclaringClass in interface Method
Returns:
the Type of the declaring class

getName

public String getName()
Return the name of this method

Specified by:
getName in interface Method
Returns:
the name of this method

getModifiers

public int getModifiers()
Returns the Java language modifiers for the method represented by this object, as an integer. The Modifier class should be used to decode the modifiers.

Specified by:
getModifiers in interface Method
Returns:
the modifiers for this method

getReturnType

public Type getReturnType()
Returns a Type object that represents the formal return type of this method.

Specified by:
getReturnType in interface Method
Returns:
the return type of this method

getParameterTypes

public Type[] getParameterTypes()
Returns an array of Type objects that represent the formal parameter types, in declaration order, of this method. Returns an array of length 0 if the underlying method takes no parameters.

Specified by:
getParameterTypes in interface Method
Returns:
the parameter types of this method

getExceptionTypes

public Type[] getExceptionTypes()
Description copied from interface: Method
Returns an array of Type objects that represent the types of the exceptions declared to be thrown by this method. Returns an array of length 0 if the method declares no exceptions in its throws clause.

Specified by:
getExceptionTypes in interface Method
Returns:
the exceptions declared by this method

isAccessible

public boolean isAccessible(Type caller)
Description copied from interface: Method
Determines whether the method is accessible to a given caller

Specified by:
isAccessible in interface Method
Parameters:
caller - the type of the caller
Returns:
true if the caller is able to access this method, false otherwise

match

public boolean match(String name,
                     Type[] params,
                     Type caller)
Determines whether this method matches the parameters given by a caller

Specified by:
match in interface Method
Parameters:
name - the name of the method to match
params - the types of the parameters to the method
caller - the type of the caller
Returns:
true if this method matches, false otherwise

match

public boolean match(Type[] params,
                     Type caller)
Determines whether this method matches the parameters given by a caller

Specified by:
match in interface Method
Parameters:
params - the types of the parameters to the method
caller - the type of the caller
Returns:
true if this method matches, false otherwise

bestMatch

public Method bestMatch(Method meth)
Find the best match, given two matching methods

Specified by:
bestMatch in interface Method
Parameters:
meth - the other method to compare
Returns:
either this or meth, depending on which matches best, or null if neither matches best

exactMatch

public boolean exactMatch(Method meth)
Description copied from interface: Method
Determine whether two methods are exact matches: i.e., whether the names are the same, they take the same number of parameters, and all the parameter types are exactly equal.

Specified by:
exactMatch in interface Method
Parameters:
meth - the method to compare against
Returns:
true if the methods match exactly; false if they differ in any particular

toString

public String toString()
Return a string describing this CompiledMethod

Returns:
a string describing this CompiledMethod