Package jadex.javaparser.javaccimpl
Class ReflectNode
java.lang.Object
jadex.javaparser.javaccimpl.SimpleNode
jadex.javaparser.javaccimpl.ExpressionNode
jadex.javaparser.javaccimpl.ReflectNode
- All Implemented Interfaces:
IParsedExpression
,Node
,Serializable
A node for a constructor or method invocation or field access.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Method
The field accessor method (for static and nonstatic fields).protected Object[]
The argument values (for constructors and methods).protected Class[]
The argument types (for constructors and methods).protected Class
The clazz.static final int
The constructor type.protected Constructor[]
The possible constructors (for constructor nodes).protected Field
The field (for static and nonstatic fields).static final int
The field type.static final int
The method type.protected Method[]
The possible methods (for static and nonstatic methods).protected boolean
Flag indicating that this node is a candidate dynamic class reloading (currently only supported for plan constructors).protected Class
The dynamically reloaded class (currently only for constructor nodes).static final int
The static field type.static final int
The static method type.protected int
The reflect node type.Fields inherited from class jadex.javaparser.javaccimpl.ExpressionNode
constant, constant_value, expressiontext, imports, static_type, text
Fields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent
-
Constructor Summary
ConstructorsConstructorDescriptionReflectNode
(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create an expression node. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
accessField
(Object ref, Class clazz, jadex.common.IValueFetcher fetcher) Access a field.boolean
Test if two nodes are equal.protected Constructor[]
findConstructors
(Class clazz, Class[] argtypes) Find all matching constructors of a given class.protected Method[]
findMethods
(Class clazz, Class[] argtypes) Find all matching methods of a given class.protected Method
getMethodForMethod
(Method method) Find method declared in public class for a given method.int
getType()
Get the constructor type.getValue
(jadex.common.IValueFetcher fetcher) Evaluate the expression in the given state with respect to given parameters.int
hashCode()
Get the hash code for the node.protected Object
invokeConstructor
(Class clazz, Class[] argtypes, Object[] args) Find and invoke a constructor.protected Object
invokeMethod
(Object ref, Class clazz, Class[] argtypes, Object[] args) Find and invoke a method.void
Precompute the set of matching constructors if possible.void
setType
(int type) Set the constructor type.Create a string representation of this node and its subnodes.Methods inherited from class jadex.javaparser.javaccimpl.ExpressionNode
appendText, getConstantValue, getExpressionText, getParameters, getStaticType, getText, getUnboundParameterNodes, isConstant, precompileTree, setConstant, setConstantValue, setExpressionText, setStaticType, setText, subnodeToString, throwEvaluationException, throwParseException, toString, toString
Methods inherited from class jadex.javaparser.javaccimpl.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
-
Field Details
-
CONSTRUCTOR
public static final int CONSTRUCTORThe constructor type.- See Also:
-
STATIC_METHOD
public static final int STATIC_METHODThe static method type.- See Also:
-
STATIC_FIELD
public static final int STATIC_FIELDThe static field type.- See Also:
-
METHOD
public static final int METHODThe method type.- See Also:
-
FIELD
public static final int FIELDThe field type.- See Also:
-
type
protected int typeThe reflect node type. -
clazz
The clazz. -
argtypes
The argument types (for constructors and methods). -
args
The argument values (for constructors and methods). -
constructors
The possible constructors (for constructor nodes). -
reloadedclass
The dynamically reloaded class (currently only for constructor nodes). -
methods
The possible methods (for static and nonstatic methods). -
accessor
The field accessor method (for static and nonstatic fields). -
field
The field (for static and nonstatic fields). -
reloadable
protected boolean reloadableFlag indicating that this node is a candidate dynamic class reloading (currently only supported for plan constructors).
-
-
Constructor Details
-
ReflectNode
public ReflectNode(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create an expression node.- Parameters:
p
- The parser.id
- The id.
-
-
Method Details
-
setType
public void setType(int type) Set the constructor type.- Parameters:
type
- The constrcutor type.
-
getType
public int getType()Get the constructor type.- Returns:
- The constructor type.
-
precompile
public void precompile()Precompute the set of matching constructors if possible.- Overrides:
precompile
in classExpressionNode
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValue
in interfaceIParsedExpression
- Specified by:
getValue
in classExpressionNode
- Parameters:
params
- The parameters (string, value pairs), if any.- Returns:
- The value of the term.
-
toPlainString
Create a string representation of this node and its subnodes.- Specified by:
toPlainString
in interfaceNode
- Overrides:
toPlainString
in classExpressionNode
- Returns:
- A string representation of this node.
-
findConstructors
Find all matching constructors of a given class.- Parameters:
clazz
- The class.argtypes
- The argument types.- Returns:
- The matched constructors.
-
findMethods
Find all matching methods of a given class.- Parameters:
clazz
- The class.argtypes
- The argument types.- Returns:
- The matched methods.
-
invokeConstructor
Find and invoke a constructor.- Parameters:
clazz
- The class to instantiate.argtypes
- The actual argument types.args
- The actual argument values.- Returns:
- The instantiated object.
- Throws:
Exception
-
invokeMethod
protected Object invokeMethod(Object ref, Class clazz, Class[] argtypes, Object[] args) throws Exception Find and invoke a method.- Parameters:
ref
- The object on which to invoke (may be null for static methods).clazz
- The class to instantiate.argtypes
- The actual argument types.args
- The actual argument values.- Returns:
- The return value.
- Throws:
Exception
-
accessField
protected Object accessField(Object ref, Class clazz, jadex.common.IValueFetcher fetcher) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException Access a field. -
getMethodForMethod
Find method declared in public class for a given method. -
equals
Test if two nodes are equal.- Overrides:
equals
in classExpressionNode
-
hashCode
public int hashCode()Get the hash code for the node.- Overrides:
hashCode
in classExpressionNode
-