de.caff.io.json

## Class SimpleJsonReader.MapObjectHandler

- java.lang.Object
- - de.caff.io.json.SimpleJsonReader.ObjectHandler
  - - de.caff.io.json.SimpleJsonReader.MapObjectHandler

- All Implemented Interfaces:
    SimpleJsonReader.Handler, SimpleJsonReader.TemporaryHandler
  Enclosing class:
    SimpleJsonReader

      public static class SimpleJsonReader.MapObjectHandler
      extends SimpleJsonReader.ObjectHandler

  Map object handler which collects the JSON data into a Java map. Map keys are strings. Allowed map values are
  - `null`
  - `String`
  - `Boolean`
  - `Number`, either `Double` or `Integer`
  - `Object[]`, where each element is one of the allowed values
  - `Map<String, Object>`, where again each value is one of the allowed values
  See Also:
    `SimpleJsonReader.readToMap(Reader)`, `SimpleJsonReader.readToMap(InputStream, Charset)`, `SimpleJsonReader.readToMap(InputStream)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapObjectHandler()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected SimpleJsonReader.TemporaryHandler` | `arrayValue(java.lang.String key)` Called when a key with the beginning of an array value was read.
    `void` | `finish(SimpleJsonReader reader)` Called once after the handler is used.
    `java.util.Map<java.lang.String,java.lang.Object>` | `getMap()`
    `void` | `initialize(SimpleJsonReader reader)` Called once before the handler is used.
    `protected void` | `nullValue(java.lang.String key)` Called when a null value was read.
    `protected SimpleJsonReader.TemporaryHandler` | `objectValue(java.lang.String key)` Called when a key with the beginning of an object value was read.
    `protected void` | `value(java.lang.String key, boolean v)` Called when a boolean value was read.
    `protected void` | `value(java.lang.String key, java.lang.Number v)` Called when a number value was read.
    `protected void` | `value(java.lang.String key, java.lang.String v)` Called when a text value was read.

    - ### Methods inherited from class de.caff.io.json.SimpleJsonReader.ObjectHandler

      `beginArray, beginObject, endArray, endObject, key, nullValue, value, value, value`

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

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

- - ### Constructor Detail

    - #### MapObjectHandler

          public MapObjectHandler()

  - ### Method Detail

    - #### initialize

          public void initialize(@NotNull
                                 SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.TemporaryHandler`
      Called once before the handler is used.
      Parameters:
        `reader` - JSON reader access

    - #### finish

          public void finish(@NotNull
                             SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.TemporaryHandler`
      Called once after the handler is used.
      Parameters:
        `reader` - JSON reader access

    - #### objectValue

          @NotNull
          protected SimpleJsonReader.TemporaryHandler objectValue(@NotNull
                                                                           java.lang.String key)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a key with the beginning of an object value was read. Expected to return a dedicated reader which is used to read the content of the object. The handler will be initialized with its `SimpleJsonReader.TemporaryHandler.initialize(SimpleJsonReader)` method, then be used to handle the key-value pairs inside the object. When the object is finished, the handler's `SimpleJsonReader.TemporaryHandler.finish(SimpleJsonReader)` method is called.

      If the key is unsupported either throw an exception or return `SimpleJsonReader.SKIP_HANDLER` which will ignore the object.

      Specified by:
        `objectValue` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the object is read
      Returns:
        dedicated reader for the object, usually another `SimpleJsonReader.ObjectHandler`

    - #### arrayValue

          @NotNull
          protected SimpleJsonReader.TemporaryHandler arrayValue(@NotNull
                                                                          java.lang.String key)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a key with the beginning of an array value was read. Expected to return a dedicated reader which is used to read the content of the array. The handler will be initialized with its `SimpleJsonReader.TemporaryHandler.initialize(SimpleJsonReader)` method, then be used to handle the key-value pairs inside the object. When the object is finished, the handler's `SimpleJsonReader.TemporaryHandler.finish(SimpleJsonReader)` method is called.

      If the key is unsupported either throw an exception or return `SimpleJsonReader.SKIP_HANDLER` which will ignore the object.

      Specified by:
        `arrayValue` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the object is read
      Returns:
        dedicated reader for the object, usually an `SimpleJsonReader.ArrayHandler`

    - #### nullValue

          protected void nullValue(@NotNull
                                   java.lang.String key)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a null value was read.
      Specified by:
        `nullValue` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the null was read

    - #### value

          protected void value(@NotNull
                               java.lang.String key,
                               @NotNull
                               java.lang.String v)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a text value was read.
      Specified by:
        `value` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the text value was read
        `v` - text value

    - #### value

          protected void value(@NotNull
                               java.lang.String key,
                               boolean v)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a boolean value was read.
      Specified by:
        `value` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the boolean value was read
        `v` - boolean value

    - #### value

          protected void value(@NotNull
                               java.lang.String key,
                               @NotNull
                               java.lang.Number v)

      Description copied from class: `SimpleJsonReader.ObjectHandler`
      Called when a number value was read.
      Specified by:
        `value` in class `SimpleJsonReader.ObjectHandler`
      Parameters:
        `key` - key for which the number value was read
        `v` - number value, implementation will provide either an `Integer` (if fit), or a `Double`

    - #### getMap

          @NotNull
          public java.util.Map<java.lang.String,java.lang.Object> getMap()