public class DefaultDataContext extends Object implements DataContext
| Constructor and Description |
|---|
DefaultDataContext(Data data) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public DefaultDataContext(Data data)
public Data getRootData()
DataContextgetRootData in interface DataContextpublic void pushVariableScope()
pushVariableScope in interface DataContextpublic void popVariableScope()
pushVariableScope() has been called.popVariableScope in interface DataContextpublic void createLocalVariableByValue(String name, String value)
DataContextcreateLocalVariableByValue in interface DataContextname - 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)
DataContextcreateLocalVariableByValue in interface DataContextname - 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)
DataContextThis 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 DataContextname - 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)
DataContextnull, 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 DataContextname - the name of the local variable to fetch or create.path - The path to the Data objectpublic Data findVariable(String name, boolean create)
DataContexttrue, 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 DataContextname - 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)
DataContextEscapeMode.findVariableEscapeMode in interface DataContextEscapeMode, otherwise returns EscapeMode.ESCAPE_NONE.Copyright © 2010–2016 Google. All rights reserved.