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 MethodThe 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 ClassThe clazz.static final intThe constructor type.protected Constructor[]The possible constructors (for constructor nodes).protected FieldThe field (for static and nonstatic fields).static final intThe field type.static final intThe method type.protected Method[]The possible methods (for static and nonstatic methods).protected booleanFlag indicating that this node is a candidate dynamic class reloading (currently only supported for plan constructors).protected ClassThe dynamically reloaded class (currently only for constructor nodes).static final intThe static field type.static final intThe static method type.protected intThe reflect node type.Fields inherited from class jadex.javaparser.javaccimpl.ExpressionNode
constant, constant_value, expressiontext, imports, static_type, textFields 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 ObjectaccessField(Object ref, Class clazz, jadex.common.IValueFetcher fetcher) Access a field.booleanTest 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 MethodgetMethodForMethod(Method method) Find method declared in public class for a given method.intgetType()Get the constructor type.getValue(jadex.common.IValueFetcher fetcher) Evaluate the expression in the given state with respect to given parameters.inthashCode()Get the hash code for the node.protected ObjectinvokeConstructor(Class clazz, Class[] argtypes, Object[] args) Find and invoke a constructor.protected ObjectinvokeMethod(Object ref, Class clazz, Class[] argtypes, Object[] args) Find and invoke a method.voidPrecompute the set of matching constructors if possible.voidsetType(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, toStringMethods 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:
precompilein classExpressionNode
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValuein interfaceIParsedExpression- Specified by:
getValuein 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:
toPlainStringin interfaceNode- Overrides:
toPlainStringin 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:
equalsin classExpressionNode
-
hashCode
public int hashCode()Get the hash code for the node.- Overrides:
hashCodein classExpressionNode
-