|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.betwixt.expression.Context
public class Context
Context
describes the context used to evaluate
bean expressions.
This is mostly a bean together with a number of context variables.
Context variables are named objects.
In other words,
a context variable associates an object with a string.
Logging during expression evaluation is done through the logging
instance held by this class.
The object initiating the evaluation should control this logging
and so passing a Log
instance is enforced by the constructors.
Context
is a natural place to include shared evaluation code.
One of the problems that you get with object graphs is that they can be cyclic.
Xml cannot (directly) include cycles.
Therefore betwixt
needs to find and deal properly with cycles.
The algorithm used is to check the parentage of a new child.
If the child is a parent then that operation fails.
Field Summary | |
---|---|
private Object |
bean
Evaluate this bean |
private Log |
log
Logging uses commons-logging Log
named org.apache.commons.betwixt |
private Map |
variables
Variables map |
Constructor Summary | |
---|---|
Context()
Construct context with default log |
|
Context(Object bean,
Log log)
Convenience constructor sets evaluted bean and log. |
|
Context(Object bean,
Map variables,
Log log)
Convenience constructor sets evaluted bean, context variables and log. |
Method Summary | |
---|---|
Object |
getBean()
Gets the current bean. |
Log |
getLog()
Gets the current log. |
Object |
getVariable(String name)
Gets the value of a particular context variable. |
Map |
getVariables()
Gets context variables. |
Context |
newContext(Object newBean)
Returns a new child context with the given bean but the same log and variables. |
void |
setBean(Object bean)
Set the current bean. |
void |
setLog(Log log)
Set the log implementation to which this class logs |
void |
setVariable(String name,
Object value)
Sets the value of a particular context variable. |
void |
setVariables(Map variables)
Sets context variables. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Object bean
private Map variables
private Log log
Log
named org.apache.commons.betwixt
Constructor Detail |
---|
public Context()
public Context(Object bean, Log log)
bean
- evaluate expressions against this beanlog
- log to this loggerpublic Context(Object bean, Map variables, Log log)
bean
- evaluate expressions against this beanvariables
- context variableslog
- log to this loggerMethod Detail |
---|
public Context newContext(Object newBean)
newBean
- create a child context for this bean
public Object getBean()
public void setBean(Object bean)
bean
- the Object against which expressions will be evaluatedpublic Map getVariables()
public void setVariables(Map variables)
variables
- map containing variable values indexed by varibable name Stringspublic Object getVariable(String name)
name
- the name of the variable whose value is to be returned
public void setVariable(String name, Object value)
name
- the name of the variablevalue
- the value of the variablepublic Log getLog()
public void setLog(Log log)
log
- the implemetation that this class should log to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |