This class is a name resolver. It holds a possibly ambiguous dot separated name and reference to a namespace in which it allegedly lives. It provides methods that attempt to resolve the name to various types of entities: e.g. an Object, a Class, a declared scripted BeanShell method.
Name objects are created by the factory method NameSpace getNameResolver(), which caches them subject to a class namespace change. This means that we can cache information about various types of resolution here. Currently very little if any information is cached. However with a future "optimize" setting that defeats certain dynamic behavior we might be able to cache quite a bit.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Class | asClass
The result is a class |
| private int | |
| pack-priv Class | classOfStaticMethod
The result is a static method call on the following class |
| private Object | |
| private String | evalName
Remaining text to evaluate |
| private static String | |
| private String | lastEvalName
The last part of the name evaluated. |
| public NameSpace | |
| pack-priv String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private Object | |
| private Object | consumeNextObjectField(CallStack callstack, Interpreter interpreter, boolean forceClass, boolean autoAllocateThis)
Get the next object by consuming one or more components of evalName. |
| pack-priv static int | |
| pack-priv static NameSpace | Returns: the enclosing class body namespace or null if not in a class.
|
| private Object | invokeLocalMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo)
Invoke a locally declared method or a bsh command. |
| public Object | invokeMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo)
Invoke the method identified by this name. |
| public static boolean | |
| pack-priv static String | |
| pack-priv static String | |
| private void | |
| pack-priv Object | resolveThisFieldReference(CallStack
may be null, but this is only legitimate in special
cases where we are sure resolution will not involve this.caller. callstack, NameSpace the namespace of the this reference (should be the
same as the top of the stack? thisNameSpace, Interpreter interpreter, String varName, boolean specialFieldsVisible)Resolve a variable relative to a This reference. |
| pack-priv static String | |
| public static String | |
| public synchronized Class | |
| public synchronized LHS | |
| public Object | toObject(CallStack callstack, Interpreter interpreter)
Resolve possibly complex name to an object value. |
| public synchronized Object | toObject(CallStack callstack, Interpreter interpreter, boolean
if true then resolution will only produce a class.
This is necessary to disambiguate in cases where the grammar knows
that we want a class; where in general the var path may be taken. forceClass)
|
| public String |
| asClass | back to summary |
|---|---|
| pack-priv Class<T> asClass The result is a class | |
| callstackDepth | back to summary |
|---|---|
| private int callstackDepth | |
| classOfStaticMethod | back to summary |
|---|---|
| pack-priv Class<T> classOfStaticMethod The result is a static method call on the following class | |
| evalBaseObject | back to summary |
|---|---|
| private Object evalBaseObject | |
| evalName | back to summary |
|---|---|
| private String evalName Remaining text to evaluate | |
| FINISHED | back to summary |
|---|---|
| private static String FINISHED | |
| lastEvalName | back to summary |
|---|---|
| private String lastEvalName The last part of the name evaluated. This is really only used for this, caller, and super resolution. | |
| namespace | back to summary |
|---|---|
| public NameSpace namespace | |
| value | back to summary |
|---|---|
| pack-priv String value | |
| Name | back to summary |
|---|---|
| pack-priv Name(NameSpace namespace, String s) This constructor should *not* be used in general. Use NameSpace getNameResolver() which supports caching.
| |
| completeRound | back to summary |
|---|---|
| private Object completeRound(String lastEvalName, String nextEvalName, Object returnObject) | |
| consumeNextObjectField | back to summary |
|---|---|
| private Object consumeNextObjectField(CallStack callstack, Interpreter interpreter, boolean forceClass, boolean autoAllocateThis) throws UtilEvalError Get the next object by consuming one or more components of evalName. Often this consumes just one component, but if the name is a classname it will consume all of the components necessary to make the class identifier. | |
| countParts | back to summary |
|---|---|
| pack-priv static int countParts(String value) | |
| getClassNameSpace | back to summary |
|---|---|
pack-priv static NameSpace getClassNameSpace(NameSpace thisNameSpace)
| |
| invokeLocalMethod | back to summary |
|---|---|
| private Object invokeLocalMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo) throws EvalError Invoke a locally declared method or a bsh command. If the method is not already declared in the namespace then try to load it as a resource from the imported command path (e.g. /bsh/commands) | |
| invokeMethod | back to summary |
|---|---|
| public Object invokeMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo) throws UtilEvalError, EvalError, ReflectError, InvocationTargetException Invoke the method identified by this name. Performs caching of method resolution using SignatureKey. Name contains a wholely unqualfied messy name; resolve it to ( object | static prefix ) + method name and invoke. The interpreter is necessary to support 'this.interpreter' references in the called code. (e.g. debug());
Some cases:
// dynamic
local();
myVariable.foo();
myVariable.bar.blah.foo();
// static
java.lang.Integer.getInteger("foo");
| |
| isCompound | back to summary |
|---|---|
| public static boolean isCompound(String value) | |
| prefix | back to summary |
|---|---|
| pack-priv static String prefix(String value) | |
| prefix | back to summary |
|---|---|
| pack-priv static String prefix(String value, int parts) | |
| reset | back to summary |
|---|---|
| private void reset() | |
| resolveThisFieldReference | back to summary |
|---|---|
| pack-priv Object resolveThisFieldReference(CallStack callstack, NameSpace thisNameSpace, Interpreter interpreter, String varName, boolean specialFieldsVisible) throws UtilEvalError Resolve a variable relative to a This reference. This is the general variable resolution method, accomodating special fields from the This context. Together the namespace and interpreter comprise the This context. The callstack, if available allows for the this.caller construct. Optionally interpret special "magic" field names: e.g. interpreter.
| |
| suffix | back to summary |
|---|---|
| pack-priv static String suffix(String name) | |
| suffix | back to summary |
|---|---|
| public static String suffix(String value, int parts) | |
| toClass | back to summary |
|---|---|
| public synchronized Class Check the cache, else use toObject() to try to resolve to a class identifier.
| |
| toLHS | back to summary |
|---|---|
| public synchronized LHS toLHS(CallStack callstack, Interpreter interpreter) throws UtilEvalError | |
| toObject | back to summary |
|---|---|
| public Object toObject(CallStack callstack, Interpreter interpreter) throws UtilEvalError Resolve possibly complex name to an object value. Throws EvalError on various failures. A null object value is indicated by a Primitive.NULL. A return type of Primitive.VOID comes from attempting to access an undefined variable. Some cases: myVariable myVariable.foo myVariable.foo.bar java.awt.GridBagConstraints.BOTH my.package.stuff.MyClass.someField.someField... Interpreter reference is necessary to allow resolution of "this.interpreter" magic field. CallStack reference is necessary to allow resolution of "this.caller" magic field. "this.callstack" magic field. | |
| toObject | back to summary |
|---|---|
public synchronized Object toObject(CallStack callstack, Interpreter interpreter, boolean forceClass) throws UtilEvalError
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |