openjava.mop
Class OJMethod

java.lang.Object
  |
  +--openjava.mop.OJMethod
All Implemented Interfaces:
OJMember

public final class OJMethod
extends Object
implements OJMember


Field Summary
private  OJMethodImp substance
           
private static Hashtable table
           
 
Fields inherited from interface openjava.mop.OJMember
DECLARED, PUBLIC
 
Constructor Summary
  OJMethod(Environment env, OJClass declarer, MethodDeclaration d)
           
(package private) OJMethod(Method m)
           
  OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, String name, OJClass[] parameterTypes, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
  OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, String name, OJClass[] parameterTypes, String[] parameterNames, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
  OJMethod(OJClass declarer, OJModifier modif, OJClass returnType, String name, ParameterList params, OJClass[] exceptionTypes, StatementList body)
          Constructs a new OJMethod object.
 
Method Summary
 void addExceptionType(OJClass type)
           
static OJMethod[] arrayForMethods(Method[] jmethods)
           
private  boolean compareParameters(OJClass[] params2)
           
private  boolean compareParameters(OJMethod other)
           
 boolean equals(Object obj)
          Compares this method against the given object.
static OJMethod forMethod(Method java_method)
           
 StatementList getBody()
           
 Method getByteCode()
           
 OJClass getDeclaringClass()
           
 Environment getEnvironment()
           
 OJClass[] getExceptionTypes()
           
 String getIdentifiableName()
           
 OJModifier getModifiers()
           
 String getName()
           
 String[] getParameters()
           
 OJClass[] getParameterTypes()
           
 ExpressionList getParameterVariables()
           
 OJClass getReturnType()
           
 MethodDeclaration getSourceCode()
           
 ParseTree getSuffix(String keyword)
          Obtains an parse tree of suffix in extended syntax starting with the specified keyword.
 int hashCode()
          Computes a hashcode for this method.
 Object invoke(Object obj, 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)
           
(package private)  void setDeclaringClass(OJClass parent)
           
 void setExceptionTypes(OJClass[] types)
           
 void setModifiers(int mods)
           
 void setModifiers(OJModifier mods)
           
 void setName(String name)
           
 void setReturnType(OJClass type)
           
 Signature signature()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

substance

private OJMethodImp substance

table

private static Hashtable table
Constructor Detail

OJMethod

OJMethod(Method m)

OJMethod

public OJMethod(OJClass declarer,
                OJModifier modif,
                OJClass returnType,
                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,
                String name,
                OJClass[] parameterTypes,
                String[] parameterNames,
                OJClass[] exceptionTypes,
                StatementList body)
Constructs a new OJMethod object.


OJMethod

public OJMethod(OJClass declarer,
                OJModifier modif,
                OJClass returnType,
                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(Method java_method)

arrayForMethods

public static OJMethod[] arrayForMethods(Method[] jmethods)

signature

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

getDeclaringClass

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

getName

public String getName()
Specified by:
getName in interface OJMember

getIdentifiableName

public 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
CannotAlterException

getParameters

public String[] getParameters()
                       throws CannotAlterException
CannotAlterException

getSuffix

public ParseTree getSuffix(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(Object obj)
Compares this method against the given object. The algorithm is borrowed by java.lang.reflect.Method.equals().

Overrides:
equals in class Object
See Also:
Method.equals(java.lang.Object)

compareParameters

private boolean compareParameters(OJMethod other)

compareParameters

private boolean compareParameters(OJClass[] params2)

hashCode

public int hashCode()
Computes a hashcode for this method. The algorithm is borrowed by java.lang.reflect.Method.hashCode().

Overrides:
hashCode in class Object
See Also:
Method.hashCode()

toString

public String toString()
Overrides:
toString in class Object

getEnvironment

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

invoke

public Object invoke(Object obj,
                     Object[] args)
              throws IllegalAccessException,
                     IllegalArgumentException,
                     InvocationTargetException,
                     CannotExecuteException
Invokes this method on the given object with the given parameters.

Throws:
CannotExecuteException - if this method is not compiled yet.
IllegalAccessException
IllegalArgumentException
InvocationTargetException

isExecutable

public final boolean isExecutable()

isAlterable

public final boolean isAlterable()

getByteCode

public final Method getByteCode()
                         throws CannotExecuteException
CannotExecuteException

getSourceCode

public final MethodDeclaration getSourceCode()
                                      throws CannotAlterException
CannotAlterException

getBody

public final StatementList getBody()
                            throws CannotAlterException
CannotAlterException

setDeclaringClass

void setDeclaringClass(OJClass parent)
                 throws CannotAlterException
CannotAlterException

setName

public final void setName(String name)
                   throws CannotAlterException
CannotAlterException

setModifiers

public final void setModifiers(int mods)
                        throws CannotAlterException
CannotAlterException

setModifiers

public final void setModifiers(OJModifier mods)
                        throws CannotAlterException
CannotAlterException

setReturnType

public final void setReturnType(OJClass type)
                         throws CannotAlterException
CannotAlterException

setExceptionTypes

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

addExceptionType

public final void addExceptionType(OJClass type)
                            throws CannotAlterException
CannotAlterException

setBody

public final StatementList setBody(StatementList stmts)
                            throws CannotAlterException
CannotAlterException

SourceForge.net_Logo