gnu.mapping
Class Environment

java.lang.Object
  extended by gnu.mapping.Procedure
      extended by gnu.mapping.Procedure1
          extended by gnu.mapping.NameMap
              extended by gnu.mapping.Environment
All Implemented Interfaces:
HasSetter, Named
Direct Known Subclasses:
BuiltinEnvironment, SimpleEnvironment

public abstract class Environment
extends NameMap

A mapping from EnvironmentKey to Locations. An EnvironmentKey is either a Symbol or a (Symbol, property)-pair.


Field Summary
static int INDIRECT_DEFINES
          Newly defined locations are created in inherited parent environment.
 
Constructor Summary
Environment()
           
 
Method Summary
 void addLocation(EnvironmentKey key, Location loc)
           
 void addLocation(NamedLocation loc)
           
abstract  NamedLocation addLocation(Symbol name, java.lang.Object prop, Location loc)
           
 boolean containsKey(java.lang.Object key)
           
static Environment current()
          Deprecated.  
 Namespace defaultNamespace()
           
abstract  void define(Symbol key, java.lang.Object property, java.lang.Object newValue)
           
abstract  LocationEnumeration enumerateAllLocations()
          Does enumerate inherited Locations.
abstract  LocationEnumeration enumerateLocations()
          Does not enumerate inherited Locations.
 java.lang.Object get(EnvironmentKey key, java.lang.Object defaultValue)
           
 java.lang.Object get(java.lang.Object key)
          Get the value bound to the given name.
 java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
           
 java.lang.Object get(Symbol sym)
           
 java.lang.Object get(Symbol key, java.lang.Object property, java.lang.Object defaultValue)
           
 boolean getCanDefine()
          True if new bindings (non-unbound Locations) can be added.
 boolean getCanRedefine()
          True if bindings can be removed or replaced by other kinds of Location.
static Environment getCurrent()
           
 int getFlags()
           
 java.lang.Object getFunction(Symbol sym)
           
 java.lang.Object getFunction(Symbol key, java.lang.Object defaultValue)
           
static Environment getGlobal()
           
static Environment getInstance(java.lang.String name)
           
 Location getLocation(java.lang.Object key, boolean create)
           
 Location getLocation(Symbol key)
          Return a location bound to key (and null property).
 Location getLocation(Symbol key, java.lang.Object property)
          Return a location bound to (key, property).
 NamedLocation getLocation(Symbol name, java.lang.Object property, boolean create)
           
abstract  NamedLocation getLocation(Symbol key, java.lang.Object property, int hash, boolean create)
           
 Symbol getSymbol(java.lang.String name)
           
protected abstract  boolean hasMoreElements(LocationEnumeration it)
           
 boolean isBound(Symbol key)
           
 boolean isBound(Symbol key, java.lang.Object property)
           
 boolean isLocked()
          True if this environment is locked - bindings cannot be added or removed.
 Location lookup(Symbol key)
           
 Location lookup(Symbol key, java.lang.Object property)
          Return a location bound to (key, property).
abstract  NamedLocation lookup(Symbol name, java.lang.Object property, int hash)
           
static SimpleEnvironment make()
           
static SimpleEnvironment make(java.lang.String name)
           
static InheritingEnvironment make(java.lang.String name, Environment parent)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object newValue)
           
 java.lang.Object put(java.lang.String key, java.lang.Object value)
           
 void put(Symbol key, java.lang.Object newValue)
           
 void put(Symbol key, java.lang.Object property, java.lang.Object newValue)
           
 void putFunction(Symbol key, java.lang.Object newValue)
           
 java.lang.Object remove(EnvironmentKey key)
          Remove and undefine binding.
 java.lang.Object remove(java.lang.Object key)
           
 void remove(Symbol sym)
           
 void remove(Symbol symbol, java.lang.Object property)
           
 void remove(Symbol key, java.lang.Object property, int hash)
          Remove Location from this Environment and undefined it.
 void removeFunction(Symbol sym)
           
 void setCanDefine(boolean canDefine)
           
 void setCanRedefine(boolean canRedefine)
           
static void setCurrent(Environment env)
           
 void setFlag(boolean setting, int flag)
           
static void setGlobal(Environment env)
           
 void setIndirectDefines()
           
 void setLocked()
           
 java.lang.String toString()
           
 java.lang.String toStringVerbose()
          Overridden in sub-classes - useful for more verbose debug output.
 Location unlink(Symbol key, java.lang.Object property, int hash)
          Remove Location from this Environment.
static Environment user()
           
 
Methods inherited from class gnu.mapping.NameMap
apply1, getChecked, set1
 
Methods inherited from class gnu.mapping.Procedure1
apply0, apply2, apply3, apply4, applyN, numArgs
 
Methods inherited from class gnu.mapping.Procedure
apply, apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getName, getProperty, getSetter, getSymbol, match0, match1, match2, match3, match4, matchN, maxArgs, minArgs, name, removeProperty, set0, setN, setName, setProperty, setProperty, setSetter, setSymbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gnu.mapping.HasSetter
getSetter
 

Field Detail

INDIRECT_DEFINES

public static final int INDIRECT_DEFINES
Newly defined locations are created in inherited parent environment.

See Also:
Constant Field Values
Constructor Detail

Environment

public Environment()
Method Detail

setGlobal

public static void setGlobal(Environment env)

getGlobal

public static Environment getGlobal()

getFlags

public int getFlags()

setFlag

public void setFlag(boolean setting,
                    int flag)

getCanDefine

public boolean getCanDefine()
True if new bindings (non-unbound Locations) can be added.


setCanDefine

public void setCanDefine(boolean canDefine)

getCanRedefine

public boolean getCanRedefine()
True if bindings can be removed or replaced by other kinds of Location.


setCanRedefine

public void setCanRedefine(boolean canRedefine)

isLocked

public final boolean isLocked()
True if this environment is locked - bindings cannot be added or removed.


setLocked

public void setLocked()

setIndirectDefines

public final void setIndirectDefines()

getLocation

public final Location getLocation(Symbol key,
                                  java.lang.Object property)
Return a location bound to (key, property). Create new unbound Location if no such Location exists.


getLocation

public final Location getLocation(Symbol key)
Return a location bound to key (and null property). Create new unbound Location if no such Location exists.


lookup

public final Location lookup(Symbol key,
                             java.lang.Object property)
Return a location bound to (key, property). Return null if no such Location exists.


lookup

public abstract NamedLocation lookup(Symbol name,
                                     java.lang.Object property,
                                     int hash)

lookup

public final Location lookup(Symbol key)

getLocation

public abstract NamedLocation getLocation(Symbol key,
                                          java.lang.Object property,
                                          int hash,
                                          boolean create)

getLocation

public final NamedLocation getLocation(Symbol name,
                                       java.lang.Object property,
                                       boolean create)

getLocation

public final Location getLocation(java.lang.Object key,
                                  boolean create)

isBound

public boolean isBound(Symbol key,
                       java.lang.Object property)

isBound

public final boolean isBound(Symbol key)

containsKey

public final boolean containsKey(java.lang.Object key)

get

public java.lang.Object get(Symbol key,
                            java.lang.Object property,
                            java.lang.Object defaultValue)

get

public final java.lang.Object get(EnvironmentKey key,
                                  java.lang.Object defaultValue)

get

public final java.lang.Object get(java.lang.String key,
                                  java.lang.Object defaultValue)
Specified by:
get in class NameMap

get

public java.lang.Object get(Symbol sym)

getFunction

public final java.lang.Object getFunction(Symbol key,
                                          java.lang.Object defaultValue)

getFunction

public final java.lang.Object getFunction(Symbol sym)

get

public final java.lang.Object get(java.lang.Object key)
Description copied from class: NameMap
Get the value bound to the given name. Returns null if the name has no binding (for compatibility with Java2 Collections framework).

Overrides:
get in class NameMap
See Also:
NameMap.getChecked(String)

put

public void put(Symbol key,
                java.lang.Object property,
                java.lang.Object newValue)

define

public abstract void define(Symbol key,
                            java.lang.Object property,
                            java.lang.Object newValue)

put

public final void put(Symbol key,
                      java.lang.Object newValue)

put

public final java.lang.Object put(java.lang.Object key,
                                  java.lang.Object newValue)

putFunction

public final void putFunction(Symbol key,
                              java.lang.Object newValue)

put

public final java.lang.Object put(java.lang.String key,
                                  java.lang.Object value)
Specified by:
put in class NameMap

unlink

public Location unlink(Symbol key,
                       java.lang.Object property,
                       int hash)
Remove Location from this Environment. Does not explicitly undefine the location itself.


remove

public void remove(Symbol key,
                   java.lang.Object property,
                   int hash)
Remove Location from this Environment and undefined it.


remove

public java.lang.Object remove(EnvironmentKey key)
Remove and undefine binding. (A more type-specific version of gnu.util.mape.remove.)

Returns:
Old value

remove

public void remove(Symbol symbol,
                   java.lang.Object property)

remove

public final void remove(Symbol sym)

removeFunction

public final void removeFunction(Symbol sym)

remove

public final java.lang.Object remove(java.lang.Object key)

defaultNamespace

public Namespace defaultNamespace()

getSymbol

public Symbol getSymbol(java.lang.String name)

getInstance

public static Environment getInstance(java.lang.String name)

enumerateLocations

public abstract LocationEnumeration enumerateLocations()
Does not enumerate inherited Locations.


enumerateAllLocations

public abstract LocationEnumeration enumerateAllLocations()
Does enumerate inherited Locations.


hasMoreElements

protected abstract boolean hasMoreElements(LocationEnumeration it)

current

public static Environment current()
Deprecated. 


getCurrent

public static Environment getCurrent()

setCurrent

public static void setCurrent(Environment env)

user

public static Environment user()

addLocation

public final void addLocation(NamedLocation loc)

addLocation

public abstract NamedLocation addLocation(Symbol name,
                                          java.lang.Object prop,
                                          Location loc)

addLocation

public final void addLocation(EnvironmentKey key,
                              Location loc)

make

public static SimpleEnvironment make()

make

public static SimpleEnvironment make(java.lang.String name)

make

public static InheritingEnvironment make(java.lang.String name,
                                         Environment parent)

toString

public java.lang.String toString()
Overrides:
toString in class Procedure

toStringVerbose

public java.lang.String toStringVerbose()
Overridden in sub-classes - useful for more verbose debug output.