gnu.mapping

Class Environment

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 intINDIRECT_DEFINES
Newly defined locations are created in inherited parent environment.
Method Summary
voidaddLocation(NamedLocation loc)
abstract NamedLocationaddLocation(Symbol name, Object prop, Location loc)
voidaddLocation(EnvironmentKey key, Location loc)
booleancontainsKey(Object key)
static Environmentcurrent()
NamespacedefaultNamespace()
abstract voiddefine(Symbol key, Object property, Object newValue)
abstract LocationEnumerationenumerateAllLocations()
Does enumerate inherited Locations.
abstract LocationEnumerationenumerateLocations()
Does not enumerate inherited Locations.
Objectget(Symbol key, Object property, Object defaultValue)
Objectget(EnvironmentKey key, Object defaultValue)
Objectget(String key, Object defaultValue)
Objectget(Symbol sym)
Objectget(Object key)
Get the value bound to the given name.
booleangetCanDefine()
True if new bindings (non-unbound Locations) can be added.
booleangetCanRedefine()
True if bindings can be removed or replaced by other kinds of Location.
ObjectgetChecked(String name)
Get the value bound to the given name.
static EnvironmentgetCurrent()
intgetFlags()
ObjectgetFunction(Symbol key, Object defaultValue)
ObjectgetFunction(Symbol sym)
static EnvironmentgetGlobal()
static EnvironmentgetInstance(String name)
LocationgetLocation(Symbol key, Object property)
Return a location bound to (key, property).
LocationgetLocation(Symbol key)
Return a location bound to key (and null property).
abstract NamedLocationgetLocation(Symbol key, Object property, int hash, boolean create)
NamedLocationgetLocation(Symbol name, Object property, boolean create)
LocationgetLocation(Object key, boolean create)
SymbolgetSymbol(String name)
protected abstract booleanhasMoreElements(LocationEnumeration it)
booleanisBound(Symbol key, Object property)
booleanisBound(Symbol key)
booleanisLocked()
True if this environment is locked - bindings cannot be added or removed.
Locationlookup(Symbol key, Object property)
Return a location bound to (key, property).
abstract NamedLocationlookup(Symbol name, Object property, int hash)
Locationlookup(Symbol key)
static SimpleEnvironmentmake()
static SimpleEnvironmentmake(String name)
static InheritingEnvironmentmake(String name, Environment parent)
voidput(Symbol key, Object property, Object newValue)
voidput(Symbol key, Object newValue)
Objectput(Object key, Object newValue)
Objectput(String key, Object value)
voidputFunction(Symbol key, Object newValue)
Objectremove(Symbol key, Object property, int hash)
Remove Location from this Environment and undefine it.
Objectremove(EnvironmentKey key)
Remove and undefine binding.
Objectremove(Symbol symbol, Object property)
voidremove(Symbol sym)
Objectremove(Object key)
voidremoveFunction(Symbol sym)
voidsetCanDefine(boolean canDefine)
voidsetCanRedefine(boolean canRedefine)
static voidsetCurrent(Environment env)
voidsetFlag(boolean setting, int flag)
static voidsetGlobal(Environment env)
voidsetIndirectDefines()
voidsetLocked()
StringtoString()
StringtoStringVerbose()
Overridden in sub-classes - useful for more verbose debug output.
Locationunlink(Symbol key, Object property, int hash)
Remove Location from this Environment.
static Environmentuser()

Field Detail

INDIRECT_DEFINES

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

Method Detail

addLocation

public final void addLocation(NamedLocation loc)

addLocation

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

addLocation

public final void addLocation(EnvironmentKey key, 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 Object get(Symbol key, Object property, Object defaultValue)

get

public final Object get(EnvironmentKey key, Object defaultValue)

get

public final Object get(String key, Object defaultValue)

get

public Object get(Symbol sym)

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

See Also: getChecked

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.

Throws: gnu.mapping.UnboundLocationException the name has no binding

See Also: get

getCurrent

public static Environment getCurrent()

getFlags

public int getFlags()

getFunction

public final Object getFunction(Symbol key, Object defaultValue)

getFunction

public final Object getFunction(Symbol sym)

getGlobal

public static Environment getGlobal()

getInstance

public static Environment getInstance(String name)

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 Location getLocation(Symbol key)
Return a location bound to key (and null property). Create new unbound Location if no such Location exists.

getLocation

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

getLocation

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

getLocation

public final Location getLocation(Object key, boolean create)

getSymbol

public Symbol getSymbol(String name)

hasMoreElements

protected abstract boolean hasMoreElements(LocationEnumeration it)

isBound

public boolean isBound(Symbol key, Object property)

isBound

public final boolean isBound(Symbol key)

isLocked

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

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)

lookup

public final Location lookup(Symbol key)

make

public static SimpleEnvironment make()

make

public static SimpleEnvironment make(String name)

make

public static InheritingEnvironment make(String name, Environment parent)

put

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

put

public final void put(Symbol key, Object newValue)

put

public final Object put(Object key, Object newValue)

put

public final Object put(String key, Object value)

putFunction

public final void putFunction(Symbol key, Object newValue)

remove

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

remove

public final Object remove(EnvironmentKey key)
Remove and undefine binding.

Returns: Old value

remove

public final Object remove(Symbol symbol, Object property)

remove

public final void remove(Symbol sym)

remove

public final Object remove(Object key)

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