|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.christopherschultz.evaluator.util.DefaultEvaluationContext
public class DefaultEvaluationContext
Contains important information about the current expression evaluation.
Using the loadStandard()
method, you can have this
EvaluationContext load "standard" functions and constants
into the context from the file EvaluationContext.properties
.
Using the load(ResourceBundle)
or load(Map)
methods,
you can load those constants and function definitions from arbitrary
sources.
I also might need some flags, like, 'should a NULL return object result in the expression evaluation terminating, returning nulls until the final return?'. That would be useful for when you want to vail out in the case that one of your functions returns null denoting that the expression cannot currently be evaluated.
Constructor Summary | |
---|---|
DefaultEvaluationContext()
Creates a new EvaluationContext. |
Method Summary | |
---|---|
Object |
get(String identifier)
Gets the value of the specified identifier. |
Map |
getAll()
Returns a Map of all bound identifiers and their values. |
Object |
getProperty(String key)
Gets the specified property. |
void |
load(Map props)
|
void |
load(ResourceBundle bundle)
|
EvaluationContext |
loadStandard()
|
Object |
remove(String identifier)
Removes the value of an identifier. |
void |
removeProperty(Object key)
Removes the specified property. |
Object |
set(String identifier,
Object value)
Sets the value of the specified identifer to the given value. |
void |
setProperty(String key,
Object value)
Sets the specified property to the given value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultEvaluationContext()
Creates a new EvaluationContext.
Note that no functions, constants, etc. will be defined
in this EvaluationContext. If you want to load all the
"standard" functions and constants, as defined by
EvaluationContext.properties, then call the
loadStandard()
method. If you want to load
your own functions, constants, and properties, then
use load(ResourceBundle)
or load(Map)
.
Method Detail |
---|
public Object get(String identifier)
get
in interface EvaluationContext
identifier
- The identifier for the value.
public Map getAll()
getAll
in interface EvaluationContext
public Object set(String identifier, Object value)
set
in interface EvaluationContext
identifier
- The identifier for the value.value
- The value for the identifier.
value
object.public Object remove(String identifier)
EvaluationContext
remove
in interface EvaluationContext
identifier
- The identifier whose value should be removed.
null
if there was
no value.public void setProperty(String key, Object value)
setProperty
in interface EvaluationContext
key
- The name of the property.value
- The value of the property.public Object getProperty(String key)
getProperty
in interface EvaluationContext
key
- The name of the property.
public void removeProperty(Object key)
removeProperty
in interface EvaluationContext
key
- The name of the property to remove.public EvaluationContext loadStandard()
public void load(ResourceBundle bundle)
public void load(Map props)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |