Interface JsonSettings


public interface JsonSettings
Settings for json output rendering. The current default version is version 1.0. CAUTION: This class is still in development and may change drastically without any further notice.
Since:
5.2.190507
  • Field Details

    • VERSION_0_2

      @Internal static final String VERSION_0_2
      JSON Format-Version 0.2. A Pre-Release-Version.
      See Also:
    • VERSION_1_0

      static final String VERSION_1_0
      JSON Format-Version 1.0. The first released version.
      Since:
      5.2.191206
      See Also:
    • VERSION_1_1

      static final String VERSION_1_1
      JSON Format-Version 1.1. This version introduces Full PageRef Rendering, which outputs the PageRef entirely and references the page instead of copying most of the Page attributes.
      Since:
      5.2.200205
      See Also:
    • VERSION_1_2

      static final String VERSION_1_2
      JSON Format-Version 1.2. This version introduces dom property config rendering
      Since:
      5.2.210904
      See Also:
  • Method Details

    • create

      @NotNull @Internal static @NotNull JsonSettings create()
      Create a new default JsonSettings object.
      Returns:
      new JsonSettings instance
    • isPrettyPrinting

      @ApiDoc(since="5.2.190507", comment="Retrieve the pretty printing setting for json output.") boolean isPrettyPrinting()
      Returns the prettyPrinting setting.
      Returns:
      true if pretty printing is enabled, false otherwise
      Since:
      5.2.190507
    • setPrettyPrinting

      @NotNull @ApiDoc(since="5.2.190507", comment="Switch pretty printing on/off.") @NotNull JsonSettings setPrettyPrinting(boolean value)
      Turns the prettyPrinting setting on or off. If pretty printing is set to false no whitespaces will be added, making it the best option for data transfers. If pretty printing is true then the json output will be rendered more readable for humans using indentations and other whitespace for the json output.
      Parameters:
      value - the new setting for prettyPrinting
      Since:
      5.2.190507
    • getFormatVersion

      @ApiDoc(since="5.2.191206", comment="Retrieve the current json format version.") @NotNull @NotNull String getFormatVersion()
      Returns the json format setting.
      Returns:
      the numeric json format version
      Since:
      5.2.191206
    • setFormatVersion

      @ApiDoc(since="5.2.191206", comment="Set the json format version string.") @NotNull @NotNull JsonSettings setFormatVersion(@NotNull @NotNull String formatVersion)
      Sets the json format version for rendering. Different json formats may structure data differently.
      Since:
      5.2.191206
    • isSectionTemplateRendering

      @ApiDoc(since="5.2.191206", comment="Retrieve the SectionTemplateRendering setting for json output.") boolean isSectionTemplateRendering()
      Returns the section template rendering setting.
      Returns:
      true if section template rendering is enabled, false otherwise
      Since:
      5.2.191206
    • setSectionTemplateRendering

      @ApiDoc(since="5.2.191206", comment="Set section template rendering on/off.") @NotNull @NotNull JsonSettings setSectionTemplateRendering(boolean sectionTemplateRendering)
      Turns the template rendering for Section type elements on or off. If template rendering is set to true the template of every Section is evaluated and the template result is the json output. If section template rendering is false the default section rendering will be active and render the section as a simple JsonObject with its form data.
      Parameters:
      sectionTemplateRendering - the value to set
      Since:
      5.2.191206
    • isMetaDataRendering

      @ApiDoc(since="5.2.191206", comment="Retrieve the MetaDataRendering setting for json output.") boolean isMetaDataRendering()
      Returns the meta FormData rendering setting.
      Returns:
      true if meta data rendering is enabled, false otherwise
      Since:
      5.2.191206
    • setMetaDataRendering

      @ApiDoc(since="5.2.191206", comment="Set meta data rendering on/off.") @NotNull @NotNull JsonSettings setMetaDataRendering(boolean metaDataRendering)
      Turns the meta data for elements on or off. If meta data rendering is true the json output will contain a 'metaFormData' attribute containing the meta data.
      Parameters:
      metaDataRendering - the value to set
      Since:
      5.2.191206
    • setDataRenderDepth

      @NotNull @ApiDoc(since="5.2.191206", comment="Set the renderdepth for datasets.") @NotNull JsonSettings setDataRenderDepth(int dataRenderDepth)
      Sets the render depth of linked Datasets in the JsonOutput.
      • 0: all Dataset instances in the output are rendered as a reference
      • 1: Dataset instances in the output are rendered in full but Datasets in the hierarchy are rendered as reference
      • 2: Dataset instances in the output hierarchy that have two or more Dataset parents are rendered as a reference... and so on
      Parameters:
      dataRenderDepth - the value to set
      Since:
      5.2.191206
    • getDataRenderDepth

      @ApiDoc(since="5.2.191206", comment="Retrieve the renderdepth for datasets.") int getDataRenderDepth()
      Returns the set data render depth.
      Returns:
      the set data render depth
      Since:
      5.2.191206
    • setOutputLengthLimit

      @Experimental JsonSettings setOutputLengthLimit(int limit)
      Set the length limit of the generated JSON output. If the limit is exceeded, the JSON rendering will throw an IOException. The default limit is Integer.MAX_VALUE.
      Parameters:
      limit - The length limit for the generated JSON output.
      Since:
      5.2.230506
    • getOutputLenthLimit

      @Experimental int getOutputLenthLimit()
      Get the length limit of the generated JSON output. If the limit is exceeded, an exception will be thrown. The default limit is Integer.MAX_VALUE.
      Returns:
      The length limit for the generated JSON output.
      Since:
      5.2.230506
    • setTemplateAttributeRendering

      @NotNull @Internal @NotNull JsonSettings setTemplateAttributeRendering(boolean enabled)
      Sets the template attribute output setting on or off. If true all TemplateProvider elements will render the optional "template" attribute describing the template the element is based on.
      Parameters:
      enabled - the value to set.
    • isTemplateAttributeRendering

      @Internal boolean isTemplateAttributeRendering()
      Get the current attribute output setting. Defaults to true
      Returns:
      true if the template attribute is rendered, false otherwise
    • getHtmlTemplateProvider

      @Nullable @Internal @Nullable de.espirit.firstspirit.generate.functions.json.HtmlTemplateProvider getHtmlTemplateProvider()
      Get the currently set HtmlTemplateProvider. Null by default.
      Returns:
      the current HtmlTemplateProvider or null if none is set.
    • setHtmlTemplateProvider

      @Internal void setHtmlTemplateProvider(@Nullable @Nullable de.espirit.firstspirit.generate.functions.json.HtmlTemplateProvider htmlTemplateProvider)
      Provides means to inject arbitrary templates into the JSON rendering. The format templates returned by the set htmlTemplateProvider are used instead of the defined project format templates. This function was specifically developed to allow CMS_INPUT_DOM JSON Rendering without the need to maintain templates in a project.
      Parameters:
      htmlTemplateProvider - the HtmlTemplateProvider to set.
    • getUseDefaultHtmlTemplateProvider

      @Internal boolean getUseDefaultHtmlTemplateProvider()
      Check if the current HtmlTemplateProvider is the DefaultHtmlTemplateProvider and return the result.
      Returns:
      true if the current HtmlTemplateProvider is the DefaultHtmlTemplateProvider, false otherwise
    • setUseDefaultHtmlTemplateProvider

      @Internal JsonSettings setUseDefaultHtmlTemplateProvider(boolean setUseDefaultHtmlTemplateProvider)
      Shortcut for setting the DefaultHtmlTemplateProvider as the current htmlTemplateProvider on or off.
      Parameters:
      setUseDefaultHtmlTemplateProvider - the HtmlTemplateProvider to set.
    • isResolveDynamicContent

      @Internal boolean isResolveDynamicContent()
      Get the current resolve dynamic content setting. Defaults to true.
      Returns:
      true if dynamic content is resolved and rendered, false otherwise
    • setResolveDynamicContent

      @Internal JsonSettings setResolveDynamicContent(boolean enabled)
      Sets the resolve dynamic content setting. This setting refers to the rendering of Content2Sections. By default this setting is true and the dynamic content of Content2Sections is resolved. In that case the Content2Section template is used to render all data, that can be derived from the current State of the PageRef via its Content2Params.
      If set to false, the Content2Sections will be rendered as a placeholder reference, meaning it contains information with which the content can be retrieved, instead of the content itself. A client may then use the placeholder information to retrieve the actual content at a later time.
      Parameters:
      enabled - the value to set
    • setNonDisplayedSectionsRendering

      void setNonDisplayedSectionsRendering(boolean shouldRenderNonDisplayedSections)
      Sets the NonDisplayedSectionsRendering-parameter NonDisplayedSectionsRendering indicates whether non-displayed Section should be rendered
      Parameters:
      shouldRenderNonDisplayedSections - true non displayed Section will be included in JSON-Output
      Since:
      5.2.210102
    • getNonDisplayedSectionsRendering

      boolean getNonDisplayedSectionsRendering()
      Gets the NonDisplayedSectionsRendering-parameter NonDisplayedSectionsRendering indicates whether non displayed Section should be rendered
      Returns:
      true non displayed Section will be included in JSON-Output
      Since:
      5.2.210102
    • setMetaInheritanceRendering

      void setMetaInheritanceRendering(boolean metaInheritanceRendering)
      Activates or deactivates the rendering of inherited meta data values. If this setting is set to true, the rendered meta data will include values from the parent hierarchy. If this setting is set to false, only the meta data from the current element will be rendered.
      Parameters:
      metaInheritanceRendering -
      Since:
      5.2.210409
    • isMetaInheritanceRendering

      boolean isMetaInheritanceRendering()
      Gets the current MetaInheritanceRendering-Setting
      Returns:
      metaInheritanceRendering
      Since:
      5.2.210409