| java.lang.Object bsh.Name
Name | class Name implements java.io.Serializable(Code) | | What's in a name? I'll tell you...
Name() is a somewhat ambiguous thing in the grammar and so is this.
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.
|
Constructor Summary | |
| Name(NameSpace namespace, String s) This constructor should *not* be used in general. |
Method Summary | |
static int | countParts(String value) | static NameSpace | getClassNameSpace(NameSpace thisNameSpace) | public Object | invokeMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo) 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. | public static boolean | isCompound(String value) | static String | prefix(String value) | static String | prefix(String value, int parts) | Object | resolveThisFieldReference(CallStack callstack, NameSpace thisNameSpace, Interpreter interpreter, String varName, boolean specialFieldsVisible) Resolve a variable relative to a This reference.
This is the general variable resolution method, accomodating special
fields from the This context. | static String | suffix(String name) | public static String | suffix(String value, int parts) | public synchronized Class | toClass() Check the cache, else use toObject() to try to resolve to a class
identifier. | public synchronized LHS | toLHS(CallStack callstack, Interpreter interpreter) | public Object | toObject(CallStack callstack, Interpreter interpreter) Resolve possibly complex name to an object value. | public synchronized Object | toObject(CallStack callstack, Interpreter interpreter, boolean forceClass) | public String | toString() |
classOfStaticMethod | Class classOfStaticMethod(Code) | | The result is a static method call on the following class
|
Name | Name(NameSpace namespace, String s)(Code) | | This constructor should *not* be used in general.
Use NameSpace getNameResolver() which supports caching.
See Also: NameSpace See Also: getNameResolver(). |
getClassNameSpace | static NameSpace getClassNameSpace(NameSpace thisNameSpace)(Code) | | the enclosing class body namespace or null if not in a class. |
invokeMethod | public Object invokeMethod(Interpreter interpreter, Object[] args, CallStack callstack, SimpleNode callerInfo) throws UtilEvalError, EvalError, ReflectError, InvocationTargetException(Code) | | 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 | public static boolean isCompound(String value)(Code) | | |
resolveThisFieldReference | Object resolveThisFieldReference(CallStack callstack, NameSpace thisNameSpace, Interpreter interpreter, String varName, boolean specialFieldsVisible) throws UtilEvalError(Code) | | 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.
Parameters: callstack - may be null, but this is only legitimate in specialcases where we are sure resolution will not involve this.caller. Parameters: namespace - the namespace of the this reference (should be thesame as the top of the stack? |
toObject | public Object toObject(CallStack callstack, Interpreter interpreter) throws UtilEvalError(Code) | | 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 | public synchronized Object toObject(CallStack callstack, Interpreter interpreter, boolean forceClass) throws UtilEvalError(Code) | | See Also: toObject() Parameters: forceClass - if true then resolution will only produce a class.This is necessary to disambiguate in cases where the grammar knowsthat we want a class; where in general the var path may be taken. |
|
|