Interface StructuredFormatter.Generator

  • Enclosing class:
    StructuredFormatter

    protected static interface StructuredFormatter.Generator
    A generator used to create the structured output.
    • Method Detail

      • startArray

        default StructuredFormatter.Generator startArray​(String key)
                                                  throws Exception
        Writes the start of an array. This defaults to startObject(String) for convenience of generators that don't have a specific type for arrays.
        Parameters:
        key - they key for the array
        Returns:
        the generator
        Throws:
        Exception - if an error occurs while adding the data
      • endArray

        default StructuredFormatter.Generator endArray()
                                                throws Exception
        Writes an end for an array. This defaults to endObject() for convenience of generators that don't have a specific type for arrays.
        Returns:
        the generator
        Throws:
        Exception - if an error occurs while adding the data
      • addAttribute

        default StructuredFormatter.Generator addAttribute​(String name,
                                                           int value)
                                                    throws Exception
        Writes an attribute.

        By default this uses the add(String, int) method to add the attribute. If a formatter requires special handling for attributes, for example an attribute on an XML element, this method can be overridden.

        Parameters:
        name - the name of the attribute
        value - the value of the attribute
        Returns:
        the generator
        Throws:
        Exception - if an error occurs while adding the data
      • addAttribute

        default StructuredFormatter.Generator addAttribute​(String name,
                                                           String value)
                                                    throws Exception
        Writes an attribute.

        By default this uses the add(String, String) method to add the attribute. If a formatter requires special handling for attributes, for example an attribute on an XML element, this method can be overridden.

        Parameters:
        name - the name of the attribute
        value - the value of the attribute
        Returns:
        the generator
        Throws:
        Exception - if an error occurs while adding the data
      • wrapArrays

        default boolean wrapArrays()
        Indicates whether or not elements in an array should be wrapped or not. The default is false.
        Returns:
        true if elements should be wrapped, otherwise false