- java.lang.Object
-
- jakarta.json.spi.JsonProvider
-
- org.glassfish.json.JsonProviderImpl
-
public class JsonProviderImpl extends JsonProvider
- Author:
- Jitendra Kotamraju, Kin-man Chung, Alex Soto
-
-
Constructor Summary
Constructors Constructor Description JsonProviderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArrayBuilder
createArrayBuilder()
Creates a JSON array builder.JsonArrayBuilder
createArrayBuilder(JsonArray array)
Creates a JSON array builder, initialized with the specified array.JsonArrayBuilder
createArrayBuilder(Collection<?> collection)
Creates a JSON array builder, initialized with the content of specifiedcollection
.JsonBuilderFactory
createBuilderFactory(Map<String,?> config)
Creates a builder factory for creatingJsonArrayBuilder
andJsonObjectBuilder
objects.JsonPatch
createDiff(JsonStructure source, JsonStructure target)
Generates a JSON Patch (RFC 6902) from the source and targetJsonStructure
.JsonGenerator
createGenerator(OutputStream out)
Creates a JSON generator for writing JSON text to a byte stream.JsonGenerator
createGenerator(Writer writer)
Creates a JSON generator for writing JSON text to a character stream.JsonGeneratorFactory
createGeneratorFactory(Map<String,?> config)
Creates a generator factory for creatingJsonGenerator
instances.JsonMergePatch
createMergeDiff(JsonValue source, JsonValue target)
Generates a JSON Merge Patch (RFC 7396) from the source and targetJsonValue
s which when applied to thesource
, yields thetarget
.JsonMergePatch
createMergePatch(JsonValue patch)
Creates JSON Merge Patch (RFC 7396) from specifiedJsonValue
.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 specifiedmap
.JsonParser
createParser(InputStream in)
Creates a JSON parser from the specified byte stream.JsonParser
createParser(Reader reader)
Creates a JSON parser from a character stream.JsonParserFactory
createParserFactory(Map<String,?> config)
Creates a parser factory for creatingJsonParser
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 givenjsonPointer
string.JsonReader
createReader(InputStream in)
Creates a JSON reader from a byte stream.JsonReader
createReader(Reader reader)
Creates a JSON reader from a character stream.JsonReaderFactory
createReaderFactory(Map<String,?> config)
Creates a reader factory for creatingJsonReader
objects.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.JsonNumber
createValue(BigDecimal value)
Creates a JsonNumber.JsonNumber
createValue(BigInteger value)
Creates a JsonNumber.JsonWriter
createWriter(OutputStream out)
JsonWriter
createWriter(Writer writer)
JsonWriterFactory
createWriterFactory(Map<String,?> config)
Creates a writer factory for creatingJsonWriter
objects.-
Methods inherited from class jakarta.json.spi.JsonProvider
provider
-
-
-
-
Method Detail
-
createGenerator
public JsonGenerator createGenerator(Writer writer)
Description copied from class:JsonProvider
Creates a JSON generator for writing JSON text to a character stream.- Specified by:
createGenerator
in classJsonProvider
- Parameters:
writer
- a i/o writer to which JSON is written- Returns:
- a JSON generator
-
createGenerator
public JsonGenerator createGenerator(OutputStream out)
Description copied from class:JsonProvider
Creates a JSON generator for writing JSON text to a byte stream.- Specified by:
createGenerator
in classJsonProvider
- Parameters:
out
- i/o stream to which JSON is written- Returns:
- a JSON generator
-
createParser
public JsonParser createParser(Reader reader)
Description copied from class:JsonProvider
Creates a JSON parser from a character stream.- Specified by:
createParser
in classJsonProvider
- Parameters:
reader
- i/o reader from which JSON is to be read- Returns:
- a JSON parser
-
createParser
public JsonParser createParser(InputStream in)
Description copied from class:JsonProvider
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 7159 .- Specified by:
createParser
in classJsonProvider
- Parameters:
in
- i/o stream from which JSON is to be read- Returns:
- a JSON parser
-
createParserFactory
public JsonParserFactory createParserFactory(Map<String,?> config)
Description copied from class:JsonProvider
Creates a parser factory for creatingJsonParser
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.- Specified by:
createParserFactory
in classJsonProvider
- Parameters:
config
- a map of provider specific properties to configure the JSON parsers. The map may be empty or null- Returns:
- a JSON parser factory
-
createGeneratorFactory
public JsonGeneratorFactory createGeneratorFactory(Map<String,?> config)
Description copied from class:JsonProvider
Creates a generator factory for creatingJsonGenerator
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.- Specified by:
createGeneratorFactory
in classJsonProvider
- Parameters:
config
- a map of provider specific properties to configure the JSON generators. The map may be empty or null- Returns:
- a JSON generator factory
-
createReader
public JsonReader createReader(Reader reader)
Description copied from class:JsonProvider
Creates a JSON reader from a character stream.- Specified by:
createReader
in classJsonProvider
- Parameters:
reader
- a reader from which JSON is to be read- Returns:
- a JSON reader
-
createReader
public JsonReader createReader(InputStream in)
Description copied from class:JsonProvider
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.- Specified by:
createReader
in classJsonProvider
- Parameters:
in
- a byte stream from which JSON is to be read- Returns:
- a JSON reader
-
createWriter
public JsonWriter createWriter(Writer writer)
Description copied from class:JsonProvider
- Specified by:
createWriter
in classJsonProvider
- Parameters:
writer
- to which JSON object or array is written- Returns:
- a JSON writer
-
createWriter
public JsonWriter createWriter(OutputStream out)
Description copied from class:JsonProvider
Creates a JSON writer to write a JSONobject
orarray
structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.- Specified by:
createWriter
in classJsonProvider
- Parameters:
out
- to which JSON object or array is written- Returns:
- a JSON writer
-
createWriterFactory
public JsonWriterFactory createWriterFactory(Map<String,?> config)
Description copied from class:JsonProvider
Creates a writer factory for creatingJsonWriter
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.- Specified by:
createWriterFactory
in classJsonProvider
- Parameters:
config
- a map of provider specific properties to configure the JSON writers. The map may be empty or null- Returns:
- a JSON writer factory
-
createReaderFactory
public JsonReaderFactory createReaderFactory(Map<String,?> config)
Description copied from class:JsonProvider
Creates a reader factory for creatingJsonReader
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.- Specified by:
createReaderFactory
in classJsonProvider
- Parameters:
config
- a map of provider specific properties to configure the JSON readers. The map may be empty or null- Returns:
- a JSON reader factory
-
createObjectBuilder
public JsonObjectBuilder createObjectBuilder()
Description copied from class:JsonProvider
Creates a JSON object builder.- Specified by:
createObjectBuilder
in classJsonProvider
- Returns:
- a JSON object builder
-
createObjectBuilder
public JsonObjectBuilder createObjectBuilder(JsonObject object)
Description copied from class:JsonProvider
Creates a JSON object builder, initialized with the specified object.- Overrides:
createObjectBuilder
in classJsonProvider
- Parameters:
object
- the initial JSON object in the builder- Returns:
- a JSON object builder
-
createObjectBuilder
public JsonObjectBuilder createObjectBuilder(Map<String,Object> map)
Description copied from class:JsonProvider
Creates a JSON object builder, initialized with the data from specifiedmap
. If the @{code map} containsOptional
s then resulting JSON object builder contains the key from themap
only if theOptional
is not empty.- Overrides:
createObjectBuilder
in classJsonProvider
- Parameters:
map
- the initial object in the builder- Returns:
- a JSON object builder
-
createArrayBuilder
public JsonArrayBuilder createArrayBuilder()
Description copied from class:JsonProvider
Creates a JSON array builder.- Specified by:
createArrayBuilder
in classJsonProvider
- Returns:
- a JSON array builder
-
createArrayBuilder
public JsonArrayBuilder createArrayBuilder(JsonArray array)
Description copied from class:JsonProvider
Creates a JSON array builder, initialized with the specified array.- Overrides:
createArrayBuilder
in classJsonProvider
- Parameters:
array
- the initial JSON array in the builder- Returns:
- a JSON array builder
-
createArrayBuilder
public JsonArrayBuilder createArrayBuilder(Collection<?> collection)
Description copied from class:JsonProvider
Creates a JSON array builder, initialized with the content of specifiedcollection
. If the @{code collection} containsOptional
s then resulting JSON array builder contains the value from thecollection
only if theOptional
is not empty.- Overrides:
createArrayBuilder
in classJsonProvider
- Parameters:
collection
- the initial data for the builder- Returns:
- a JSON array builder
-
createPointer
public JsonPointer createPointer(String jsonPointer)
Description copied from class:JsonProvider
Creates JSON Pointer (RFC 6901) from givenjsonPointer
string.- An empty
jsonPointer
string defines a reference to the target itself. - If the
jsonPointer
string is non-empty, it must be a sequence of '/
' prefixed tokens.
- Overrides:
createPointer
in classJsonProvider
- Parameters:
jsonPointer
- the JSON Pointer string- Returns:
- a JSON Pointer
- An empty
-
createPatchBuilder
public JsonPatchBuilder createPatchBuilder()
Description copied from class:JsonProvider
Creates a JSON Patch builder (RFC 6902).- Overrides:
createPatchBuilder
in classJsonProvider
- Returns:
- a JSON Patch builder
-
createPatchBuilder
public JsonPatchBuilder createPatchBuilder(JsonArray array)
Description copied from class:JsonProvider
Creates a JSON Patch builder (RFC 6902), initialized with the specified operations.- Overrides:
createPatchBuilder
in classJsonProvider
- Parameters:
array
- the initial patch operations- Returns:
- a JSON Patch builder
-
createPatch
public JsonPatch createPatch(JsonArray array)
Description copied from class:JsonProvider
Creates a JSON Patch (RFC 6902) from the specified operations.- Overrides:
createPatch
in classJsonProvider
- Parameters:
array
- patch operations- Returns:
- a JSON Patch
-
createDiff
public JsonPatch createDiff(JsonStructure source, JsonStructure target)
Description copied from class:JsonProvider
Generates a JSON Patch (RFC 6902) from the source and targetJsonStructure
. The generated JSON Patch need not be unique.- Overrides:
createDiff
in classJsonProvider
- Parameters:
source
- the sourcetarget
- the target, must be the same type as the source- Returns:
- a JSON Patch which when applied to the source, yields the target
-
createMergePatch
public JsonMergePatch createMergePatch(JsonValue patch)
Description copied from class:JsonProvider
Creates JSON Merge Patch (RFC 7396) from specifiedJsonValue
.- Overrides:
createMergePatch
in classJsonProvider
- Parameters:
patch
- the patch- Returns:
- a JSON Merge Patch
-
createMergeDiff
public JsonMergePatch createMergeDiff(JsonValue source, JsonValue target)
Description copied from class:JsonProvider
Generates a JSON Merge Patch (RFC 7396) from the source and targetJsonValue
s which when applied to thesource
, yields thetarget
.- Overrides:
createMergeDiff
in classJsonProvider
- Parameters:
source
- the sourcetarget
- the target- Returns:
- a JSON Merge Patch
-
createValue
public JsonString createValue(String value)
Description copied from class:JsonProvider
Creates a JsonString.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON string- Returns:
- the JsonString for the string
-
createValue
public JsonNumber createValue(int value)
Description copied from class:JsonProvider
Creates a JsonNumber.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON number- Returns:
- the JsonNumber for the number
-
createValue
public JsonNumber createValue(long value)
Description copied from class:JsonProvider
Creates a JsonNumber.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON number- Returns:
- the JsonNumber for the number
-
createValue
public JsonNumber createValue(double value)
Description copied from class:JsonProvider
Creates a JsonNumber.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON number- Returns:
- the JsonNumber for the number
-
createValue
public JsonNumber createValue(BigInteger value)
Description copied from class:JsonProvider
Creates a JsonNumber.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON number- Returns:
- the JsonNumber for the number
-
createValue
public JsonNumber createValue(BigDecimal value)
Description copied from class:JsonProvider
Creates a JsonNumber.- Overrides:
createValue
in classJsonProvider
- Parameters:
value
- a JSON number- Returns:
- the JsonNumber for the number
-
createBuilderFactory
public JsonBuilderFactory createBuilderFactory(Map<String,?> config)
Description copied from class:JsonProvider
Creates a builder factory for creatingJsonArrayBuilder
andJsonObjectBuilder
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.- Specified by:
createBuilderFactory
in classJsonProvider
- Parameters:
config
- a map of provider specific properties to configure the JSON builders. The map may be empty or null- Returns:
- a JSON builder factory
-
-