|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.clearsilver.jsilver.data.DefaultDataContext
public class DefaultDataContext
This is the basic implementation of the DataContext. It stores the root Data node and a stack of Data objects that hold local variables. By definition, local variables are limited to single HDF names, with no '.' allowed. We use this to limit our search in the stack for the first occurence of the first chunk in the variable name.
Constructor Summary | |
---|---|
DefaultDataContext(Data data)
|
Method Summary | |
---|---|
void |
createLocalVariableByPath(String name,
String path)
Creates a local variable that references a (possibly non-existent) Data node. |
void |
createLocalVariableByValue(String name,
String value)
Creates and sets a local variable in the current scope equal to the given value. |
void |
createLocalVariableByValue(String name,
String value,
boolean isFirst,
boolean isLast)
Creates and sets a local variable in the current scope equal to the given value. |
void |
createLocalVariableByValue(String name,
String value,
EscapeMode mode)
Creates and sets a local variable in the current scope equal to the given value. |
Data |
findVariable(String name,
boolean create)
Searches the variable map stack for the specified variable name. |
EscapeMode |
findVariableEscapeMode(String name)
Searches the variable map stack for the specified variable name, and returns its EscapeMode . |
Data |
getRootData()
Returns the main Data object this RenderingContext was defined with. |
void |
popVariableScope()
Removes the current variable scope and references to the variables in it. |
void |
pushVariableScope()
Starts a new variable scope. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultDataContext(Data data)
Method Detail |
---|
public Data getRootData()
DataContext
getRootData
in interface DataContext
public void pushVariableScope()
pushVariableScope
in interface DataContext
public void popVariableScope()
pushVariableScope()
has been called.
popVariableScope
in interface DataContext
public void createLocalVariableByValue(String name, String value)
DataContext
createLocalVariableByValue
in interface DataContext
name
- the name of the local variable to fetch or create.value
- The String value to store at the local variable.public void createLocalVariableByValue(String name, String value, EscapeMode mode)
DataContext
createLocalVariableByValue
in interface DataContext
name
- the name of the local variable to fetch or create.value
- The String value to store at the local variable.mode
- EscapeMode that describes the escaping this variable has. EscapeMode.ESCAPE_NONE
if the variable was not escaped. EscapeMode.ESCAPE_IS_CONSTANT
if the variable was populated with a string or numeric
literal.public void createLocalVariableByValue(String name, String value, boolean isFirst, boolean isLast)
DataContext
This method is a helper method for supporting the first() and last() functions on loops without requiring loops create a full Data tree.
createLocalVariableByValue
in interface DataContext
name
- the name of the local variable to fetch or create.value
- The String value to store at the local variable.isFirst
- What the local variable should return for
Data.isFirstSibling()
isLast
- What the local variable should return for
Data.isLastSibling()
public void createLocalVariableByPath(String name, String path)
DataContext
null
, if it does not exist. If DataContext.findVariable(java.lang.String, boolean)
is called with create ==
true
, then if no Data object exists at the path location, it will be created.
createLocalVariableByPath
in interface DataContext
name
- the name of the local variable to fetch or create.path
- The path to the Data objectpublic Data findVariable(String name, boolean create)
DataContext
true
, then a new node is created
with the given name in the root Data object and that node is returned.
Note: This only creates nodes in the root Data object, not in any local variable map. To do
that, use the Data node returned by DataContext.pushVariableScope()
.
findVariable
in interface DataContext
name
- the name of the variable to find and/or create.create
- if true
then a new node will be created if an existing Data node with the
given name does not exist.
null
if no such node
exists and create
is false
.public EscapeMode findVariableEscapeMode(String name)
DataContext
EscapeMode
.
findVariableEscapeMode
in interface DataContext
EscapeMode
, otherwise returns EscapeMode.ESCAPE_NONE
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |