jparse
Interface Method

All Superinterfaces:
HasExceptions
All Known Implementing Classes:
CompiledMethod, MethAST

public interface Method
extends HasExceptions

Information on a Java method.

Author:
Jerry James

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
 

Method Detail

getDeclaringClass

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

Returns:
the Type of the declaring class

getName

public String getName()
Return the name of this 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.

Returns:
the modifiers for this method

getReturnType

public Type getReturnType()
Returns a Type object that represents the formal return type of this 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.

Returns:
the parameter types of this method

getExceptionTypes

public Type[] getExceptionTypes()
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 HasExceptions
Returns:
the exceptions declared by this method

isAccessible

public boolean isAccessible(Type caller)
Determines whether the method is accessible to a given caller

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

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

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

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)
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.

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