Package org.apache.felix.cm.json.io
Class Configurations
- java.lang.Object
-
- org.apache.felix.cm.json.io.Configurations
-
public class Configurations extends java.lang.Object
Factory class for JSON and configuration support
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConfigurationReader.Builder
buildReader()
Get a builder to create a configuration readerstatic ConfigurationWriter.Builder
buildWriter()
Get a builder to create a configuration writerstatic jakarta.json.JsonValue
convertToJsonValue(java.lang.Object value)
Convert an object to a JSON value.static java.lang.Object
convertToObject(jakarta.json.JsonValue value)
Convert a json value into an object.static java.io.Reader
jsonCommentAwareReader(java.io.Reader reader)
Create a reader handling comments in JSON.static java.util.Hashtable<java.lang.String,java.lang.Object>
newConfiguration()
Create a new map for configuration properties The returned map keeps the order of properties added and is using case-insensitive keys.
-
-
-
Method Detail
-
buildReader
public static ConfigurationReader.Builder buildReader()
Get a builder to create a configuration reader- Returns:
- A configuration reader builder
-
buildWriter
public static ConfigurationWriter.Builder buildWriter()
Get a builder to create a configuration writer- Returns:
- A configuration writer builder
-
jsonCommentAwareReader
public static java.io.Reader jsonCommentAwareReader(java.io.Reader reader) throws java.io.IOException
Create a reader handling comments in JSON. The reader tries to leave the original structure of the document untouched, meaning comments will be replace with spaces. Closing this reader will close the underlying reader.- Parameters:
reader
- Reader for the JSON- Returns:
- Reader for the pure JSON
- Throws:
java.io.IOException
- If reading fails.
-
newConfiguration
public static java.util.Hashtable<java.lang.String,java.lang.Object> newConfiguration()
Create a new map for configuration properties The returned map keeps the order of properties added and is using case-insensitive keys.- Returns:
- A new map
-
convertToObject
public static java.lang.Object convertToObject(jakarta.json.JsonValue value)
Convert a json value into an object. The resulting object isnull
: if the provided value isnull
orValueType#NULL
- A Boolean : if the json value is a boolean
- A Long : if the json value contains an integral number
- A Double : if the json value contains a non integral number
- A String : for any other provided non array value
- A Boolean[] : if the provided value is an array of booleans
- A Long[] : if the provided value is an array of integral numbers
- A Double[] : if the provided value is an array of non integral numbers
- A String[] : for any other provided array value
- Parameters:
value
- The json value- Returns:
- The object or
null
if the provided value isnull
orValueType#NULL
-
convertToJsonValue
public static jakarta.json.JsonValue convertToJsonValue(java.lang.Object value)
Convert an object to a JSON value. The resulting value is:JsonValue.NULL
: if the provided value isnull
JsonValue.TRUE
orJsonValue.FALSE
: if the provided value is Boolean.- A JSON value of type
JsonValue.ValueType#NUMBER
: if the value is a Integer, Long, Float, Double, Byte, Short JsonValue.ValueType#OBJECT
: if the value is a mapJsonValue.ValueType#ARRAY
: if the value is an array or a collectionJsonValue.ValueType#STRING
: otherwise, callingtoString()
on the value.
- Parameters:
value
- The object- Returns:
- The JSON value.
-
-