|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.ext.misc.AsString
public final class AsString
Performs a type conversion from a number model to a String model. This is useful when we need to perform String concatenation on two numbers, or when we only want a number from a multimodel.
Usage:
From java:
TemplateModelRoot root = new SimpleHash(); root.put( "asString", freemarker.ext.misc.AsString.getInstance() ); ...
From your FM-Classic template:
<assign var1 = 5>
<assign var2 = 3>
<assign var3 = asString( var1 ) + asString( var2 )>
<p>The concatenation of ${var1} and ${var2} is: ${var3}</p>
...
Note:
AsString is a singleton instance. Use the
getInstance() method to retrieve instances of this model.
| Method Summary | |
|---|---|
TemplateModel |
exec(java.util.List<TemplateModel> arguments)
Perform a number to string conversion on the given template model. |
static AsString |
getInstance()
Retrieve a singleton instance of this class. |
boolean |
isEmpty()
Is this model empty? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static AsString getInstance()
AsString class
public TemplateModel exec(java.util.List<TemplateModel> arguments)
throws TemplateModelException
exec in interface TemplateMethodModel2arguments - a List of exactly one template model to be converted
TemplateScalarModel of the String value
TemplateModelException - More than one argument is supplied,
or the model is neither a number nor a string model.
public boolean isEmpty()
throws TemplateModelException
isEmpty in interface TemplateModelfalse, to indicate the model is non-empty
TemplateModelException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||