Class JavaProperties

java.lang.Object
org.refcodes.struct.MapPathTable<String>
org.refcodes.struct.MapCanonicalTable
All Implemented Interfaces:
Flushable, Serializable, Map<String,String>, org.refcodes.component.Flushable, org.refcodes.component.Flushable.FlushBuilder<ResourceProperties>, org.refcodes.mixin.AnnotatorAccessor, org.refcodes.mixin.Clearable, org.refcodes.mixin.DelimiterAccessor, org.refcodes.mixin.EmptyAccessor, org.refcodes.mixin.TypeAccessor<String>, ImmutableProperties, ImmutableProperties.MutableProperties, ImmutableResourceProperties, ImmutableResourceProperties.MutableResoureProperties, Properties, ResourceProperties, org.refcodes.struct.CanonicalTable, org.refcodes.struct.Containable, org.refcodes.struct.ImmutableCanonicalTable, org.refcodes.struct.ImmutableCanonicalTable.MutableCanonicalTable, org.refcodes.struct.ImmutableInterOperableTable<String>, org.refcodes.struct.ImmutableInterOperableTable.MutableInterOperableTable<String>, org.refcodes.struct.ImmutablePathTable<String>, org.refcodes.struct.ImmutablePathTable.MutablePathTable<String>, org.refcodes.struct.ImmutableTable<String,String>, org.refcodes.struct.ImmutableTable.MutableTable<String,String>, org.refcodes.struct.InterOperableTable<String>, org.refcodes.struct.Keys<String,String>, org.refcodes.struct.Keys.MutableKeys<String,String>, org.refcodes.struct.Keys.MutableValues<String,String>, org.refcodes.struct.PathTable<String>, org.refcodes.struct.Table<String,String,org.refcodes.struct.PathTable<String>>

public class JavaProperties extends AbstractResourceProperties
Implementation of the ResourceProperties interface with support of so called "Java properties" (or just "properties"). For Java properties, see "https://en.wikipedia.org/wiki/.properties".
See Also:
  • Constructor Details

    • JavaProperties

      public JavaProperties()
      Create an empty JavaProperties instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
    • JavaProperties

      public JavaProperties(Class<?> aResourceClass, String aFilePath) throws IOException, ParseException
      Loads the Java properties from the given file's path.
      Parameters:
      aResourceClass - The class which's class loader is to take care of loading the properties (from inside a JAR).
      aFilePath - The file path of the class's resources from which to load the properties.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(Class<?> aResourceClass, String aFilePath, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given file's path.
      Parameters:
      aResourceClass - The class which's class loader is to take care of loading the properties (from inside a JAR).
      aFilePath - The file path of the class's resources from which to load the properties.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(Class<?> aResourceClass, String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Loads the Java properties from the given file's path. A provided ConfigLocator describes the locations to additional crawl for the desired file. Finally (if nothing else succeeds) the properties are loaded by the provided class's class loader which takes care of loading the properties (in case the file path is a relative path, also the absolute path with a prefixed path delimiter "/" is probed).
      Parameters:
      aResourceClass - The class which's class loader is to take care of loading the properties (from inside a JAR).
      aFilePath - The file path of the class's resources from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(Class<?> aResourceClass, String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given file's path. A provided ConfigLocator describes the locations to additional crawl for the desired file. Finally (if nothing else succeeds) the properties are loaded by the provided class's class loader which takes care of loading the properties (in case the file path is a relative path, also the absolute path with a prefixed path delimiter "/" is probed). *
      Parameters:
      aResourceClass - The class which's class loader is to take care of loading the properties (from inside a JAR).
      aFilePath - The file path of the class's resources from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(File aFile) throws IOException, ParseException
      Loads the Java properties from the given File.
      Parameters:
      aFile - The File from which to load the properties.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(File aFile, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given File.
      Parameters:
      aFile - The File from which to load the properties.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Loads or seeks the Java properties from the given File. A provided ConfigLocator describes the locations to additional crawl for the desired file.
      Parameters:
      aFile - The File from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads or seeks the Java properties from the given File. A provided ConfigLocator describes the locations to additional crawl for the desired file.
      Parameters:
      aFile - The File from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(InputStream aInputStream) throws IOException, ParseException
      Reads the Java properties from the given InputStream.
      Parameters:
      aInputStream - The InputStream from which to read the properties.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(InputStream aInputStream, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Reads the Java properties from the given InputStream.
      Parameters:
      aInputStream - The InputStream from which to read the properties.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(Map<?,?> aProperties)
      Create a JavaProperties instance containing the elements of the provided Map instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
    • JavaProperties

      public JavaProperties(Map<?,?> aProperties, DocumentMetrics aDocumentMetrics)
      Create a JavaProperties instance containing the elements of the provided Map instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
    • JavaProperties

      public JavaProperties(Object aObj)
      Create a JavaProperties instance containing the elements as of ImmutablePathTable.MutablePathTable.insert(Object) using the default path delimiter "/" (Delimiter.PATH) for the path declarations: "Inspects the given object and adds all elements found in the given object. Elements of type Map, Collection and arrays are identified and handled as of their type: The path for each value in a Map is appended with its according key. The path for each value in a Collection or array is appended with its according index of occurrence (in case of a List or an array, its actual index). In case of reflection, the path for each member is appended with its according mamber's name. All elements (e.g. the members and values) are inspected recursively which results in the according paths of the terminating values."
      Parameters:
      aObj - The object from which the elements are to be added.
    • JavaProperties

      public JavaProperties(Object aObj, DocumentMetrics aDocumentMetrics)
      Create a JavaProperties instance containing the elements as of ImmutablePathTable.MutablePathTable.insert(Object) using the default path delimiter "/" (Delimiter.PATH) for the path declarations: "Inspects the given object and adds all elements found in the given object. Elements of type Map, Collection and arrays are identified and handled as of their type: The path for each value in a Map is appended with its according key. The path for each value in a Collection or array is appended with its according index of occurrence (in case of a List or an array, its actual index). In case of reflection, the path for each member is appended with its according mamber's name. All elements (e.g. the members and values) are inspected recursively which results in the according paths of the terminating values."
      Parameters:
      aObj - The object from which the elements are to be added.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
    • JavaProperties

      public JavaProperties(ImmutableProperties aProperties)
      Create a JavaProperties instance containing the elements of the provided ImmutableProperties instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
    • JavaProperties

      public JavaProperties(ImmutableProperties aProperties, DocumentMetrics aDocumentMetrics)
      /** Create a JavaProperties instance containing the elements of the provided Properties instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
    • JavaProperties

      public JavaProperties(Properties aProperties)
      Create a JavaProperties instance containing the elements of the provided Properties instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
    • JavaProperties

      public JavaProperties(Properties aProperties, DocumentMetrics aDocumentMetrics)
      Create a JavaProperties instance containing the elements of the provided Properties instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aProperties - the properties to be added.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
    • JavaProperties

      public JavaProperties(String aFilePath) throws IOException, ParseException
      Loads the Java properties from the given file's path.
      Parameters:
      aFilePath - The path to the file from which to load the properties.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(String aFilePath, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given file's path.
      Parameters:
      aFilePath - The path to the file from which to load the properties.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Loads the Java properties from the given file's path. A provided ConfigLocator describes the locations to additional crawl for the desired file.
      Parameters:
      aFilePath - The path to the file from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given file's path. A provided ConfigLocator describes the locations to additional crawl for the desired file.
      Parameters:
      aFilePath - The path to the file from which to load the properties.
      aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(URL aUrl) throws IOException, ParseException
      Loads the Java properties from the given URL.
      Parameters:
      aUrl - The URL from which to read the properties.
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • JavaProperties

      public JavaProperties(URL aUrl, DocumentMetrics aDocumentMetrics) throws IOException, ParseException
      Loads the Java properties from the given URL.
      Parameters:
      aUrl - The URL from which to read the properties.
      aDocumentMetrics - Provides various metrics which may be tweaked when marshaling or unmarshaling documents of various nations (such as INI, XML, YAML, JSON, TOML, PROPERTIES, etc.).
      Throws:
      IOException - thrown in case accessing or processing the properties file failed.
      ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
  • Method Details

    • createCanonicalMapFactory

      protected org.refcodes.struct.ext.factory.CanonicalTableFactory createCanonicalMapFactory()
      Abstract method to be implemented by the sub-classes returning the concrete CanonicalTableFactory responsible to fabricate the ImmutableCanonicalTable instances as of the required notation.
      Specified by:
      createCanonicalMapFactory in class AbstractResourceProperties
      Returns:
      The CanonicalTableFactory supporting the required notation.