Package bsh

Class ExternalNameSpace3

  • All Implemented Interfaces:
    bsh.BshClassManager.Listener, bsh.NameSource, Serializable
    Direct Known Subclasses:
    ExtensibleObjectNamespace

    public class ExternalNameSpace3
    extends bsh.NameSpace
    A namespace which maintains an external map of values held in variables in its scope. This mechanism provides a standard collections based interface to the namespace as well as a convenient way to export and view values of the namespace without the ordinary BeanShell wrappers.

    Variables are maintained internally in the normal fashion to support meta-information (such as variable type and visibility modifiers), but exported and imported in a synchronized way. Variables are exported each time they are written by BeanShell. Imported variables from the map appear in the BeanShell namespace as untyped variables with no modifiers and shadow any previously defined variables in the scope.

    Note: this class is inherentely dependent on Java 1.2, however it is not used directly by the core as other than type NameSpace, so no dependency is introduced.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface bsh.NameSource

        bsh.NameSource.Listener
    • Field Summary

      • Fields inherited from class bsh.NameSpace

        importedClasses, JAVACODE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).
      protected void getAllNamesAux​(Vector vec)  
      bsh.Variable[] getDeclaredVariables()  
      Map getMap()
      Get the map view of this namespace.
      bsh.BshMethod getMethod​(String name, Class[] sig, boolean declaredOnly)  
      protected bsh.Variable getVariableImpl​(String name, boolean recurse)  
      String[] getVariableNames()  
      protected void putExternalMap​(String name, Object value)
      Place an unwrapped value in the external map.
      void setMap​(Map map)
      Set the external Map which to which this namespace synchronizes.
      void setMethod​(String name, bsh.BshMethod method)  
      void setTypedVariable​(String name, Class type, Object value, bsh.Modifiers modifiers)  
      void unsetVariable​(String name)  
      • Methods inherited from class bsh.NameSpace

        addNameSourceListener, classLoaderChanged, doSuperImport, get, getAllNames, getClass, getClassManager, getCommand, getGlobal, getImportedMethod, getImportedVar, getInvocationLine, getInvocationText, getMethod, getMethodNames, getMethods, getName, getParent, getSuper, getVariable, getVariable, identifierToClass, importClass, importCommands, importObject, importPackage, importStatic, invokeMethod, invokeMethod, loadDefaultImports, nameSpaceChanged, prune, setName, setParent, setTypedVariable, setVariable, toString, unwrapVariable
    • Constructor Detail

      • ExternalNameSpace3

        public ExternalNameSpace3()
      • ExternalNameSpace3

        public ExternalNameSpace3​(bsh.NameSpace parent,
                                  String name,
                                  Map externalMap)
    • Method Detail

      • getMap

        public Map getMap()
        Get the map view of this namespace.
      • setMap

        public void setMap​(Map map)
        Set the external Map which to which this namespace synchronizes. The previous external map is detached from this namespace. Previous map values are retained in the external map, but are removed from the BeanShell namespace.
      • unsetVariable

        public void unsetVariable​(String name)
        Overrides:
        unsetVariable in class bsh.NameSpace
      • getVariableNames

        public String[] getVariableNames()
        Overrides:
        getVariableNames in class bsh.NameSpace
      • getVariableImpl

        protected bsh.Variable getVariableImpl​(String name,
                                               boolean recurse)
                                        throws bsh.UtilEvalError
        Overrides:
        getVariableImpl in class bsh.NameSpace
        Throws:
        bsh.UtilEvalError
      • getDeclaredVariables

        public bsh.Variable[] getDeclaredVariables()
        Overrides:
        getDeclaredVariables in class bsh.NameSpace
      • setTypedVariable

        public void setTypedVariable​(String name,
                                     Class type,
                                     Object value,
                                     bsh.Modifiers modifiers)
                              throws bsh.UtilEvalError
        Overrides:
        setTypedVariable in class bsh.NameSpace
        Throws:
        bsh.UtilEvalError
      • setMethod

        public void setMethod​(String name,
                              bsh.BshMethod method)
                       throws bsh.UtilEvalError
        Overrides:
        setMethod in class bsh.NameSpace
        Throws:
        bsh.UtilEvalError
      • getMethod

        public bsh.BshMethod getMethod​(String name,
                                       Class[] sig,
                                       boolean declaredOnly)
                                throws bsh.UtilEvalError
        Overrides:
        getMethod in class bsh.NameSpace
        Throws:
        bsh.UtilEvalError
      • getAllNamesAux

        protected void getAllNamesAux​(Vector vec)
        Overrides:
        getAllNamesAux in class bsh.NameSpace
      • clear

        public void clear()
        Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).
        Overrides:
        clear in class bsh.NameSpace
      • putExternalMap

        protected void putExternalMap​(String name,
                                      Object value)
        Place an unwrapped value in the external map. BeanShell primitive types are represented by their object wrappers, so it is not possible to differentiate between wrapper types and primitive types via the external Map.