Package org.jboss.logmanager.formatters

## Interface StructuredFormatter.Generator

Enclosing class:
  StructuredFormatter

    protected static interface StructuredFormatter.Generator

A generator used to create the structured output.

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`default StructuredFormatter.Generator` `add​(java.lang.String key, int value)` Writes an integer value.
`default StructuredFormatter.Generator` `add​(java.lang.String key, long value)` Writes a long value.
`StructuredFormatter.Generator` `add​(java.lang.String key, java.lang.String value)` Writes a string value.
`StructuredFormatter.Generator` `add​(java.lang.String key, java.util.Map<java.lang.String,?> value)` Writes a map value
`default StructuredFormatter.Generator` `addAttribute​(java.lang.String name, int value)` Writes an attribute.
`default StructuredFormatter.Generator` `addAttribute​(java.lang.String name, java.lang.String value)` Writes an attribute.
`default StructuredFormatter.Generator` `addMetaData​(java.util.Map<java.lang.String,java.lang.String> metaData)` Adds the meta data to the structured format.
`default StructuredFormatter.Generator` `begin()` Initial method invoked at the start of the generation.
`StructuredFormatter.Generator` `end()` Writes any trailing data that's needed.
`default StructuredFormatter.Generator` `endArray()` Writes an end for an array.
`StructuredFormatter.Generator` `endObject()` Writes an end to the object.
`default StructuredFormatter.Generator` `startArray​(java.lang.String key)` Writes the start of an array.
`StructuredFormatter.Generator` `startObject​(java.lang.String key)` Writes the start of an object.
`default boolean` `wrapArrays()` Indicates whether or not elements in an array should be wrapped or not.

### Method Detail

#### begin

    default StructuredFormatter.Generator begin()
                                         throws java.lang.Exception

Initial method invoked at the start of the generation.

Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### add

    default StructuredFormatter.Generator add​(java.lang.String key,
                                              int value)
                                       throws java.lang.Exception

Writes an integer value.

Parameters:
  `key` - they key
  `value` - the value
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### add

    default StructuredFormatter.Generator add​(java.lang.String key,
                                              long value)
                                       throws java.lang.Exception

Writes a long value.

Parameters:
  `key` - they key
  `value` - the value
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### add

    StructuredFormatter.Generator add​(java.lang.String key,
                                      java.util.Map<java.lang.String,?> value)
                               throws java.lang.Exception

Writes a map value

Parameters:
  `key` - the key for the map
  `value` - the map
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### add

    StructuredFormatter.Generator add​(java.lang.String key,
                                      java.lang.String value)
                               throws java.lang.Exception

Writes a string value.

Parameters:
  `key` - the key for the value
  `value` - the string value
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### addMetaData

    default StructuredFormatter.Generator addMetaData​(java.util.Map<java.lang.String,java.lang.String> metaData)
                                               throws java.lang.Exception

Adds the meta data to the structured format.

By default this processes the map and uses `add(String, String)` to add entries.

Parameters:
  `metaData` - the matp of the meta data, cannot be `null`
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### startObject

    StructuredFormatter.Generator startObject​(java.lang.String key)
                                       throws java.lang.Exception

Writes the start of an object.

If the `wrapArrays()` returns `false` the key may be `null` and implementations should handle this.

Parameters:
  `key` - they key for the object, or `null` if this object was started in an array and the `wrapArrays()` is `false`
Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### endObject

    StructuredFormatter.Generator endObject()
                                     throws java.lang.Exception

Writes an end to the object.

Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data

#### startArray

    default StructuredFormatter.Generator startArray​(java.lang.String key)
                                              throws java.lang.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:
  `java.lang.Exception` - if an error occurs while adding the data

#### endArray

    default StructuredFormatter.Generator endArray()
                                            throws java.lang.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:
  `java.lang.Exception` - if an error occurs while adding the data

#### addAttribute

    default StructuredFormatter.Generator addAttribute​(java.lang.String name,
                                                       int value)
                                                throws java.lang.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:
  `java.lang.Exception` - if an error occurs while adding the data

#### addAttribute

    default StructuredFormatter.Generator addAttribute​(java.lang.String name,
                                                       java.lang.String value)
                                                throws java.lang.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:
  `java.lang.Exception` - if an error occurs while adding the data

#### end

    StructuredFormatter.Generator end()
                               throws java.lang.Exception

Writes any trailing data that's needed.

Returns:
  the generator
Throws:
  `java.lang.Exception` - if an error occurs while adding the data during the build

#### 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`