public class RhinoScriptableModel extends java.lang.Object implements TemplateHashModelEx, TemplateSequenceModel, AdapterTemplateModel, TemplateScalarModel, TemplateBooleanModel, TemplateNumberModel
NOTHINGEMPTY_STRINGFALSE, TRUE| Constructor and Description |
|---|
RhinoScriptableModel(org.mozilla.javascript.Scriptable scriptable,
BeansWrapper wrapper) |
| Modifier and Type | Method and Description |
|---|---|
TemplateModel |
get(int index)
Retrieves the i-th template model in this sequence.
|
TemplateModel |
get(java.lang.String key)
Gets a TemplateModel from the hash.
|
java.lang.Object |
getAdaptedObject(java.lang.Class hint)
Retrieves the underlying object, or some other object semantically
equivalent to its value narrowed by the class hint.
|
boolean |
getAsBoolean() |
java.lang.Number |
getAsNumber()
Returns the numeric value.
|
java.lang.String |
getAsString()
Returns the string representation of this model.
|
boolean |
isEmpty() |
TemplateCollectionModel |
keys() |
int |
size() |
TemplateCollectionModel |
values() |
public RhinoScriptableModel(org.mozilla.javascript.Scriptable scriptable,
BeansWrapper wrapper)
public TemplateModel get(java.lang.String key) throws TemplateModelException
TemplateHashModelget in interface TemplateHashModelkey - the name by which the TemplateModel
is identified in the template.TemplateModelExceptionpublic TemplateModel get(int index) throws TemplateModelException
TemplateSequenceModelget in interface TemplateSequenceModelnull if
the index is out of bounds. Note that a null value is
interpreted by FreeMarker as "variable does not exist", and accessing
a missing variables is usually considered as an error in the FreeMarker
Template Language, so the usage of a bad index will not remain hidden.TemplateModelExceptionpublic boolean isEmpty()
isEmpty in interface TemplateHashModelpublic TemplateCollectionModel keys() throws TemplateModelException
keys in interface TemplateHashModelExTemplateScalarModel
(as the keys of hashes are always strings).TemplateModelExceptionpublic int size()
size in interface TemplateHashModelExsize in interface TemplateSequenceModelpublic TemplateCollectionModel values() throws TemplateModelException
values in interface TemplateHashModelExTemplateModel-s.TemplateModelExceptionpublic boolean getAsBoolean()
getAsBoolean in interface TemplateBooleanModelpublic java.lang.Number getAsNumber()
TemplateNumberModelgetAsNumber in interface TemplateNumberModelNumber instance associated with this number model.public java.lang.String getAsString()
TemplateScalarModelnull, as that will cause exception.
(In classic-compatible mode the engine will convert null into empty string, though.)getAsString in interface TemplateScalarModelpublic java.lang.Object getAdaptedObject(java.lang.Class hint)
AdapterTemplateModelgetAdaptedObject in interface AdapterTemplateModelhint - the desired class of the returned value. An implementation
should make reasonable effort to retrieve an object of the requested
class, but if that is impossible, it must at least return the underlying
object as-is. As a minimal requirement, an implementation must always
return the exact underlying object when
hint.isInstance(underlyingObject) == true holds. When called
with java.lang.Object.class, it should return a generic Java
object (i.e. if the model is wrapping a scripting language object that is
further wrapping a Java object, the deepest underlying Java object should
be returned).