de.caff.io.json

## Class SimpleJsonReader.ValueHandler

- java.lang.Object
- - de.caff.io.json.SimpleJsonReader.ValueHandler

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

      public abstract static class SimpleJsonReader.ValueHandler
      extends java.lang.Object
      implements SimpleJsonReader.Handler

  Handler which just reads a single value.

  This is not expected to be used as a sub handler, but as the initial handler to read a complete JSON file. Because most JSON files just contain an object the only method which has to be implemented is `object()` which should return a dedicated `SimpleJsonReader.ObjectHandler`. If other types of JSON data can appear override the associated methods which by default will throw exceptions when called.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValueHandler()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected SimpleJsonReader.TemporaryHandler` | `array()` Called when the beginning of an array value was read.
    `void` | `beginArray(SimpleJsonReader reader)` Called when an array is started.
    `void` | `beginObject(SimpleJsonReader reader)` Called when an object is started.
    `void` | `endArray(SimpleJsonReader reader)` Called when an array has ended.
    `void` | `endObject(SimpleJsonReader reader)` Called when an object has ended.
    `void` | `key(SimpleJsonReader reader, java.lang.String key)` Called when a key ways read.
    `protected void` | `nullValue()` Read a null value.
    `void` | `nullValue(SimpleJsonReader reader)` Called when a null value was read.
    `protected abstract SimpleJsonReader.TemporaryHandler` | `object()` Called when the beginning of an object value was read.
    `protected void` | `value(boolean v)` Read a boolean value.
    `protected void` | `value(java.lang.Number v)` Read a number value.
    `void` | `value(SimpleJsonReader reader, boolean v)` Called when a boolean value was read.
    `void` | `value(SimpleJsonReader reader, java.lang.Number v)` Called when a number value was read.
    `void` | `value(SimpleJsonReader reader, java.lang.String v)` Called when a text value was read.
    `protected void` | `value(java.lang.String v)` Read a string value.

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

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

- - ### Constructor Detail

    - #### ValueHandler

          public ValueHandler()

  - ### Method Detail

    - #### key

          public void key(@NotNull
                          SimpleJsonReader reader,
                          @NotNull
                          java.lang.String key)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when a key ways read. Next is either a value, a SimpleJsonReader.Handler.beginObject(SimpleJsonReader), or SimpleJsonReader.Handler.beginArray(SimpleJsonReader) .
      Specified by:
        `key` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the key
        `key` - the value of the key

    - #### beginObject

          public void beginObject(@NotNull
                                  SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when an object is started. Next is either a SimpleJsonReader.Handler.key(SimpleJsonReader, String) or an SimpleJsonReader.Handler.endObject(SimpleJsonReader).
      Specified by:
        `beginObject` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which is reading the object

    - #### endObject

          public void endObject(@NotNull
                                SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when an object has ended.
      Specified by:
        `endObject` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the object

    - #### beginArray

          public void beginArray(@NotNull
                                 SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when an array is started.
      Specified by:
        `beginArray` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which is reading the array

    - #### endArray

          public void endArray(@NotNull
                               SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when an array has ended.
      Specified by:
        `endArray` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the array

    - #### nullValue

          public void nullValue(@NotNull
                                SimpleJsonReader reader)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when a null value was read.
      Specified by:
        `nullValue` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the value

    - #### value

          public void value(@NotNull
                            SimpleJsonReader reader,
                            @NotNull
                            java.lang.String v)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when a text value was read.
      Specified by:
        `value` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the value
        `v` - text value

    - #### value

          public void value(@NotNull
                            SimpleJsonReader reader,
                            boolean v)

      Description copied from interface: `SimpleJsonReader.Handler`
      Called when a boolean value was read.
      Specified by:
        `value` in interface `SimpleJsonReader.Handler`
      Parameters:
        `reader` - reader which has read the value
        `v` - boolean value

    - #### value

          public void value(@NotNull
                            SimpleJsonReader reader,
                            @NotNull
                            java.lang.Number v)

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

    - #### object

          @NotNull
          protected abstract SimpleJsonReader.TemporaryHandler object()

      Called when 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, and 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.
      Returns:
        dedicated reader for the object, usually an `SimpleJsonReader.ObjectHandler`

    - #### array

          @NotNull
          protected SimpleJsonReader.TemporaryHandler array()

      Called when 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.

      Has to be overridden if an array is a valid value. This default implementation will throw an `IllegalStateException`.

      Returns:
        dedicated reader for the object, usually an `SimpleJsonReader.ArrayHandler`

    - #### nullValue

          protected void nullValue()

      Read a null value. Has to be overridden if null is a valid value. This default implementation will throw an `IllegalStateException`.

    - #### value

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

      Read a string value. Has to be overridden if a string is a valid value. This default implementation will throw an `IllegalStateException`.
      Parameters:
        `v` - string value

    - #### value

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

      Read a number value. Has to be overridden if a number is a valid value. This default implementation will throw an `IllegalStateException`.
      Parameters:
        `v` - number value, implementation will either use `Integer` or `Double`

    - #### value

          protected void value(boolean v)

      Read a boolean value. Has to be overridden if a boolean is a valid value. This default implementation will throw an `IllegalStateException`.
      Parameters:
        `v` - boolean value