SimpleScalar (FreeMarker 2.3.23 API)
Date: 2015-07-05

freemarker.template

## Class SimpleScalar

- java.lang.Object
- - freemarker.template.SimpleScalar

- All Implemented Interfaces:
    TemplateModel, TemplateScalarModel, Serializable

      public final class SimpleScalar
      extends Object
      implements TemplateScalarModel, Serializable

  A simple implementation of the `TemplateScalarModel` interface, using a `String`. As of version 2.0 this object is immutable.

  This class is thread-safe.

  See Also:
    `SimpleSequence`, `SimpleHash`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface freemarker.template.TemplateScalarModel

      `EMPTY_STRING`

    - ### Fields inherited from interface freemarker.template.TemplateModel

      `NOTHING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleScalar(String value)` Constructs a `SimpleScalar` containing a string value.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getAsString()` Returns the string representation of this model.
    `static SimpleScalar` | `newInstanceOrNull(String s)` Same as calling the constructor, except that for a `null` parameter it returns null.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SimpleScalar

          public SimpleScalar(String value)

      Constructs a `SimpleScalar` containing a string value.
      Parameters:
        `value` - the string value. If this is `null`, its value in FTL will be `""`.

  - ### Method Detail

    - #### getAsString

          public String getAsString()

      Description copied from interface: `TemplateScalarModel`
      Returns the string representation of this model. Don't return `null`, as that will cause exception. (In classic-compatible mode the engine will convert `null` into empty string, though.)
      Specified by:
        `getAsString` in interface `TemplateScalarModel`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### newInstanceOrNull

          public static SimpleScalar newInstanceOrNull(String s)

      Same as calling the constructor, except that for a `null` parameter it returns null.
      Since:
        2.3.23