Class PlainTextOutputFormat


public final class PlainTextOutputFormat extends OutputFormat
Represents the plain text output format (MIME type "text/plain", name "plainText"). This format doesn't support escaping. This format doesn't allow mixing in template output values of other output formats.

The main difference from UndefinedOutputFormat is that this format doesn't allow inserting values of another output format into itself (unless they can be converted to plain text), while UndefinedOutputFormat would just insert the foreign "markup" as is. Also, this format has {"text/plain"} MIME type, while UndefinedOutputFormat has null.

  • Field Details

  • Method Details

    • isOutputFormatMixingAllowed

      public boolean isOutputFormatMixingAllowed()
      Description copied from class: OutputFormat
      Tells if this output format allows inserting TemplateMarkupOutputModel-s of another output formats into it.

      If true, the foreign TemplateMarkupOutputModel will be inserted into the output. If the current output format is a MarkupOutputFormat this is done using the MarkupOutputFormat.outputForeign(TemplateMarkupOutputModel, Writer) method, which can implement smart conversions. The default behavior (and the only behavior for non-markup outputs) is to behave as if the surrounding output format was the same; this is usually a bad idea to allow, as such an event could indicate application bugs.

      If this method returns false (recommended), then FreeMarker will try to assimilate the inserted value by converting its format to this format, which will currently (2.3.24) cause exception, unless the inserted value is made by escaping plain text and the target format is non-escaping, in which case format conversion is trivially possible. (It's not impossible that conversions will be extended beyond this, if there will be demand for that.)

      true value is used by UndefinedOutputFormat.

      Specified by:
      isOutputFormatMixingAllowed in class OutputFormat
    • getName

      public String getName()
      Description copied from class: OutputFormat
      The short name used to refer to this format (like in the #ftl header).
      Specified by:
      getName in class OutputFormat
    • getMimeType

      public String getMimeType()
      Description copied from class: OutputFormat
      Returns the MIME type of the output format. This might comes handy when generating a HTTP response. null null if this output format doesn't clearly corresponds to a specific MIME type.
      Specified by:
      getMimeType in class OutputFormat