Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

bsh
Class Name  view Name download Name.java

java.lang.Object
  extended bybsh.Name
All Implemented Interfaces:
java.io.Serializable

class Name
extends java.lang.Object
implements java.io.Serializable

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
private  int callstackDepth
           
(package private)  java.lang.Class classOfStaticMethod
          The result is a static method call on the following class
private  java.lang.Object evalBaseObject
           
private  java.lang.String evalName
          Remaining text to evaluate
private static java.lang.String FINISHED
           
private  java.lang.String lastEvalName
          The last part of the name evaluated.
 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
private  java.lang.Object completeRound(java.lang.String lastEvalName, java.lang.String nextEvalName, java.lang.Object returnObject)
           
private  java.lang.Object consumeNextObjectField(CallStack callstack, Interpreter interpreter, boolean forceClass, boolean autoAllocateThis)
          Get the next object by consuming one or more components of evalName.
(package private) static int countParts(java.lang.String value)
           
private  java.lang.Object invokeLocalMethod(Interpreter interpreter, java.lang.Object[] args, CallStack callstack, SimpleNode callerInfo)
          Invoke a locally declared method or a bsh command.
 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)
           
private  void reset()
           
(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()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

namespace

public NameSpace namespace

value

java.lang.String value

evalName

private java.lang.String evalName
Remaining text to evaluate


lastEvalName

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


FINISHED

private static java.lang.String FINISHED

evalBaseObject

private java.lang.Object evalBaseObject

callstackDepth

private int callstackDepth

asClass

java.lang.Class asClass
The result is a class


classOfStaticMethod

java.lang.Class classOfStaticMethod
The result is a static method call on the following class

Constructor Detail

Name

Name(NameSpace namespace,
     java.lang.String s)
This constructor should *not* be used in general. Use NameSpace getNameResolver() which supports caching.

Method Detail

reset

private void reset()

toObject

public java.lang.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

public java.lang.Object toObject(CallStack callstack,
                                 Interpreter interpreter,
                                 boolean forceClass)
                          throws UtilEvalError

completeRound

private java.lang.Object completeRound(java.lang.String lastEvalName,
                                       java.lang.String nextEvalName,
                                       java.lang.Object returnObject)

consumeNextObjectField

private java.lang.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.


resolveThisFieldReference

java.lang.Object resolveThisFieldReference(CallStack callstack,
                                           NameSpace thisNameSpace,
                                           Interpreter interpreter,
                                           java.lang.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.


toClass

public java.lang.Class toClass()
                        throws java.lang.ClassNotFoundException,
                               UtilEvalError
Check the cache, else use toObject() to try to resolve to a class identifier.


toLHS

public LHS toLHS(CallStack callstack,
                 Interpreter interpreter)
          throws UtilEvalError

invokeMethod

public java.lang.Object invokeMethod(Interpreter interpreter,
                                     java.lang.Object[] args,
                                     CallStack callstack,
                                     SimpleNode callerInfo)
                              throws UtilEvalError,
                                     EvalError,
                                     ReflectError,
                                     java.lang.reflect.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");
                


invokeLocalMethod

private java.lang.Object invokeLocalMethod(Interpreter interpreter,
                                           java.lang.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 /bsh/commands path.


isCompound

public static boolean isCompound(java.lang.String value)

countParts

static int countParts(java.lang.String value)

prefix

static java.lang.String prefix(java.lang.String value)

prefix

static java.lang.String prefix(java.lang.String value,
                               int parts)

suffix

static java.lang.String suffix(java.lang.String name)

suffix

public static java.lang.String suffix(java.lang.String value,
                                      int parts)

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).