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 interfacestatic class(package private) static classDefault Value when cannot resolve class symbol.(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Env.IntCounterprivate Expressionprivate AviatorEvaluatorInstanceCurrent 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 longprivate long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPackageSymbol(String sym) private Class<?> classForName(String name) 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.private StringfindSymbol(String name) Remove a key-value pair from overrides.Get value for key.getmOverrides(boolean readOnly) longintprivate voidbooleanisEmpty()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 voidvoidAdd 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) voidsetExpression(Expression expression) voidsetInstance(AviatorEvaluatorInstance instance) voidsetmOverrides(Map<String, Object> mOverrides) private voidsetStats(long startNs, Env.IntCounter checkPoints) 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
-
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 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. -
getmOverrides
-