public abstract class JsonProvider extends Object
All the methods in this class are safe for use by multiple concurrent threads.
ServiceLoader
Modifier | Constructor and Description |
---|---|
protected |
JsonProvider() |
Modifier and Type | Method and Description |
---|---|
abstract JsonArrayBuilder |
createArrayBuilder()
Creates a JSON array builder.
|
JsonArrayBuilder |
createArrayBuilder(Collection<?> collection)
Creates a JSON array builder, initialized with the content of specified
collection . |
JsonArrayBuilder |
createArrayBuilder(JsonArray array)
Creates a JSON array builder, initialized with the specified array.
|
abstract JsonBuilderFactory |
createBuilderFactory(Map<String,?> config)
Creates a builder factory for creating
JsonArrayBuilder
and JsonObjectBuilder objects. |
JsonPatch |
createDiff(JsonStructure source,
JsonStructure target)
Generates a JSON Patch (RFC 6902)
from the source and target
JsonStructure . |
abstract JsonGenerator |
createGenerator(OutputStream out)
Creates a JSON generator for writing JSON text to a byte stream.
|
abstract JsonGenerator |
createGenerator(Writer writer)
Creates a JSON generator for writing JSON text to a character stream.
|
abstract JsonGeneratorFactory |
createGeneratorFactory(Map<String,?> config)
Creates a generator factory for creating
JsonGenerator instances. |
JsonMergePatch |
createMergeDiff(JsonValue source,
JsonValue target)
Generates a JSON Merge Patch (RFC 7396)
from the source and target
JsonValue s
which when applied to the source , yields the target . |
JsonMergePatch |
createMergePatch(JsonValue patch)
Creates JSON Merge Patch (RFC 7396)
from specified
JsonValue . |
abstract JsonObjectBuilder |
createObjectBuilder()
Creates a JSON object builder.
|
JsonObjectBuilder |
createObjectBuilder(JsonObject object)
Creates a JSON object builder, initialized with the specified object.
|
JsonObjectBuilder |
createObjectBuilder(Map<String,Object> map)
Creates a JSON object builder, initialized with the data from specified
map . |
abstract JsonParser |
createParser(InputStream in)
Creates a JSON parser from the specified byte stream.
|
abstract JsonParser |
createParser(Reader reader)
Creates a JSON parser from a character stream.
|
abstract JsonParserFactory |
createParserFactory(Map<String,?> config)
Creates a parser factory for creating
JsonParser instances. |
JsonPatch |
createPatch(JsonArray array)
Creates a JSON Patch (RFC 6902)
from the specified operations.
|
JsonPatchBuilder |
createPatchBuilder()
Creates a JSON Patch builder (RFC 6902).
|
JsonPatchBuilder |
createPatchBuilder(JsonArray array)
Creates a JSON Patch builder
(RFC 6902),
initialized with the specified operations.
|
JsonPointer |
createPointer(String jsonPointer)
Creates JSON Pointer (RFC 6901)
from given
jsonPointer string. |
abstract JsonReader |
createReader(InputStream in)
Creates a JSON reader from a byte stream.
|
abstract JsonReader |
createReader(Reader reader)
Creates a JSON reader from a character stream.
|
abstract JsonReaderFactory |
createReaderFactory(Map<String,?> config)
Creates a reader factory for creating
JsonReader objects. |
JsonNumber |
createValue(BigDecimal value)
Creates a JsonNumber.
|
JsonNumber |
createValue(BigInteger value)
Creates a JsonNumber.
|
JsonNumber |
createValue(double value)
Creates a JsonNumber.
|
JsonNumber |
createValue(int value)
Creates a JsonNumber.
|
JsonNumber |
createValue(long value)
Creates a JsonNumber.
|
JsonString |
createValue(String value)
Creates a JsonString.
|
abstract JsonWriter |
createWriter(OutputStream out)
|
abstract JsonWriter |
createWriter(Writer writer)
|
abstract JsonWriterFactory |
createWriterFactory(Map<String,?> config)
Creates a writer factory for creating
JsonWriter objects. |
static JsonProvider |
provider()
Creates a JSON provider object.
|
public static JsonProvider provider()
ServiceLoader.load(Class)
method. If there are no available
service providers, this method returns the default service provider.
Users are recommended to cache the result of this method.ServiceLoader
public abstract JsonParser createParser(Reader reader)
reader
- i/o reader from which JSON is to be readpublic abstract JsonParser createParser(InputStream in)
in
- i/o stream from which JSON is to be readJsonException
- if encoding cannot be determined
or i/o error (IOException would be cause of JsonException)public abstract JsonParserFactory createParserFactory(Map<String,?> config)
JsonParser
instances.
The factory is configured with the specified map of
provider specific configuration properties. Provider implementations
should ignore any unsupported configuration properties specified in
the map.config
- a map of provider specific properties to configure the
JSON parsers. The map may be empty or nullpublic abstract JsonGenerator createGenerator(Writer writer)
writer
- a i/o writer to which JSON is writtenpublic abstract JsonGenerator createGenerator(OutputStream out)
out
- i/o stream to which JSON is writtenpublic abstract JsonGeneratorFactory createGeneratorFactory(Map<String,?> config)
JsonGenerator
instances.
The factory is configured with the specified map of provider specific
configuration properties. Provider implementations should
ignore any unsupported configuration properties specified in the map.config
- a map of provider specific properties to configure the
JSON generators. The map may be empty or nullpublic abstract JsonReader createReader(Reader reader)
reader
- a reader from which JSON is to be readpublic abstract JsonReader createReader(InputStream in)
in
- a byte stream from which JSON is to be readpublic abstract JsonWriter createWriter(Writer writer)
writer
- to which JSON object or array is writtenpublic abstract JsonWriter createWriter(OutputStream out)
object
or array
structure to the specified byte stream. Characters written to
the stream are encoded into bytes using UTF-8 encoding.out
- to which JSON object or array is writtenpublic abstract JsonWriterFactory createWriterFactory(Map<String,?> config)
JsonWriter
objects.
The factory is configured with the specified map of provider specific
configuration properties. Provider implementations should ignore any
unsupported configuration properties specified in the map.config
- a map of provider specific properties to configure the
JSON writers. The map may be empty or nullpublic abstract JsonReaderFactory createReaderFactory(Map<String,?> config)
JsonReader
objects.
The factory is configured with the specified map of provider specific
configuration properties. Provider implementations should ignore any
unsupported configuration properties specified in the map.config
- a map of provider specific properties to configure the
JSON readers. The map may be empty or nullpublic abstract JsonObjectBuilder createObjectBuilder()
public JsonObjectBuilder createObjectBuilder(JsonObject object)
object
- the initial JSON object in the builderpublic JsonObjectBuilder createObjectBuilder(Map<String,Object> map)
map
.
If the @{code map} contains Optional
s then resulting JSON object builder
contains the key from the map
only if the Optional
is not empty.map
- the initial object in the builderIllegalArgumentException
- if the value from the map
cannot be converted
to the corresponding JsonValue
public abstract JsonArrayBuilder createArrayBuilder()
public JsonArrayBuilder createArrayBuilder(JsonArray array)
array
- the initial JSON array in the builderpublic JsonPointer createPointer(String jsonPointer)
jsonPointer
string.
jsonPointer
string defines a reference to the target itself.jsonPointer
string is non-empty, it must be a sequence of '/
' prefixed tokens.jsonPointer
- the JSON Pointer stringNullPointerException
- if jsonPointer
is null
JsonException
- if jsonPointer
is not a valid JSON Pointerpublic JsonPatchBuilder createPatchBuilder()
public JsonPatchBuilder createPatchBuilder(JsonArray array)
array
- the initial patch operationspublic JsonPatch createPatch(JsonArray array)
array
- patch operationspublic JsonPatch createDiff(JsonStructure source, JsonStructure target)
JsonStructure
.
The generated JSON Patch need not be unique.source
- the sourcetarget
- the target, must be the same type as the sourcepublic JsonMergePatch createMergePatch(JsonValue patch)
JsonValue
.patch
- the patchpublic JsonMergePatch createMergeDiff(JsonValue source, JsonValue target)
JsonValue
s
which when applied to the source
, yields the target
.source
- the sourcetarget
- the targetpublic JsonArrayBuilder createArrayBuilder(Collection<?> collection)
collection
.
If the @{code collection} contains Optional
s then resulting JSON array builder
contains the value from the collection
only if the Optional
is not empty.collection
- the initial data for the builderIllegalArgumentException
- if the value from the collection
cannot be converted
to the corresponding JsonValue
public abstract JsonBuilderFactory createBuilderFactory(Map<String,?> config)
JsonArrayBuilder
and JsonObjectBuilder
objects.
The factory is configured with the specified map of provider specific
configuration properties. Provider implementations should ignore any
unsupported configuration properties specified in the map.config
- a map of provider specific properties to configure the
JSON builders. The map may be empty or nullpublic JsonString createValue(String value)
value
- a JSON stringpublic JsonNumber createValue(int value)
value
- a JSON numberpublic JsonNumber createValue(long value)
value
- a JSON numberpublic JsonNumber createValue(double value)
value
- a JSON numberpublic JsonNumber createValue(BigDecimal value)
value
- a JSON numberpublic JsonNumber createValue(BigInteger value)
value
- a JSON numberCopyright © 2018,2020 Eclipse Foundation.
Use is subject to license terms.