pnuts.ext
Class CompositePackage

java.lang.Object
  extended by pnuts.lang.Package
      extended by pnuts.ext.CompositePackage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Property

public class CompositePackage
extends Package

Composed hierarchical names space based on a Package. A read access first looks for the symbol in the local symbol table, if not found, then looks for the base package. A write access never affect the base package.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class pnuts.lang.Package
autoloadTable, exportedSymbols, exports, globalPackage, initialized, name, packages, parent, providedModuleNames, requiredModuleNames, root, usedAsModule
 
Constructor Summary
CompositePackage()
           
CompositePackage(Package base)
          Constructor
 
Method Summary
 java.util.Enumeration bindings()
          Returns an enumeration of the NamedValues in the symbol table.
 void clear()
          Deletes all name-value bindings.
 java.lang.Object get(java.lang.String interned)
          Gets the value of a variable.
 Package getBasePackage()
          Gets the base package
 java.util.Enumeration keys()
          Returns an enumeration of the keys in the symbol table.
 NamedValue lookup(java.lang.String symbol)
          Looks for a name-value binding in the symbol table chain.
 NamedValue lookup(java.lang.String symbol, Context context)
          First looks for the symbol in the local symbol table.
 Package newInstance(java.lang.String name)
          Creates a sub-package
 void set(java.lang.String interned, java.lang.Object value)
          Defines a name-value binding in the symbol table.
 void setConstant(java.lang.String interned, java.lang.Object value)
          Defines a constant in the symbol table.
 int size()
           
 java.util.Enumeration values()
          Returns an enumeration of the values in the symbol table.
 
Methods inherited from class pnuts.lang.Package
addPackage, asMap, autoload, autoload, clear, clone, defined, elements, export, find, find, get, getGlobalPackage, getName, getPackage, getPackage, getParent, init, initializeModule, lookupRecursively, remove, remove, removePackage, set, toString, wrap
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositePackage

public CompositePackage()

CompositePackage

public CompositePackage(Package base)
Constructor

Parameters:
base - the base package
Method Detail

newInstance

public Package newInstance(java.lang.String name)
Creates a sub-package

Overrides:
newInstance in class Package
Parameters:
name - the name of the sub-package
Returns:
a Package object

getBasePackage

public Package getBasePackage()
Gets the base package


lookup

public NamedValue lookup(java.lang.String symbol,
                         Context context)
First looks for the symbol in the local symbol table. If not found looks for the symbol in the base package.

Overrides:
lookup in class Package
Parameters:
symbol - the symbol to look for
context - the context
Returns:
the pnuts.lang.NamedValue object that holds the value of the symbol if it exists. null, otherwise.

lookup

public NamedValue lookup(java.lang.String symbol)
Looks for a name-value binding in the symbol table chain.

Parameters:
symbol - the name of the variable, which must be intern'd
Returns:
the value

get

public java.lang.Object get(java.lang.String interned)
Gets the value of a variable.

Parameters:
interned - the name of the variable, which must be intern'd
Returns:
the value

set

public void set(java.lang.String interned,
                java.lang.Object value)
Defines a name-value binding in the symbol table.

Parameters:
interned - the name of the variable, which must be intern'd
value - the new value
Throws:
java.lang.IllegalStateException - thrown when the specified symbol has been defined as a constant.

setConstant

public void setConstant(java.lang.String interned,
                        java.lang.Object value)
Defines a constant in the symbol table.

Parameters:
interned - the name of the variable, which must be intern'd
value - the constant value
Throws:
java.lang.IllegalStateException - thrown when the specified symbol has been defined as a constant

clear

public void clear()
Deletes all name-value bindings.


size

public int size()

bindings

public java.util.Enumeration bindings()
Returns an enumeration of the NamedValues in the symbol table.

Returns:
an enumeration of the NamedValues
See Also:
NamedValue

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in the symbol table.

Returns:
an enumeration of the keys

values

public java.util.Enumeration values()
Returns an enumeration of the values in the symbol table.

Returns:
an enumeration of the values