Package com.googlecode.aviator.utils
Class Env
java.lang.Object
com.googlecode.aviator.utils.Env
- Type Parameters:
String-Object-
- All Implemented Interfaces:
Serializable,Map<String,Object>
Expression execute environment.Modifed from ChainedMap in jibx.
- Author:
- dennis
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPackageSymbol(String sym) voidclear()Clear all override key-value pairs.voidconfigure(AviatorEvaluatorInstance instance, Expression exp, long startNs, Env.IntCounter checkPoints) booleancontainsKey(Object key) Check if a key has a defined value.booleancontainsValue(Object value) Check if a value is present.entrySet()Get the set of entries.Remove a key-value pair from overrides.Get value for key.longintbooleanisEmpty()Check if no overrides are defined.keySet()Get the set of keys.Set an override value.Assign an value, if it's already in overrides, it will update it, otherwise set it to default map.voidAdd all key-value pairs from another map into the overrides map.Remove a key-value pair.Class<?> resolveClassSymbol(String name) Class<?> resolveClassSymbol(String name, boolean checkIfAllow) voidsetExpression(Expression expression) voidsetInstance(AviatorEvaluatorInstance instance) voidsetmOverrides(Map<String, Object> mOverrides) intsize()Get the number of entries in the map.toString()Gets the map as a String.values()Get the values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
EMPTY_ENV
-
-
Constructor Details
-
Env
public Env()Constructs an env instance with empty state. -
Env
Constructor.- Parameters:
defaults- map providing defaults for keys not set directly
-
Env
-
-
Method Details
-
setmOverrides
-
getStartNs
public long getStartNs() -
incExecCheckpointsAndGet
public int incExecCheckpointsAndGet() -
getCheckPoints
-
getImportedSymbols
-
getExpression
-
setExpression
-
getDefaults
-
addSymbol
-
addPackageSymbol
-
getInstance
-
setInstance
-
configure
public void configure(AviatorEvaluatorInstance instance, Expression exp, long startNs, Env.IntCounter checkPoints) -
resolveClassSymbol
- Throws:
ClassNotFoundException
-
resolveClassSymbol
- Throws:
ClassNotFoundException
-
clear
public void clear()Clear all override key-value pairs. This only effects the overrides, not the defaults. -
containsKey
Check if a key has a defined value. This will returntrueif the key is present in the overrides map or the defaults map.- Specified by:
containsKeyin interfaceMap<String,Object> - Parameters:
key-- Returns:
trueif key defined,falseif not
-
containsValue
Check if a value is present.- Specified by:
containsValuein interfaceMap<String,Object> - Parameters:
value-- Returns:
trueif value present as an override,falseif not
-
entrySet
Get the set of entries. -
get
Get value for key. If the key is present in the overrides map, the value from that map is returned; otherwise, the value for the key in the defaults map is returned. -
isEmpty
public boolean isEmpty()Check if no overrides are defined. -
keySet
Get the set of keys. This only returns the keys in the overrides map. -
override
Set an override value.- Parameters:
key-value-- Returns:
-
put
Assign an value, if it's already in overrides, it will update it, otherwise set it to default map. -
putAll
Add all key-value pairs from another map into the overrides map. -
remove
Remove a key-value pair. If the key was previously present in the overrides map it is simply removed from that map. If it was not present in the overrides map but is present in the defaults map, a null entry is added to the overrides map for that key. -
forgot
Remove a key-value pair from overrides.- Parameters:
key-- Returns:
-
size
public int size()Get the number of entries in the map. This returns the entry count for the overrides map only. -
values
Get the values. This returns only the values in the overrides map. -
toString
Gets the map as a String.
-