|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.template.LocalModelWrapper
public class LocalModelWrapper
Wraps a template hash model with a template model root. The hash model
can be accessed transparently from the root of this model. Any local
variables are stored within the supplied Map
. Anything that
doesn't exist within the Map
is automatically forwarded
to the wrapped global model. Local variables are counted as being all
variables contained in the localModel
parameter of the
constructor method.
Use this class when you want a well-defined distinction between global and local variables.
RootModelWrapper
,
Serialized FormField Summary | |
---|---|
protected TemplateWriteableHashModel |
globalModel
The underlying root model being wrapped. |
protected java.util.Map<java.lang.String,TemplateModel> |
localModel
The map containing local values for the root model. |
Constructor Summary | |
---|---|
LocalModelWrapper(TemplateWriteableHashModel globalModel,
java.util.Map<java.lang.String,TemplateModel> localModel)
Create a new RootModelWrapper with the given
hash model as the model to be wrapped. |
Method Summary | |
---|---|
TemplateModel |
get(java.lang.String key)
Retrieve a template model for the given key, if one exists. |
boolean |
isEmpty()
Returns whether we have a completely empty model. |
void |
put(java.lang.String key,
TemplateModel model)
Put the given template model into storage with the given key. |
void |
reset()
Clear all the local variables from the local storage, and just provide pass-through access to the wrapped hash model. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<java.lang.String,TemplateModel> localModel
protected TemplateWriteableHashModel globalModel
Constructor Detail |
---|
public LocalModelWrapper(TemplateWriteableHashModel globalModel, java.util.Map<java.lang.String,TemplateModel> localModel)
RootModelWrapper
with the given
hash model as the model to be wrapped.
globalModel
- the root model to be wrappedlocalModel
- a Map containing the pre-populated local variablesMethod Detail |
---|
public TemplateModel get(java.lang.String key) throws TemplateModelException
get
in interface TemplateHashModel
key
- the name of the value to be returned
null
TemplateModelException
- there was a problem with the underlying
hash modelpublic boolean isEmpty() throws TemplateModelException
false
. Otherwise, forward
the call to the global model.
isEmpty
in interface TemplateModel
true
if the model is empty, otherwise false
TemplateModelException
- there was a problem with underlying
hash modelpublic void put(java.lang.String key, TemplateModel model) throws TemplateModelException
put
in interface TemplateWriteableHashModel
key
- the name of the model to be storedmodel
- the model being stored
TemplateModelException
- there was a problem setting the value
for the given keypublic void reset()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |