public class ReflectNode extends ExpressionNode
Modifier and Type | Field and Description |
---|---|
protected java.lang.reflect.Method |
accessor
The field accessor method (for static and nonstatic fields).
|
protected java.lang.Object[] |
args
The argument values (for constructors and methods).
|
protected java.lang.Class[] |
argtypes
The argument types (for constructors and methods).
|
protected java.lang.Class |
clazz
The clazz.
|
static int |
CONSTRUCTOR
The constructor type.
|
protected java.lang.reflect.Constructor[] |
constructors
The possible constructors (for constructor nodes).
|
protected java.lang.reflect.Field |
field
The field (for static and nonstatic fields).
|
static int |
FIELD
The field type.
|
static int |
METHOD
The method type.
|
protected java.lang.reflect.Method[] |
methods
The possible methods (for static and nonstatic methods).
|
protected boolean |
reloadable
Flag indicating that this node is a candidate dynamic class reloading
(currently only supported for plan constructors).
|
protected java.lang.Class |
reloadedclass
The dynamically reloaded class (currently only for constructor nodes).
|
static int |
STATIC_FIELD
The static field type.
|
static int |
STATIC_METHOD
The static method type.
|
protected int |
type
The reflect node type.
|
constant, constant_value, expressiontext, imports, static_type, text
children, id, parent
Constructor and Description |
---|
ReflectNode(ParserImpl p,
int id)
Create an expression node.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
accessField(java.lang.Object ref,
java.lang.Class clazz,
IValueFetcher fetcher)
Access a field.
|
boolean |
equals(java.lang.Object o)
Test if two nodes are equal.
|
protected java.lang.reflect.Constructor[] |
findConstructors(java.lang.Class clazz,
java.lang.Class[] argtypes)
Find all matching constructors of a given class.
|
protected java.lang.reflect.Method[] |
findMethods(java.lang.Class clazz,
java.lang.Class[] argtypes)
Find all matching methods of a given class.
|
protected java.lang.reflect.Method |
getMethodForMethod(java.lang.reflect.Method method)
Find method declared in public class for a given method.
|
int |
getType()
Get the constructor type.
|
java.lang.Object |
getValue(IValueFetcher fetcher)
Evaluate the expression in the given state
with respect to given parameters.
|
int |
hashCode()
Get the hash code for the node.
|
protected java.lang.Object |
invokeConstructor(java.lang.Class clazz,
java.lang.Class[] argtypes,
java.lang.Object[] args)
Find and invoke a constructor.
|
protected java.lang.Object |
invokeMethod(java.lang.Object ref,
java.lang.Class clazz,
java.lang.Class[] argtypes,
java.lang.Object[] args)
Find and invoke a method.
|
void |
precompile()
Precompute the set of matching constructors if possible.
|
void |
setType(int type)
Set the constructor type.
|
java.lang.String |
toPlainString()
Create a string representation of this node and its subnodes.
|
appendText, getConstantValue, getExpressionText, getParameters, getStaticType, getText, getUnboundParameterNodes, isConstant, precompileTree, setConstant, setConstantValue, setExpressionText, setStaticType, setText, subnodeToString, throwEvaluationException, throwParseException, toString, toString
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
public static final int CONSTRUCTOR
public static final int STATIC_METHOD
public static final int STATIC_FIELD
public static final int METHOD
public static final int FIELD
protected int type
protected java.lang.Class clazz
protected transient java.lang.Class[] argtypes
protected transient java.lang.Object[] args
protected transient java.lang.reflect.Constructor[] constructors
protected transient java.lang.Class reloadedclass
protected transient java.lang.reflect.Method[] methods
protected transient java.lang.reflect.Method accessor
protected transient java.lang.reflect.Field field
protected boolean reloadable
public ReflectNode(ParserImpl p, int id)
p
- The parser.id
- The id.public void setType(int type)
type
- The constrcutor type.public int getType()
public void precompile()
precompile
in class ExpressionNode
public java.lang.Object getValue(IValueFetcher fetcher)
getValue
in interface IParsedExpression
getValue
in class ExpressionNode
params
- The parameters (string, value pairs), if any.public java.lang.String toPlainString()
toPlainString
in interface Node
toPlainString
in class ExpressionNode
protected java.lang.reflect.Constructor[] findConstructors(java.lang.Class clazz, java.lang.Class[] argtypes)
clazz
- The class.argtypes
- The argument types.protected java.lang.reflect.Method[] findMethods(java.lang.Class clazz, java.lang.Class[] argtypes)
clazz
- The class.argtypes
- The argument types.protected java.lang.Object invokeConstructor(java.lang.Class clazz, java.lang.Class[] argtypes, java.lang.Object[] args) throws java.lang.Exception
clazz
- The class to instantiate.argtypes
- The actual argument types.args
- The actual argument values.java.lang.Exception
protected java.lang.Object invokeMethod(java.lang.Object ref, java.lang.Class clazz, java.lang.Class[] argtypes, java.lang.Object[] args) throws java.lang.Exception
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.java.lang.Exception
protected java.lang.Object accessField(java.lang.Object ref, java.lang.Class clazz, IValueFetcher fetcher) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.NoSuchFieldException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NoSuchFieldException
protected java.lang.reflect.Method getMethodForMethod(java.lang.reflect.Method method)
public boolean equals(java.lang.Object o)
equals
in class ExpressionNode
public int hashCode()
hashCode
in class ExpressionNode