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

Quick Search    Search Deep

bsh
Class ClassNameSpace  view ClassNameSpace download ClassNameSpace.java

java.lang.Object
  extended bybsh.NameSpace
      extended bybsh.ClassNameSpace
All Implemented Interfaces:
BshClassManager.Listener, NameSource, java.io.Serializable

class ClassNameSpace
extends NameSpace

A ClassNameSpace represents the body a scripted class definition or scripted class instance. In the case of the class definition it serves as the Class object and holds the class initializer method (called before the constructor).

When serving as a class definition, only static members are visible and attempting to access an instance member will cause a "can't reach instance from static context" exception.

When serving as a class instance static members are dissallowed (except by the initializer) and are ignored, allowing them to be seen in the class definition.

Class instances also serve as the top scope of instance variables declared within the class (by the initializer).


Nested Class Summary
 
Nested classes inherited from class bsh.NameSpace
NameSpace.CommandPathEntry, NameSpace.Variable
 
Nested classes inherited from class bsh.NameSource
NameSource.Listener
 
Field Summary
static int CLASS
           
static int INSTANCE
           
(package private)  int type
           
 
Fields inherited from class bsh.NameSpace
callerInfoNode, isMethod, JAVACODE, nameSourceListeners, nsName
 
Constructor Summary
ClassNameSpace(NameSpace parent, java.lang.String name, int type)
           
 
Method Summary
protected  void checkMethodModifiers(BshMethod method)
           
protected  void checkVariableModifiers(java.lang.String name, Modifiers modifiers)
          Dissallow static vars outside of a class
 This constructClassInstance(java.lang.Object[] args, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo)
           
 boolean isClass()
           
 boolean isClassInstance()
           
static boolean isScriptedClass(java.lang.Object obj)
           
protected  boolean isVisible(BshMethod method)
          This is a hook to allow ClassNameSpace to add functionality to getMethod()
protected  boolean isVisible(NameSpace.Variable var)
          This is a hook to allow ClassNameSpace to add functionality in getVariableImpl()
 void setVariable(java.lang.String name, java.lang.Object value, boolean strictJava)
          Set the variable through this namespace.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class bsh.NameSpace
addCommandPath, addNameSourceListener, classLoaderChanged, clear, doSuperImport, get, getAllNames, getAllNamesAux, getAssignableForm, getClass, getClassManager, getCommand, getCommand, getGlobal, getInvocationLine, getInvocationText, getMethod, getMethodNames, getMethods, getName, getNameResolver, getNode, getParent, getSuper, getThis, getVariable, getVariable, getVariableImpl, getVariableNames, identifierToClass, importClass, importPackage, invokeMethod, invokeMethod, loadDefaultImports, nameSpaceChanged, prune, removeCommandPath, setClassManager, setLocalVariable, setMethod, setName, setNode, setParent, setTypedVariable, setTypedVariable, setVariable, setVariable, unsetVariable, unwrapVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

public static final int CLASS
See Also:
Constant Field Values

INSTANCE

public static final int INSTANCE
See Also:
Constant Field Values

type

int type
Constructor Detail

ClassNameSpace

public ClassNameSpace(NameSpace parent,
                      java.lang.String name,
                      int type)
               throws EvalError
Method Detail

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value,
                        boolean strictJava)
                 throws UtilEvalError
Description copied from class: NameSpace
Set the variable through this namespace. This method obeys the LOCALSCOPING property to determine how variables are set.

Note: this method is primarily intended for use internally. If you use this method outside of the bsh package and wish to set variables with primitive values you will have to wrap them using bsh.Primitive.

Overrides:
setVariable in class NameSpace

isVisible

protected boolean isVisible(NameSpace.Variable var)
                     throws UtilEvalError
This is a hook to allow ClassNameSpace to add functionality in getVariableImpl()

Overrides:
isVisible in class NameSpace

isVisible

protected boolean isVisible(BshMethod method)
                     throws UtilEvalError
This is a hook to allow ClassNameSpace to add functionality to getMethod()

Overrides:
isVisible in class NameSpace

isClassInstance

public boolean isClassInstance()

isClass

public boolean isClass()

constructClassInstance

public This constructClassInstance(java.lang.Object[] args,
                                   Interpreter interpreter,
                                   CallStack callstack,
                                   SimpleNode callerInfo)
                            throws EvalError

checkVariableModifiers

protected void checkVariableModifiers(java.lang.String name,
                                      Modifiers modifiers)
                               throws UtilEvalError
Description copied from class: NameSpace
Dissallow static vars outside of a class

Overrides:
checkVariableModifiers in class NameSpace

checkMethodModifiers

protected void checkMethodModifiers(BshMethod method)
                             throws UtilEvalError
Overrides:
checkMethodModifiers in class NameSpace

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()).

Overrides:
toString in class NameSpace

isScriptedClass

public static boolean isScriptedClass(java.lang.Object obj)