Package org.apache.commons.jexl2
Class MapContext
- java.lang.Object
-
- org.apache.commons.jexl2.MapContext
-
- All Implemented Interfaces:
JexlContext
public class MapContext extends java.lang.Object implements JexlContext
Wraps a map in a context.Each entry in the map is considered a variable name, value pair.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>
map
The wrapped variable map.
-
Constructor Summary
Constructors Constructor Description MapContext()
Creates a MapContext on an automatically allocated underlying HashMap.MapContext(java.util.Map<java.lang.String,java.lang.Object> vars)
Creates a MapContext wrapping an existing user provided map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.String name)
Gets the value of a variable.boolean
has(java.lang.String name)
Checks whether a variable is defined in this context.void
set(java.lang.String name, java.lang.Object value)
Sets the value of a variable.
-
-
-
Field Detail
-
map
protected final java.util.Map<java.lang.String,java.lang.Object> map
The wrapped variable map.
-
-
Constructor Detail
-
MapContext
public MapContext()
Creates a MapContext on an automatically allocated underlying HashMap.
-
MapContext
public MapContext(java.util.Map<java.lang.String,java.lang.Object> vars)
Creates a MapContext wrapping an existing user provided map.- Parameters:
vars
- the variable map
-
-
Method Detail
-
has
public boolean has(java.lang.String name)
Checks whether a variable is defined in this context.A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.
- Specified by:
has
in interfaceJexlContext
- Parameters:
name
- the variable's name- Returns:
- true if it exists, false otherwise
-
get
public java.lang.Object get(java.lang.String name)
Gets the value of a variable.- Specified by:
get
in interfaceJexlContext
- Parameters:
name
- the variable's name- Returns:
- the value
-
set
public void set(java.lang.String name, java.lang.Object value)
Sets the value of a variable.- Specified by:
set
in interfaceJexlContext
- Parameters:
name
- the variable's namevalue
- the variable's value
-
-