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 fromEnvironmentKey
toLocation
s. AnEnvironmentKey
is either aSymbol
or a (Symbol
, property)-pair.
-
-
Field Summary
Fields Modifier and Type Field Description protected static gnu.mapping.Environment.InheritedLocal
curEnvironment
static int
INDIRECT_DEFINES
Newly 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 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(EnvironmentKey key, Object defaultValue)
Object
get(Symbol sym)
Object
get(Symbol key, Object property, Object defaultValue)
Object
get(Object key)
Get the value bound to the given name.Object
get(String key, 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(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)
Location
getLocation(Object key, 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)
void
put(Symbol key, Object newValue)
void
put(Symbol key, Object property, Object newValue)
Object
put(Object key, Object newValue)
Object
put(String key, Object value)
void
putFunction(Symbol key, Object newValue)
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.Object
remove(Object key)
void
removeFunction(Symbol sym)
static void
restoreCurrent(Environment saved)
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()
static Environment
setSaveCurrent(Environment env)
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 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.
-
-