Class 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 reader
      static ConfigurationWriter.Builder buildWriter()
      Get a builder to create a configuration writer
      static 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 is
        • null : if the provided value is null or ValueType#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 is null or ValueType#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 is null
        • JsonValue.TRUE or JsonValue.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 map
        • JsonValue.ValueType#ARRAY : if the value is an array or a collection
        • JsonValue.ValueType#STRING : otherwise, calling toString() on the value.
        Parameters:
        value - The object
        Returns:
        The JSON value.