java.lang.Object
org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

@Beta public final class JsonParserStream extends Object implements Closeable, Flushable
This class parses JSON elements from a GSON JsonReader. It disallows multiple elements of the same name unlike the default GSON JsonParser.
  • Method Details

    • create

      public static @NonNull JsonParserStream create(@NonNull org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter writer, @NonNull JSONCodecFactory codecFactory)
      Create a new JsonParserStream backed by specified NormalizedNodeStreamWriter and JSONCodecFactory. The stream will be logically rooted at the top of the SchemaContext associated with the specified codec factory.
      Parameters:
      writer - NormalizedNodeStreamWriter to use for instantiation of normalized nodes
      codecFactory - JSONCodecFactory to use for parsing leaves
      Returns:
      A new JsonParserStream
      Throws:
      NullPointerException - if any of the arguments are null
    • create

      public static @NonNull JsonParserStream create(@NonNull org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter writer, @NonNull JSONCodecFactory codecFactory, @NonNull org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference parentNode)
      Create a new JsonParserStream backed by specified NormalizedNodeStreamWriter and JSONCodecFactory. The stream will be logically rooted at the specified parent node.
      Parameters:
      writer - NormalizedNodeStreamWriter to use for instantiation of normalized nodes
      codecFactory - JSONCodecFactory to use for parsing leaves
      parentNode - Logical root node
      Returns:
      A new JsonParserStream
      Throws:
      NullPointerException - if any of the arguments are null
    • createLenient

      public static @NonNull JsonParserStream createLenient(@NonNull org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter writer, @NonNull JSONCodecFactory codecFactory)
      Create a new JsonParserStream backed by specified NormalizedNodeStreamWriter and JSONCodecFactory. The stream will be logically rooted at the top of the SchemaContext associated with the specified codec factory.

      Returned parser will treat incoming JSON data leniently:

      • JSON elements referring to unknown constructs will be silently ignored
      Parameters:
      writer - NormalizedNodeStreamWriter to use for instantiation of normalized nodes
      codecFactory - JSONCodecFactory to use for parsing leaves
      Returns:
      A new JsonParserStream
      Throws:
      NullPointerException - if any of the arguments are null
    • createLenient

      public static @NonNull JsonParserStream createLenient(@NonNull org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter writer, @NonNull JSONCodecFactory codecFactory, @NonNull org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference parentNode)
      Create a new JsonParserStream backed by specified NormalizedNodeStreamWriter and JSONCodecFactory. The stream will be logically rooted at the specified parent node.

      Returned parser will treat incoming JSON data leniently:

      • JSON elements referring to unknown constructs will be silently ignored
      Parameters:
      writer - NormalizedNodeStreamWriter to use for instantiation of normalized nodes
      codecFactory - JSONCodecFactory to use for parsing leaves
      parentNode - Logical root node
      Returns:
      A new JsonParserStream
      Throws:
      NullPointerException - if any of the arguments are null
    • parse

      public JsonParserStream parse(com.google.gson.stream.JsonReader reader)
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException