Package gnu.mapping
Class Environment
- java.lang.Object
-
- gnu.mapping.PropertySet
-
- gnu.mapping.Environment
-
- All Implemented Interfaces:
Named
- Direct Known Subclasses:
BuiltinEnvironment,SimpleEnvironment
public abstract class Environment extends PropertySet
A mapping fromEnvironmentKeytoLocations. AnEnvironmentKeyis either aSymbolor a (Symbol, property)-pair.
-
-
Field Summary
Fields Modifier and Type Field Description protected static gnu.mapping.Environment.InheritedLocalcurEnvironmentstatic intINDIRECT_DEFINESNewly defined locations are created in inherited parent environment.-
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
-
Constructor Summary
Constructors Constructor Description Environment()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddLocation(EnvironmentKey key, Location loc)voidaddLocation(NamedLocation loc)abstract NamedLocationaddLocation(Symbol name, Object prop, Location loc)booleancontainsKey(Object key)static Environmentcurrent()Deprecated.NamespacedefaultNamespace()abstract voiddefine(Symbol key, Object property, Object newValue)abstract LocationEnumerationenumerateAllLocations()Does enumerate inherited Locations.abstract LocationEnumerationenumerateLocations()Does not enumerate inherited Locations.Objectget(EnvironmentKey key, Object defaultValue)Objectget(Symbol sym)Objectget(Symbol key, Object property, Object defaultValue)Objectget(Object key)Get the value bound to the given name.Objectget(String key, Object defaultValue)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 sym)ObjectgetFunction(Symbol key, Object defaultValue)static EnvironmentgetGlobal()static EnvironmentgetInstance(String name)LocationgetLocation(Symbol key)Return a location bound to key (and null property).LocationgetLocation(Symbol key, Object property)Return a location bound to (key, property).NamedLocationgetLocation(Symbol name, Object property, boolean create)abstract NamedLocationgetLocation(Symbol key, Object property, int hash, boolean create)LocationgetLocation(Object key, boolean create)SymbolgetSymbol(String name)protected abstract booleanhasMoreElements(LocationEnumeration it)booleanisBound(Symbol key)booleanisBound(Symbol key, Object property)booleanisLocked()True if this environment is locked - bindings cannot be added or removed.Locationlookup(Symbol key)Locationlookup(Symbol key, Object property)Return a location bound to (key, property).abstract NamedLocationlookup(Symbol name, Object property, int hash)static SimpleEnvironmentmake()static SimpleEnvironmentmake(String name)static InheritingEnvironmentmake(String name, Environment parent)voidput(Symbol key, Object newValue)voidput(Symbol key, Object property, Object newValue)Objectput(Object key, Object newValue)Objectput(String key, Object value)voidputFunction(Symbol key, Object newValue)Objectremove(EnvironmentKey key)Remove and undefine binding.voidremove(Symbol sym)Objectremove(Symbol symbol, Object property)Objectremove(Symbol key, Object property, int hash)Remove Location from this Environment and undefine it.Objectremove(Object key)voidremoveFunction(Symbol sym)static voidrestoreCurrent(Environment saved)voidsetCanDefine(boolean canDefine)voidsetCanRedefine(boolean canRedefine)static voidsetCurrent(Environment env)voidsetFlag(boolean setting, int flag)static voidsetGlobal(Environment env)voidsetIndirectDefines()voidsetLocked()static EnvironmentsetSaveCurrent(Environment env)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()-
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
-
-
-
Field Detail
-
INDIRECT_DEFINES
public static final int INDIRECT_DEFINES
Newly defined locations are created in inherited parent environment.- See Also:
- Constant Field Values
-
curEnvironment
protected static final gnu.mapping.Environment.InheritedLocal curEnvironment
-
-
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, 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, 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)
-
getLocation
public abstract NamedLocation getLocation(Symbol key, Object property, int hash, boolean create)
-
getLocation
public final NamedLocation getLocation(Symbol name, Object property, boolean create)
-
isBound
public final boolean isBound(Symbol key)
-
containsKey
public final boolean containsKey(Object key)
-
getChecked
public final Object getChecked(String name)
Get the value bound to the given name.- Throws:
UnboundLocationException- the name has no binding- See Also:
get(Object)
-
get
public final Object get(EnvironmentKey key, Object defaultValue)
-
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(String)
-
unlink
public Location unlink(Symbol key, Object property, int hash)
Remove Location from this Environment. Does not explicitly undefine the location itself.
-
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 void remove(Symbol sym)
-
removeFunction
public final void removeFunction(Symbol sym)
-
defaultNamespace
public Namespace defaultNamespace()
-
getInstance
public static Environment getInstance(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
@Deprecated public static Environment current()
Deprecated.
-
getCurrent
public static Environment getCurrent()
-
setCurrent
public static void setCurrent(Environment env)
-
setSaveCurrent
public static Environment setSaveCurrent(Environment env)
-
restoreCurrent
public static void restoreCurrent(Environment saved)
-
user
public static Environment user()
-
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)
-
make
public static SimpleEnvironment make()
-
make
public static SimpleEnvironment make(String name)
-
make
public static InheritingEnvironment make(String name, Environment parent)
-
toStringVerbose
public String toStringVerbose()
Overridden in sub-classes - useful for more verbose debug output.
-
-