Class Env

java.lang.Object
com.googlecode.aviator.utils.Env
Type Parameters:
String -
Object -
All Implemented Interfaces:
Serializable, Map<String,Object>

public class Env extends Object implements Map<String,Object>, Serializable
Expression execute environment.Modifed from ChainedMap in jibx.
See Also:
  • Field Details

  • Constructor Details

    • Env

      public Env()
      Constructs an env instance with empty state.
    • Env

      public Env(Map<String,Object> defaults)
      Constructor.
      Parameters:
      defaults - map providing defaults for keys not set directly
    • Env

      public Env(Map<String,Object> defaults, Map<String,Object> overrides)
  • Method Details

    • setmOverrides

      public void setmOverrides(Map<String,Object> mOverrides)
    • getStartNs

      public long getStartNs()
    • incExecCheckpointsAndGet

      public int incExecCheckpointsAndGet()
    • getCheckPoints

      public Env.IntCounter getCheckPoints()
    • getImportedSymbols

      public List<String> getImportedSymbols()
    • getExpression

      public Expression getExpression()
    • setExpression

      public void setExpression(Expression expression)
    • getDefaults

      public Map<String,Object> getDefaults()
    • addSymbol

      public String addSymbol(String sym)
    • addPackageSymbol

      public String addPackageSymbol(String sym)
    • invalidateCache

      private void invalidateCache()
    • getInstance

      public AviatorEvaluatorInstance getInstance()
    • setInstance

      public void setInstance(AviatorEvaluatorInstance instance)
    • configure

      public void configure(AviatorEvaluatorInstance instance, Expression exp, long startNs, Env.IntCounter checkPoints)
    • setStats

      private void setStats(long startNs, Env.IntCounter checkPoints)
    • findSymbol

      private String findSymbol(String name) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • resolveClassSymbol

      public Class<?> resolveClassSymbol(String name) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • resolveClassSymbol

      public Class<?> resolveClassSymbol(String name, boolean checkIfAllow) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • resolveFromImportedPackages

      private Class<?> resolveFromImportedPackages(String name)
    • resolveFromImportedSymbols

      private Class<?> resolveFromImportedSymbols(String name, Class<?> clazz) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • put2cache

      private void put2cache(String name, Class<?> ret)
    • retrieveFromCache

      private Class<?> retrieveFromCache(String name)
    • classForName

      private Class<?> classForName(String name)
    • clear

      public void clear()
      Clear all override key-value pairs. This only effects the overrides, not the defaults.
      Specified by:
      clear in interface Map<String,Object>
    • containsKey

      public boolean containsKey(Object key)
      Check if a key has a defined value. This will return true if the key is present in the overrides map or the defaults map.
      Specified by:
      containsKey in interface Map<String,Object>
      Parameters:
      key -
      Returns:
      true if key defined, false if not
    • containsValue

      public boolean containsValue(Object value)
      Check if a value is present.
      Specified by:
      containsValue in interface Map<String,Object>
      Parameters:
      value -
      Returns:
      true if value present as an override, false if not
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Get the set of entries.
      Specified by:
      entrySet in interface Map<String,Object>
      Returns:
      override entries
    • get

      public Object get(Object key)
      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.
      Specified by:
      get in interface Map<String,Object>
      Parameters:
      key -
      Returns:
      value (null if key not present)
    • isEmpty

      public boolean isEmpty()
      Check if no overrides are defined.
      Specified by:
      isEmpty in interface Map<String,Object>
      Returns:
      true if no overrides, false if any present
    • keySet

      public Set<String> keySet()
      Get the set of keys. This only returns the keys in the overrides map.
      Specified by:
      keySet in interface Map<String,Object>
      Returns:
      keys
    • override

      public Object override(String key, Object value)
      Set an override value.
      Parameters:
      key -
      value -
      Returns:
    • put

      public Object put(String key, Object value)
      Assign an value, if it's already in overrides, it will update it, otherwise set it to default map.
      Specified by:
      put in interface Map<String,Object>
      Parameters:
      key -
      value -
      Returns:
      previous value for key (from default map, if not present in overrides)
    • putAll

      public void putAll(Map map)
      Add all key-value pairs from another map into the overrides map.
      Specified by:
      putAll in interface Map<String,Object>
      Parameters:
      map -
    • remove

      public Object remove(Object key)
      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.
      Specified by:
      remove in interface Map<String,Object>
      Parameters:
      key -
      Returns:
      previous value for key
    • forgot

      public Object forgot(Object key)
      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.
      Specified by:
      size in interface Map<String,Object>
      Returns:
      entry count
    • values

      public Collection<Object> values()
      Get the values. This returns only the values in the overrides map.
      Specified by:
      values in interface Map<String,Object>
      Returns:
      values
    • toString

      public String toString()
      Gets the map as a String.
      Overrides:
      toString in class Object
      Returns:
      a string version of the map
    • getmOverrides

      private Map<String,Object> getmOverrides(boolean readOnly)