Package org.apache.felix.cm.json.io
Class Configurations
- java.lang.Object
-
- org.apache.felix.cm.json.io.Configurations
-
public class Configurations extends Object
Factory class for JSON and configuration support
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConfigurationReader.BuilderbuildReader()Get a builder to create a configuration readerstatic ConfigurationWriter.BuilderbuildWriter()Get a builder to create a configuration writerstatic jakarta.json.JsonValueconvertToJsonValue(Object value)Convert an object to a JSON value.static ObjectconvertToObject(jakarta.json.JsonValue value)Convert a json value into an object.static ReaderjsonCommentAwareReader(Reader reader)Create a reader handling comments in JSON.static Hashtable<String,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 Reader jsonCommentAwareReader(Reader reader) throws 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:
IOException- If reading fails.
-
newConfiguration
public static Hashtable<String,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 Object convertToObject(jakarta.json.JsonValue value)
Convert a json value into an object. The resulting object isnull: if the provided value isnullorValueType#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
nullif the provided value isnullorValueType#NULL
-
convertToJsonValue
public static jakarta.json.JsonValue convertToJsonValue(Object value)
Convert an object to a JSON value. The resulting value is:JsonValue.NULL: if the provided value isnullJsonValue.TRUEorJsonValue.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.
-
-