Top Description Fields Constructors Methods
bsh

pack-priv Class Name

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.lang.reflect.Array, .InvocationTargetException, .Method, java.util.Hashtable, java.io.*

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

Modifier and TypeField and Description
pack-priv Class<T>
asClass

The result is a class

private int
pack-priv Class<T>
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

Constructor Summary

AccessConstructor and Description
pack-priv
Name(NameSpace namespace, String s)

This constructor should *not* be used in general.

Method Summary

Modifier and TypeMethod and Description
private Object
completeRound(String lastEvalName, String nextEvalName, Object returnObject)

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.
getClassNameSpace
(NameSpace thisNameSpace)

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
prefix(String value)

pack-priv static String
prefix(String value, int parts)

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
suffix(String name)

public static String
suffix(String value, int parts)

public synchronized Class<T>
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
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
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

asClassback to summary
pack-priv Class<T> asClass

The result is a class

callstackDepthback to summary
private int callstackDepth
classOfStaticMethodback to summary
pack-priv Class<T> classOfStaticMethod

The result is a static method call on the following class

evalBaseObjectback to summary
private Object evalBaseObject
evalNameback to summary
private String evalName

Remaining text to evaluate

FINISHEDback to summary
private static String FINISHED
lastEvalNameback to summary
private String lastEvalName

The last part of the name evaluated. This is really only used for this, caller, and super resolution.

namespaceback to summary
public NameSpace namespace
valueback to summary
pack-priv String value

Constructor Detail

Nameback to summary
pack-priv Name(NameSpace namespace, String s)

This constructor should *not* be used in general. Use NameSpace getNameResolver() which supports caching.

See Also
getNameResolver().

Method Detail

completeRoundback to summary
private Object completeRound(String lastEvalName, String nextEvalName, Object returnObject)
consumeNextObjectFieldback 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.

countPartsback to summary
pack-priv static int countParts(String value)
getClassNameSpaceback to summary
pack-priv static NameSpace getClassNameSpace(NameSpace thisNameSpace)
Returns:NameSpace

the enclosing class body namespace or null if not in a class.

invokeLocalMethodback 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)

invokeMethodback 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");
		
isCompoundback to summary
public static boolean isCompound(String value)
prefixback to summary
pack-priv static String prefix(String value)
prefixback to summary
pack-priv static String prefix(String value, int parts)
resetback to summary
private void reset()
resolveThisFieldReferenceback 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.

Parameters
callstack:CallStack

may be null, but this is only legitimate in special cases where we are sure resolution will not involve this.caller.

thisNameSpace:NameSpace

the namespace of the this reference (should be the same as the top of the stack?

suffixback to summary
pack-priv static String suffix(String name)
suffixback to summary
public static String suffix(String value, int parts)
toClassback to summary
public synchronized Class<T> toClass() throws ClassNotFoundException, UtilEvalError

Check the cache, else use toObject() to try to resolve to a class identifier.

Exceptions
ClassNotFoundException:
on class not found.
ClassPathException:
(type of EvalError) on special case of ambiguous unqualified name after super import.
toLHSback to summary
public synchronized LHS toLHS(CallStack callstack, Interpreter interpreter) throws UtilEvalError
toObjectback 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.

toObjectback to summary
public synchronized Object toObject(CallStack callstack, Interpreter interpreter, boolean forceClass) throws UtilEvalError
Parameters
forceClass: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.

See Also
toObject()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.