|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbsh.Name
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.
| Field Summary | |
(package private) java.lang.Class |
asClass
The result is a class |
(package private) java.lang.Class |
classOfStaticMethod
The result is a static method call on the following class |
NameSpace |
namespace
|
(package private) java.lang.String |
value
|
| Constructor Summary | |
(package private) |
Name(NameSpace namespace,
java.lang.String s)
This constructor should *not* be used in general. |
| Method Summary | |
(package private) static int |
countParts(java.lang.String value)
|
(package private) static NameSpace |
getClassNameSpace(NameSpace thisNameSpace)
|
java.lang.Object |
invokeMethod(Interpreter interpreter,
java.lang.Object[] args,
CallStack callstack,
SimpleNode callerInfo)
Invoke the method identified by this name. |
static boolean |
isCompound(java.lang.String value)
|
(package private) static java.lang.String |
prefix(java.lang.String value)
|
(package private) static java.lang.String |
prefix(java.lang.String value,
int parts)
|
(package private) java.lang.Object |
resolveThisFieldReference(CallStack callstack,
NameSpace thisNameSpace,
Interpreter interpreter,
java.lang.String varName,
boolean specialFieldsVisible)
Resolve a variable relative to a This reference. |
(package private) static java.lang.String |
suffix(java.lang.String name)
|
static java.lang.String |
suffix(java.lang.String value,
int parts)
|
java.lang.Class |
toClass()
Check the cache, else use toObject() to try to resolve to a class identifier. |
LHS |
toLHS(CallStack callstack,
Interpreter interpreter)
|
java.lang.Object |
toObject(CallStack callstack,
Interpreter interpreter)
Resolve possibly complex name to an object value. |
java.lang.Object |
toObject(CallStack callstack,
Interpreter interpreter,
boolean forceClass)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public NameSpace namespace
java.lang.String value
java.lang.Class asClass
java.lang.Class classOfStaticMethod
| Constructor Detail |
Name(NameSpace namespace,
java.lang.String s)
getNameResolver().| Method Detail |
public java.lang.Object toObject(CallStack callstack,
Interpreter interpreter)
throws UtilEvalError
UtilEvalError
public java.lang.Object toObject(CallStack callstack,
Interpreter interpreter,
boolean forceClass)
throws UtilEvalError
forceClass - 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.
UtilEvalErrortoObject()
java.lang.Object resolveThisFieldReference(CallStack callstack,
NameSpace thisNameSpace,
Interpreter interpreter,
java.lang.String varName,
boolean specialFieldsVisible)
throws UtilEvalError
callstack - may be null, but this is only legitimate in special
cases where we are sure resolution will not involve this.caller.
UtilEvalErrorstatic NameSpace getClassNameSpace(NameSpace thisNameSpace)
public java.lang.Class toClass()
throws java.lang.ClassNotFoundException,
UtilEvalError
java.lang.ClassNotFoundException - on class not found.
ClassPathException - (type of EvalError) on special case of
ambiguous unqualified name after super import.
UtilEvalError
public LHS toLHS(CallStack callstack,
Interpreter interpreter)
throws UtilEvalError
UtilEvalError
public java.lang.Object invokeMethod(Interpreter interpreter,
java.lang.Object[] args,
CallStack callstack,
SimpleNode callerInfo)
throws UtilEvalError,
EvalError,
ReflectError,
java.lang.reflect.InvocationTargetException
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");
UtilEvalError
EvalError
ReflectError
java.lang.reflect.InvocationTargetExceptionpublic static boolean isCompound(java.lang.String value)
static int countParts(java.lang.String value)
static java.lang.String prefix(java.lang.String value)
static java.lang.String prefix(java.lang.String value,
int parts)
static java.lang.String suffix(java.lang.String name)
public static java.lang.String suffix(java.lang.String value,
int parts)
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||