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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
static class
(package private) static class
Default Value when cannot resolve class symbol.(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Env.IntCounter
private Expression
private AviatorEvaluatorInstance
Current evaluator instance that executes current expression.private static final IdentityHashMap
<String, Env.GetValueTask> Internal variable tasks to get the value.Default values map.Override values map.private static final long
private long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPackageSymbol
(String sym) private Class
<?> classForName
(String name) void
clear()
Clear all override key-value pairs.void
configure
(AviatorEvaluatorInstance instance, Expression exp, long startNs, Env.IntCounter checkPoints) boolean
containsKey
(Object key) Check if a key has a defined value.boolean
containsValue
(Object value) Check if a value is present.entrySet()
Get the set of entries.private String
findSymbol
(String name) Remove a key-value pair from overrides.Get value for key.getmOverrides
(boolean readOnly) long
int
private void
boolean
isEmpty()
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.private void
void
Add 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) private Class
<?> private Class
<?> resolveFromImportedSymbols
(String name, Class<?> clazz) private Class
<?> retrieveFromCache
(String name) void
setExpression
(Expression expression) void
setInstance
(AviatorEvaluatorInstance instance) void
setmOverrides
(Map<String, Object> mOverrides) private void
setStats
(long startNs, Env.IntCounter checkPoints) int
size()
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, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
mDefaults
Default values map. -
instance
Current evaluator instance that executes current expression. -
mOverrides
Override values map. -
expression
-
importedSymbols
-
importedPackages
-
resolvedClasses
-
EMPTY_ENV
-
startNs
private long startNs -
checkPoints
-
INTERNAL_VARIABLES
Internal variable tasks to get the value.
-
-
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
-
invalidateCache
private void invalidateCache() -
getInstance
-
setInstance
-
configure
public void configure(AviatorEvaluatorInstance instance, Expression exp, long startNs, Env.IntCounter checkPoints) -
setStats
-
findSymbol
- Throws:
ClassNotFoundException
-
resolveClassSymbol
- Throws:
ClassNotFoundException
-
resolveClassSymbol
- Throws:
ClassNotFoundException
-
resolveFromImportedPackages
-
resolveFromImportedSymbols
private Class<?> resolveFromImportedSymbols(String name, Class<?> clazz) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
put2cache
-
retrieveFromCache
-
classForName
-
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 returntrue
if the key is present in the overrides map or the defaults map.- Specified by:
containsKey
in interfaceMap<String,
Object> - Parameters:
key
-- Returns:
true
if key defined,false
if not
-
containsValue
Check if a value is present.- Specified by:
containsValue
in interfaceMap<String,
Object> - Parameters:
value
-- Returns:
true
if value present as an override,false
if 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. -
getmOverrides
-