gnu.mapping

Class Environment

Implemented Interfaces:
Named
Known Direct Subclasses:
BuiltinEnvironment, SimpleEnvironment

public abstract class Environment
extends PropertySet

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.

Method Summary

void
addLocation(EnvironmentKey key, Location loc)
void
addLocation(NamedLocation loc)
abstract NamedLocation
addLocation(Symbol name, Object prop, Location loc)
boolean
containsKey(Object key)
static Environment
current()
Deprecated.
Namespace
defaultNamespace()
abstract void
define(Symbol key, Object property, Object newValue)
abstract LocationEnumeration
enumerateAllLocations()
Does enumerate inherited Locations.
abstract LocationEnumeration
enumerateLocations()
Does not enumerate inherited Locations.
Object
get(Object key)
Get the value bound to the given name.
Object
get(String key, Object defaultValue)
Object
get(EnvironmentKey key, Object defaultValue)
Object
get(Symbol sym)
Object
get(Symbol key, Object property, 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.
Object
getChecked(String name)
Get the value bound to the given name.
static Environment
getCurrent()
int
getFlags()
Object
getFunction(Symbol sym)
Object
getFunction(Symbol key, Object defaultValue)
static Environment
getGlobal()
static Environment
getInstance(String name)
Location
getLocation(Object key, boolean create)
Location
getLocation(Symbol key)
Return a location bound to key (and null property).
Location
getLocation(Symbol key, Object property)
Return a location bound to (key, property).
NamedLocation
getLocation(Symbol name, Object property, boolean create)
abstract NamedLocation
getLocation(Symbol key, Object property, int hash, boolean create)
Symbol
getSymbol(String name)
protected abstract boolean
hasMoreElements(LocationEnumeration it)
boolean
isBound(Symbol key)
boolean
isBound(Symbol key, Object property)
boolean
isLocked()
True if this environment is locked - bindings cannot be added or removed.
Location
lookup(Symbol key)
Location
lookup(Symbol key, Object property)
Return a location bound to (key, property).
abstract NamedLocation
lookup(Symbol name, Object property, int hash)
static SimpleEnvironment
make()
static SimpleEnvironment
make(String name)
static InheritingEnvironment
make(String name, Environment parent)
Object
put(Object key, Object newValue)
Object
put(String key, Object value)
void
put(Symbol key, Object newValue)
void
put(Symbol key, Object property, Object newValue)
void
putFunction(Symbol key, Object newValue)
Object
remove(Object key)
Object
remove(EnvironmentKey key)
Remove and undefine binding.
void
remove(Symbol sym)
Object
remove(Symbol symbol, Object property)
Object
remove(Symbol key, Object property, int hash)
Remove Location from this Environment and undefine 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()
String
toString()
String
toStringVerbose()
Overridden in sub-classes - useful for more verbose debug output.
Location
unlink(Symbol key, Object property, int hash)
Remove Location from this Environment.
static Environment
user()

Methods inherited from class gnu.mapping.PropertySet

getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol

Field Details

INDIRECT_DEFINES

public static final int INDIRECT_DEFINES
Newly defined locations are created in inherited parent environment.
Field Value:
32

Method Details

addLocation

public final void addLocation(EnvironmentKey key,
                              Location loc)

addLocation

public final void addLocation(NamedLocation loc)

addLocation

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

containsKey

public final boolean containsKey(Object key)

current

public static Environment current()

Deprecated.


defaultNamespace

public Namespace defaultNamespace()

define

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

enumerateAllLocations

public abstract LocationEnumeration enumerateAllLocations()
Does enumerate inherited Locations.

enumerateLocations

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

get

public final Object get(Object key)
Get the value bound to the given name. Returns null if the name has no binding (for compatibility with Java2 Collections framework).

get

public final Object get(String key,
                        Object defaultValue)

get

public final Object get(EnvironmentKey key,
                        Object defaultValue)

get

public Object get(Symbol sym)

get

public Object get(Symbol key,
                  Object property,
                  Object defaultValue)

getCanDefine

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

getCanRedefine

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

getChecked

public final Object getChecked(String name)
Get the value bound to the given name.

getCurrent

public static Environment getCurrent()

getFlags

public int getFlags()

getFunction

public final Object getFunction(Symbol sym)

getFunction

public final Object getFunction(Symbol key,
                                Object defaultValue)

getGlobal

public static Environment getGlobal()

getInstance

public static Environment getInstance(String name)

getLocation

public final Location getLocation(Object key,
                                  boolean create)

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.

getLocation

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

getLocation

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

getLocation

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

getSymbol

public Symbol getSymbol(String name)

hasMoreElements

protected abstract boolean hasMoreElements(LocationEnumeration it)

isBound

public final boolean isBound(Symbol key)

isBound

public boolean isBound(Symbol key,
                       Object property)

isLocked

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

lookup

public final Location lookup(Symbol key)

lookup

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

lookup

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

make

public static SimpleEnvironment make()

make

public static SimpleEnvironment make(String name)

make

public static InheritingEnvironment make(String name,
                                         Environment parent)

put

public final Object put(Object key,
                        Object newValue)

put

public final Object put(String key,
                        Object value)

put

public final void put(Symbol key,
                      Object newValue)

put

public void put(Symbol key,
                Object property,
                Object newValue)

putFunction

public final void putFunction(Symbol key,
                              Object newValue)

remove

public final Object remove(Object key)

remove

public final Object remove(EnvironmentKey key)
Remove and undefine binding.
Returns:
Old value

remove

public final void remove(Symbol sym)

remove

public final Object remove(Symbol symbol,
                           Object property)

remove

public Object remove(Symbol key,
                     Object property,
                     int hash)
Remove Location from this Environment and undefine it.

removeFunction

public final void removeFunction(Symbol sym)

setCanDefine

public void setCanDefine(boolean canDefine)

setCanRedefine

public void setCanRedefine(boolean canRedefine)

setCurrent

public static void setCurrent(Environment env)

setFlag

public void setFlag(boolean setting,
                    int flag)

setGlobal

public static void setGlobal(Environment env)

setIndirectDefines

public final void setIndirectDefines()

setLocked

public void setLocked()

toString

public String toString()

toStringVerbose

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

unlink

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

user

public static Environment user()