パッケージ com.shimizukenta.jsonhub

インタフェース JsonHub

すべてのスーパーインタフェース:
java.lang.Iterable<JsonHub>

public interface JsonHub
extends java.lang.Iterable<JsonHub>
This interface is implements of JSON(RFC 8259) converter, parser, builder, prettyPrint.
関連項目:
JsonHubBuilder, JsonHubPrettyPrinter
  • メソッドの概要

    修飾子とタイプ メソッド 説明
    default boolean booleanValue()
    Returns boolean value if type is TRUE or FALSE.
    boolean containsKey​(java.lang.CharSequence name)
    Returns true if contains name in Object.
    default double doubleValue()
    Returns double value if type is NUMBER.
    void forEach​(java.util.function.BiConsumer<? super JsonString,​? super JsonHub> action)
    forEach operation if type is OBJECT or ARRAY.
    void forEach​(java.util.function.Consumer<? super JsonHub> action)
    forEach operation if type is OBJECT or ARRAY.
    static JsonHub fromBytes​(byte[] bs)
    Returns parsed JsonHub instance from JSON-UTF8-bytes-array.
    static JsonHub fromBytes​(java.io.InputStream strm)
    Returns parsed JsonHub instance from JSON-UTF8-bytes-stream.
    static JsonHub fromFile​(java.nio.file.Path path)
    Returns parsed JsonHub instance from read file.
    static JsonHub fromJson​(java.io.Reader reader)
    Returns parsed JaonHub from Reader.
    static JsonHub fromJson​(java.lang.CharSequence json)
    Returns JsonHub instance parsing from JSON-String.
    static JsonHub fromPojo​(java.lang.Object pojo)
    Returns JsonHub instance parsing from POJO (Plain-Old-Java-Object).
    JsonHub get​(int index)
    Returns value in Array by index.
    JsonHub get​(java.lang.CharSequence name)
    Returns JsonHub OBJECT-value instance if Object has same-name, and null otherwise.
    JsonHub get​(java.lang.String... names)
    Returns JsonHub instance, seek chains in Object by names, If seek failed, return null.
    static JsonHubBuilder getBuilder()
    Returns JsonHubBuilder.
    byte[] getBytes()
    Returns UTF-8 encorded bytes.
    byte[] getBytesExcludedNullValueInObject()
    Returns UTF-8 encorded bytes excluded null value in Object.
    JsonHub getOrDefault​(java.lang.CharSequence name)
    Returns JsonHub instance, seek in Object name, if not exist, return empty-ObjectJsonHub.
    JsonHub getOrDefault​(java.lang.CharSequence name, JsonHub defaultValue)
    Returns JsonHub instance, seek in Object name, if not exist, return defaultValue.
    default int intValue()
    Returns int value if type is NUMBER.
    default boolean isArray()
    Returns true if type is ARRAY.
    default boolean isBoolean()
    Returns true if type is TRUE or FALSE.
    boolean isEmpty()
    Returns true if empty.
    default boolean isFalse()
    Returns true if type is FALSE.
    default boolean isNull()
    Returns true if type is NULL.
    default boolean isNumber()
    Returns true if type is NUMBER.
    default boolean isObject()
    Returns true if type is OBJECT.
    default boolean isString()
    Returns true if type is STRING.
    default boolean isTrue()
    Returns true if type is TRUE.
    java.util.Iterator<JsonHub> iterator()
    Returns iterator if type is OBJECT or ARRAY.
    default java.util.List<JsonHub> jsonPath​(java.lang.CharSequence jsonPath)
    Parse with JsonPath.
    java.util.Set<JsonString> keySet()
    Returns set of Object names.
    int length()
    Returns length if type is STRING or OBJECT or ARRAY.
    default long longValue()
    Returns long value if type is NUMBER.
    default boolean nonNull()
    Returns true if type is not null.
    java.util.Optional<java.lang.Boolean> optionalBoolean()
    Returns Optional, Optional has value if type is TRUE or FALSE, and Optional.empty() otherwise.
    java.util.OptionalDouble optionalDouble()
    Returns OptionalDouble, OptionalDouble has value if type is NUMBER, and OptionalDouble.empty() otherwise.
    java.util.OptionalInt optionalInt()
    Returns OptionalInt, OptionalInt has value if type is NUMBER, and OptionalInt.empty() otherwise.
    java.util.OptionalLong optionalLong()
    Returns OptionalLong, OptionalLong has value if type is NUMBER, and OptionalLong.empty() otherwise.
    java.util.Optional<java.lang.Number> optionalNubmer()
    Returns Optional, Optional has value if type is NUMBER, and Optional.empty() otherwise.
    java.util.Optional<java.lang.String> optionalString()
    Returns Optional, Optional has value if type is STRING, and Optional.empty() otherwise.
    default java.lang.String prettyPrint()
    Returns default format Pretty-Print-JSON.
    default java.lang.String prettyPrint​(JsonHubPrettyPrinterConfig config)
    Returns Pretty-Print-JSON with config format.
    default void prettyPrint​(java.io.Writer writer)
    Write default format Pretty-Print-JSON to writer
    default void prettyPrint​(java.io.Writer writer, JsonHubPrettyPrinterConfig config)
    Write Pretty-Print-JSON to writer with config format
    default void prettyPrint​(java.nio.file.Path path)
    Write default format Pretty-Print-JSON to File
    default void prettyPrint​(java.nio.file.Path path, JsonHubPrettyPrinterConfig config)
    Write Pretty-Print-JSON to File with config format
    default void prettyPrint​(java.nio.file.Path path, JsonHubPrettyPrinterConfig config, java.nio.file.OpenOption... options)
    Write Pretty-Print-JSON to File with config format
    default void prettyPrint​(java.nio.file.Path path, java.nio.file.OpenOption... options)
    Write default format Pretty-Print-JSON to File
    java.util.Spliterator<JsonHub> spliterator()
    Returns spliterator if type is OBJECT or ARRAY.
    java.util.stream.Stream<JsonHub> stream()
    Returns java.util.stream.Stream if type is OBJECT or ARRAY.
    java.lang.String toJson()
    Returns parsed compact-JSON-String
    void toJson​(java.io.Writer writer)
    Write compact-JSON-String to Writer
    java.lang.String toJsonExcludedNullValueInObject()
    Returns parsed compact-JSON-String exclude null value pair in Object;
    void toJsonExcludedNullValueInObject​(java.io.Writer writer)
    Returns parsed compact-JSON-String exclude null value pair in Object;
    default <T> T toPojo​(java.lang.Class<T> classOfT)
    Returns parsed instance of ClassOtT.
    JsonHubType type()
    Returns type, type is NULL, TRUE, FALSE, NUMBER, STRING, ARRAY or OBJECT.
    java.util.List<JsonHub> values()
    Returns list of values.
    void writeBytes​(java.io.OutputStream strm)
    Write UTF-8 encorded bytes to OutputStream
    void writeBytesExcludedNullValueInObject​(java.io.OutputStream strm)
    Write UTF-8 encorded bytes exclued null value in Object to OutputStream
    default void writeFile​(java.nio.file.Path path)
    Write to file.
    default void writeFile​(java.nio.file.Path path, java.nio.file.OpenOption... options)
    Write to file with options.
  • メソッドの詳細

    • iterator

      java.util.Iterator<JsonHub> iterator()
      Returns iterator if type is OBJECT or ARRAY.

      Available if type is ARRAY or OBJECT.
      If type is OBJECT, values is JsonHub.

      定義:
      iterator インタフェース内 java.lang.Iterable<JsonHub>
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • spliterator

      java.util.Spliterator<JsonHub> spliterator()
      Returns spliterator if type is OBJECT or ARRAY.

      Available if type is ARRAY or OBJECT.
      If type is OBJECT, value is JsonHub.

      定義:
      spliterator インタフェース内 java.lang.Iterable<JsonHub>
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • forEach

      void forEach​(java.util.function.Consumer<? super JsonHub> action)
      forEach operation if type is OBJECT or ARRAY.

      Available if type is OBJECT or ARRAY.
      If type is OBJECT, value is JsonHub.

      定義:
      forEach インタフェース内 java.lang.Iterable<JsonHub>
      パラメータ:
      action - Consumer
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • forEach

      void forEach​(java.util.function.BiConsumer<? super JsonString,​? super JsonHub> action)
      forEach operation if type is OBJECT or ARRAY.

      Available if type is OBJECT or ARRAY.
      If type is ARRAY, NAME is null.

      パラメータ:
      action - the BiConsumer
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • type

      JsonHubType type()
      Returns type, type is NULL, TRUE, FALSE, NUMBER, STRING, ARRAY or OBJECT.
      戻り値:
      JsonHubType
    • stream

      java.util.stream.Stream<JsonHub> stream()
      Returns java.util.stream.Stream if type is OBJECT or ARRAY.

      Available if type is OBJECT or ARRAY.
      If type is OBJECT, value is JsonHub.

      戻り値:
      Array values stream
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • keySet

      java.util.Set<JsonString> keySet()
      Returns set of Object names.

      Available if type is OBJECT.

      戻り値:
      set of Object names
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • values

      java.util.List<JsonHub> values()
      Returns list of values.

      Available if type is OBJECT or ARRAY.

      戻り値:
      list of values
      例外:
      JsonHubUnsupportedOperationException - if type is not (OBJECT or ARRAY)
    • get

      JsonHub get​(int index)
      Returns value in Array by index.

      Available if type is ARRAY.

      パラメータ:
      index - index of Array
      戻り値:
      value
      例外:
      JsonHubUnsupportedOperationException - if type is not ARRAY
    • containsKey

      boolean containsKey​(java.lang.CharSequence name)
      Returns true if contains name in Object.

      Available if type is OBJECT.
      Not accept null.

      パラメータ:
      name - name of Object
      戻り値:
      true if contains name in Object
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • get

      JsonHub get​(java.lang.CharSequence name)
      Returns JsonHub OBJECT-value instance if Object has same-name, and null otherwise.

      Available if type is OBJECT.
      Not accept null.

      パラメータ:
      name - name of Object
      戻り値:
      JsonHub value. null if has no same name.
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • getOrDefault

      JsonHub getOrDefault​(java.lang.CharSequence name)
      Returns JsonHub instance, seek in Object name, if not exist, return empty-ObjectJsonHub.

      Available if type is OBJECT

      パラメータ:
      name - name of Object
      戻り値:
      value, Empty-ObjectJsonHub instance if not exist
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • getOrDefault

      JsonHub getOrDefault​(java.lang.CharSequence name, JsonHub defaultValue)
      Returns JsonHub instance, seek in Object name, if not exist, return defaultValue.

      Available if type is OBJECT

      パラメータ:
      name - name of Object
      defaultValue - return this value if not exist.
      戻り値:
      value, defaultValue if not exist
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • get

      JsonHub get​(java.lang.String... names)
      Returns JsonHub instance, seek chains in Object by names, If seek failed, return null.

      Available if type is OBJECT-chains

      パラメータ:
      names - names of Object
      戻り値:
      value if exist and null otherwise
      例外:
      JsonHubUnsupportedOperationException - if type is not OBJECT
    • length

      int length()
      Returns length if type is STRING or OBJECT or ARRAY.

      Available if type is STRING or ARRAY or OBJECT

      If type is STRING return length of String.
      If type is ARRAY, return size of values.
      If type is OBJECT, return size of name-value-pairs.

      戻り値:
      length
      例外:
      JsonHubUnsupportedOperationException - if not (STRING or ARRAY or OBJECT)
    • isEmpty

      boolean isEmpty()
      Returns true if empty.

      Available if type is STRING or ARRAY or OBJECT.

      If type is STRING, return true if length is 0.
      If type is ARRAY, return true if Array is empty.
      If type is OBJECT, return true if Object-pairs is empty.

      戻り値:
      true if empty
      例外:
      JsonHubUnsupportedOperationException - if not (STRING or ARRAY or OBJECT)
    • isNull

      default boolean isNull()
      Returns true if type is NULL.
      戻り値:
      true if type is NULL
    • nonNull

      default boolean nonNull()
      Returns true if type is not null.
      戻り値:
      true if type is not NULL
    • isTrue

      default boolean isTrue()
      Returns true if type is TRUE.
      戻り値:
      true if type is TRUE
    • isFalse

      default boolean isFalse()
      Returns true if type is FALSE.
      戻り値:
      true if type is FALSE
    • isBoolean

      default boolean isBoolean()
      Returns true if type is TRUE or FALSE.
      戻り値:
      true if type is TRUE or FALSE
    • isString

      default boolean isString()
      Returns true if type is STRING.
      戻り値:
      true is type is STRING
    • isNumber

      default boolean isNumber()
      Returns true if type is NUMBER.
      戻り値:
      true if type is NUMBER
    • isArray

      default boolean isArray()
      Returns true if type is ARRAY.
      戻り値:
      true if type is ARRAY
    • isObject

      default boolean isObject()
      Returns true if type is OBJECT.
      戻り値:
      true if type is OBJECT
    • optionalBoolean

      java.util.Optional<java.lang.Boolean> optionalBoolean()
      Returns Optional, Optional has value if type is TRUE or FALSE, and Optional.empty() otherwise.
      戻り値:
      Optional has value if type is TRUE or FALSE, and Optional.empty() otherwise
    • optionalInt

      java.util.OptionalInt optionalInt()
      Returns OptionalInt, OptionalInt has value if type is NUMBER, and OptionalInt.empty() otherwise.
      戻り値:
      OptionalInt has value if type is NUMBER, and OptionalInt.empty() otherwise
    • optionalLong

      java.util.OptionalLong optionalLong()
      Returns OptionalLong, OptionalLong has value if type is NUMBER, and OptionalLong.empty() otherwise.
      戻り値:
      OptionalLong has value if type is NUMBER, and OptionalLong.empty() otherwise
    • optionalDouble

      java.util.OptionalDouble optionalDouble()
      Returns OptionalDouble, OptionalDouble has value if type is NUMBER, and OptionalDouble.empty() otherwise.
      戻り値:
      OptionalDouble has value if type is NUMBER, and OptionalDouble.empty() otherwise
    • optionalString

      java.util.Optional<java.lang.String> optionalString()
      Returns Optional, Optional has value if type is STRING, and Optional.empty() otherwise.
      戻り値:
      Optional has value if type is STRING, and Optional.empty() otherwise
    • optionalNubmer

      java.util.Optional<java.lang.Number> optionalNubmer()
      Returns Optional, Optional has value if type is NUMBER, and Optional.empty() otherwise.
      戻り値:
      Optional has value if type is NUMBER, and Optional.empty() otherwise
    • booleanValue

      default boolean booleanValue()
      Returns boolean value if type is TRUE or FALSE.

      Available if type is TRUE or FALSE

      戻り値:
      booleanValue
      例外:
      JsonHubUnsupportedOperationException - if type is not (TRUE or FALSE)
    • intValue

      default int intValue()
      Returns int value if type is NUMBER.

      Available if type is NUMBER.

      戻り値:
      intValue
      例外:
      JsonHubUnsupportedOperationException - if type is not NUMBER
    • longValue

      default long longValue()
      Returns long value if type is NUMBER.

      Available if type is NUMBER.

      戻り値:
      longValue
      例外:
      JsonHubUnsupportedOperationException - if type is not NUMBER
    • doubleValue

      default double doubleValue()
      Returns double value if type is NUMBER.

      Available if type is NUMBER.

      戻り値:
      doubleValue
      例外:
      JsonHubUnsupportedOperationException - if type is not NUMBER
    • getBuilder

      static JsonHubBuilder getBuilder()
      Returns JsonHubBuilder.
      戻り値:
      JsonHubBuilder instance
      関連項目:
      JsonHubBuilder
    • fromJson

      static JsonHub fromJson​(java.lang.CharSequence json)
      Returns JsonHub instance parsing from JSON-String.

      Not accept null.

      パラメータ:
      json - JSON-string
      戻り値:
      parsed JsonHub instance
      例外:
      JsonHubParseException - if parse failed
    • fromJson

      static JsonHub fromJson​(java.io.Reader reader) throws java.io.IOException
      Returns parsed JaonHub from Reader.
      パラメータ:
      reader - the reader
      戻り値:
      parsed JsonHub instance
      例外:
      java.io.IOException - if IO failed
      JsonHubParseException - if parse failed
    • toJson

      java.lang.String toJson()
      Returns parsed compact-JSON-String
      戻り値:
      json
    • toJson

      void toJson​(java.io.Writer writer) throws java.io.IOException
      Write compact-JSON-String to Writer
      パラメータ:
      writer - writer of JSON-string
      例外:
      java.io.IOException - if IO failed
    • toJsonExcludedNullValueInObject

      java.lang.String toJsonExcludedNullValueInObject()
      Returns parsed compact-JSON-String exclude null value pair in Object;
      戻り値:
      json of excluded null value pair in Object.
    • toJsonExcludedNullValueInObject

      void toJsonExcludedNullValueInObject​(java.io.Writer writer) throws java.io.IOException
      Returns parsed compact-JSON-String exclude null value pair in Object;
      パラメータ:
      writer - the writer
      例外:
      java.io.IOException - if IO failed
    • fromFile

      static JsonHub fromFile​(java.nio.file.Path path) throws java.io.IOException
      Returns parsed JsonHub instance from read file.
      パラメータ:
      path - of JSON file
      戻り値:
      parsed JsonHub instance
      例外:
      java.io.IOException - if IO failed
      JsonHubParseException - if JsonHub parse failed
    • writeFile

      default void writeFile​(java.nio.file.Path path) throws java.io.IOException
      Write to file.
      パラメータ:
      path - File-path
      例外:
      java.io.IOException - if IO failed
    • writeFile

      default void writeFile​(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
      Write to file with options.
      パラメータ:
      path - File-path
      options - file open options.
      例外:
      java.io.IOException - if IO failed
    • prettyPrint

      default java.lang.String prettyPrint()
      Returns default format Pretty-Print-JSON.
      戻り値:
      default format Pretty-Print-JSON
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default java.lang.String prettyPrint​(JsonHubPrettyPrinterConfig config)
      Returns Pretty-Print-JSON with config format.
      パラメータ:
      config - config of Pretty-Print-Format
      戻り値:
      Pretty-Print-JSON with config format
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.io.Writer writer) throws java.io.IOException
      Write default format Pretty-Print-JSON to writer
      パラメータ:
      writer - writer of JSON-string
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.io.Writer writer, JsonHubPrettyPrinterConfig config) throws java.io.IOException
      Write Pretty-Print-JSON to writer with config format
      パラメータ:
      writer - writer of JSON-string
      config - config of Pretty-Print-Format
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.nio.file.Path path) throws java.io.IOException
      Write default format Pretty-Print-JSON to File
      パラメータ:
      path - File-Path
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
      Write default format Pretty-Print-JSON to File
      パラメータ:
      path - File-Path
      options - OpenOptions
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.nio.file.Path path, JsonHubPrettyPrinterConfig config) throws java.io.IOException
      Write Pretty-Print-JSON to File with config format
      パラメータ:
      path - File-Path
      config - config of Pretty-Print-Format
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • prettyPrint

      default void prettyPrint​(java.nio.file.Path path, JsonHubPrettyPrinterConfig config, java.nio.file.OpenOption... options) throws java.io.IOException
      Write Pretty-Print-JSON to File with config format
      パラメータ:
      path - File-Path
      config - config of Pretty-Print-Format
      options - OpenOptions
      例外:
      java.io.IOException - if IO failed
      関連項目:
      JsonHubPrettyPrinter
    • fromPojo

      static JsonHub fromPojo​(java.lang.Object pojo)
      Returns JsonHub instance parsing from POJO (Plain-Old-Java-Object).
      パラメータ:
      pojo - (Plain-Old-Java-Object)
      戻り値:
      parsed JsonHub instance
      例外:
      JsonHubParseException - if parse failed
    • toPojo

      default <T> T toPojo​(java.lang.Class<T> classOfT)
      Returns parsed instance of ClassOtT.
      型パラメータ:
      T - Type
      パラメータ:
      classOfT - Class of Type
      戻り値:
      parsed POJO instance
      例外:
      JsonHubParseException - if parse failed
    • getBytes

      byte[] getBytes()
      Returns UTF-8 encorded bytes.
      戻り値:
      UTF-8 encorded bytes
    • writeBytes

      void writeBytes​(java.io.OutputStream strm) throws java.io.IOException
      Write UTF-8 encorded bytes to OutputStream
      パラメータ:
      strm - OutputStream
      例外:
      java.io.IOException - if IO failed
    • getBytesExcludedNullValueInObject

      byte[] getBytesExcludedNullValueInObject()
      Returns UTF-8 encorded bytes excluded null value in Object.
      戻り値:
      UTF-8 encorded bytes excluded null value in Object
    • writeBytesExcludedNullValueInObject

      void writeBytesExcludedNullValueInObject​(java.io.OutputStream strm) throws java.io.IOException
      Write UTF-8 encorded bytes exclued null value in Object to OutputStream
      パラメータ:
      strm - OutputStream
      例外:
      java.io.IOException - if IO failed
    • fromBytes

      static JsonHub fromBytes​(byte[] bs)
      Returns parsed JsonHub instance from JSON-UTF8-bytes-array.
      パラメータ:
      bs - JSON-UTF8-bytes-array
      戻り値:
      parsed JsonHub instance
      例外:
      JsonHubParseException - if parse failed
    • fromBytes

      static JsonHub fromBytes​(java.io.InputStream strm) throws java.io.IOException
      Returns parsed JsonHub instance from JSON-UTF8-bytes-stream.
      パラメータ:
      strm - JSON-UTF8-bytes-stream
      戻り値:
      parsed JsonHub instance
      例外:
      java.io.IOException - if IO failed
      JsonHubParseException - if parse failed
    • jsonPath

      default java.util.List<JsonHub> jsonPath​(java.lang.CharSequence jsonPath)
      Parse with JsonPath.
      パラメータ:
      jsonPath - the JsonPath
      戻り値:
      List of JsonHub