openjava.mop
Class OJMethod

java.lang.Object
  |
  +--openjava.mop.OJMethod

public final class OJMethod
extends java.lang.Object
implements OJMember


Fields inherited from interface openjava.mop.OJMember
DECLARED, PUBLIC
 
Constructor Summary
OJMethod(Environment env, OJClass declarer, MethodDeclaration d)
           
OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, java.lang.String name, OJClass[] parameterTypes, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, java.lang.String name, OJClass[] parameterTypes, java.lang.String[] parameterNames, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, java.lang.String name, ParameterList params, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
 
Method Summary
 void addExceptionType(OJClass type)
           
static OJMethod[] arrayForMethods(java.lang.reflect.Method[] jmethods)
           
 boolean equals(java.lang.Object obj)
          Compares this method against the given object.
static OJMethod forMethod(java.lang.reflect.Method java_method)
           
 StatementList getBody()
           
 java.lang.reflect.Method getByteCode()
           
 OJClass getDeclaringClass()
           
 Environment getEnvironment()
           
 OJClass[] getExceptionTypes()
           
 java.lang.String getIdentifiableName()
           
 OJModifier getModifiers()
           
 java.lang.String getName()
           
 java.lang.String[] getParameters()
           
 OJClass[] getParameterTypes()
           
 ExpressionList getParameterVariables()
           
 OJClass getReturnType()
           
 MethodDeclaration getSourceCode()
           
 ParseTree getSuffix(java.lang.String keyword)
          Obtains an parse tree of suffix in extended syntax starting with the specified keyword.
 int hashCode()
          Computes a hashcode for this method.
 java.lang.Object invoke(java.lang.Object obj, java.lang.Object[] args)
          Invokes this method on the given object with the given parameters.
 boolean isAlterable()
           
 boolean isExecutable()
           
static OJMethod makePrototype(OJMethod original)
          Generates a method object which has the same attributes as the model method except its body.
 StatementList setBody(StatementList stmts)
           
 void setExceptionTypes(OJClass[] types)
           
 void setModifiers(int mods)
           
 void setModifiers(OJModifier mods)
           
 void setName(java.lang.String name)
           
 void setReturnType(OJClass type)
           
 Signature signature()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OJMethod

public OJMethod(OJClass declarer,
                OJModifier modif,
                OJClass returnType,
                java.lang.String name,
                OJClass[] parameterTypes,
                OJClass[] exceptionTypes,
                StatementList body)
Constructs a new OJMethod object.

This constructor automatically generates parameter variables.


OJMethod

public OJMethod(OJClass declarer,
                OJModifier modif,
                OJClass returnType,
                java.lang.String name,
                OJClass[] parameterTypes,
                java.lang.String[] parameterNames,
                OJClass[] exceptionTypes,
                StatementList body)
Constructs a new OJMethod object.

OJMethod

public OJMethod(OJClass declarer,
                OJModifier modif,
                OJClass returnType,
                java.lang.String name,
                ParameterList params,
                OJClass[] exceptionTypes,
                StatementList body)
Constructs a new OJMethod object.

OJMethod

public OJMethod(Environment env,
                OJClass declarer,
                MethodDeclaration d)
Method Detail

makePrototype

public static OJMethod makePrototype(OJMethod original)
Generates a method object which has the same attributes as the model method except its body.

The body of generated method is to be set to null.

Parameters:
original - the base model for generating method object.

forMethod

public static OJMethod forMethod(java.lang.reflect.Method java_method)

arrayForMethods

public static OJMethod[] arrayForMethods(java.lang.reflect.Method[] jmethods)

signature

public Signature signature()
Specified by:
signature in interface OJMember

getDeclaringClass

public OJClass getDeclaringClass()
Specified by:
getDeclaringClass in interface OJMember

getName

public java.lang.String getName()
Specified by:
getName in interface OJMember

getIdentifiableName

public java.lang.String getIdentifiableName()

getModifiers

public OJModifier getModifiers()
Specified by:
getModifiers in interface OJMember

getReturnType

public OJClass getReturnType()

getParameterTypes

public OJClass[] getParameterTypes()

getExceptionTypes

public OJClass[] getExceptionTypes()

getParameterVariables

public ExpressionList getParameterVariables()
                                     throws CannotAlterException

getParameters

public java.lang.String[] getParameters()
                                 throws CannotAlterException

getSuffix

public ParseTree getSuffix(java.lang.String keyword)
Obtains an parse tree of suffix in extended syntax starting with the specified keyword. Returned openjava.ptree.ParseTree object has a structure built by an openjava.syntax.SyntaxRule object returned via the method getDeclSuffixRule(String).
Returns:
the parse tree
See Also:
OJClass.getDeclSuffixRule(String), SyntaxRule

equals

public boolean equals(java.lang.Object obj)
Compares this method against the given object. The algorithm is borrowed by java.lang.reflect.Method.equals().
Overrides:
equals in class java.lang.Object
See Also:
Method.equals(java.lang.Object)

hashCode

public int hashCode()
Computes a hashcode for this method. The algorithm is borrowed by java.lang.reflect.Method.hashCode().
Overrides:
hashCode in class java.lang.Object
See Also:
Method.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface OJMember

invoke

public java.lang.Object invoke(java.lang.Object obj,
                               java.lang.Object[] args)
                        throws java.lang.IllegalAccessException,
                               java.lang.IllegalArgumentException,
                               java.lang.reflect.InvocationTargetException,
                               CannotExecuteException
Invokes this method on the given object with the given parameters.
Throws:
CannotExecuteException - if this method is not compiled yet.

isExecutable

public final boolean isExecutable()

isAlterable

public final boolean isAlterable()

getByteCode

public final java.lang.reflect.Method getByteCode()
                                           throws CannotExecuteException

getSourceCode

public final MethodDeclaration getSourceCode()
                                      throws CannotAlterException

getBody

public final StatementList getBody()
                            throws CannotAlterException

setName

public final void setName(java.lang.String name)
                   throws CannotAlterException

setModifiers

public final void setModifiers(int mods)
                        throws CannotAlterException

setModifiers

public final void setModifiers(OJModifier mods)
                        throws CannotAlterException

setReturnType

public final void setReturnType(OJClass type)
                         throws CannotAlterException

setExceptionTypes

public final void setExceptionTypes(OJClass[] types)
                             throws CannotAlterException

addExceptionType

public final void addExceptionType(OJClass type)
                            throws CannotAlterException

setBody

public final StatementList setBody(StatementList stmts)
                            throws CannotAlterException