Class AbstractResourcePropertiesBuilder

    • Field Detail

      • _propertiesFile

        protected java.io.File _propertiesFile
    • Constructor Detail

      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​()
        Create an empty AbstractResourcePropertiesBuilder instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.Object aObj)
        Create a AbstractResourcePropertiesBuilder instance containing the elements as of PathMap.MutablePathMap.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.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(Properties aProperties)
        Create a AbstractResourcePropertiesBuilder 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.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.util.Map<?,?> aProperties)
        Create a AbstractResourcePropertiesBuilder 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.
      • AbstractResourcePropertiesBuilder

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

        protected AbstractResourcePropertiesBuilder​(java.io.File aFile,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given File.
        Parameters:
        aFile - The File from which to load the properties.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.io.File aFile,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads or seeks the properties from the given File. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        Parameters:
        aFile - The File from which to load the properties.
        aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.io.File aFile,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads or seeks the properties from the given File. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        Parameters:
        aFile - The File from which to load the properties.
        aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

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

        protected AbstractResourcePropertiesBuilder​(java.lang.String aFilePath,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given file's path.
        Parameters:
        aFilePath - The path to the file from which to load the properties.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.Class<?> aResourceClass,
                                                    java.lang.String aFilePath)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the 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:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.Class<?> aResourceClass,
                                                    java.lang.String aFilePath,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the 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.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.String aFilePath,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given file's path. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        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:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.String aFilePath,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given file's path. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        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.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.Class<?> aResourceClass,
                                                    java.lang.String aFilePath,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given file's path. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        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:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

        protected AbstractResourcePropertiesBuilder​(java.lang.Class<?> aResourceClass,
                                                    java.lang.String aFilePath,
                                                    org.refcodes.runtime.ConfigLocator aConfigLocator,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given file's path. In case you enable the "seek" argument, then the properties are, if the file does not exist, loaded from the first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        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.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

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

        protected AbstractResourcePropertiesBuilder​(java.net.URL aUrl,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Loads the properties from the given URL.
        Parameters:
        aUrl - The URL from which to read the properties.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • AbstractResourcePropertiesBuilder

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

        protected AbstractResourcePropertiesBuilder​(java.io.InputStream aInputStream,
                                                    char... aDelimiters)
                                             throws java.io.IOException,
                                                    java.text.ParseException
        Reads the properties from the given InputStream.
        Parameters:
        aInputStream - The InputStream from which to read the properties.
        aDelimiters - The path delimiters to be used when parsing the source's properties.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
    • Method Detail

      • loadFrom

        public Properties loadFrom​(java.io.InputStream aInputStream,
                                   char... aDelimiters)
                            throws java.io.IOException,
                                   java.text.ParseException
        Loads the properties from the given InputStream. Save them using the method ResourceProperties.MutableResoureProperties.saveTo(OutputStream). This is the hook-method of the default implementation for loading the properties. In case you want to implement ResourceProperties which support other notations than the properties notation (path=value), then you overwrite this method in your implementation accordingly.
        Specified by:
        loadFrom in interface ResourceProperties.MutableResoureProperties
        Parameters:
        aInputStream - The InputStream from which to load the properties.
        aDelimiters - The path delimiters to be used when parsing the source's properties (in case the the serialized format supports / requires the such).
        Returns:
        The Properties as loaded from the resource and applied to this instance.
        Throws:
        java.io.IOException - thrown in case loading the properties failed
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • saveTo

        public void saveTo​(java.io.OutputStream aOutputStream,
                           java.lang.String aComment,
                           char aDelimiter)
                    throws java.io.IOException
        The comment is ignored for the JSON format as JSON does not(!) support any comments! Saves the properties to the given OutputStream using the provided delimiter as the destination's path delimiter. Load them via ResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...) This is the hook-method of the default implementation for writing (saving) the properties. In case you want to implement ResourceProperties which support other notations than the properties notation (path=value), then you overwrite this method in your implementation accordingly.
        Specified by:
        saveTo in interface ResourceProperties.MutableResoureProperties
        Parameters:
        aOutputStream - The OutputStream to which to save the properties to.
        aComment - The description for the properties file.
        aDelimiter - The path delimiter to be used when writing out the properties to the destination (in case the the serialized format supports / requires the such).
        Throws:
        java.io.IOException - thrown in case saving the properties failed
      • saveTo

        public java.io.File saveTo​(java.io.File aFile,
                                   java.lang.String aComment,
                                   char aDelimiter)
                            throws java.io.IOException
        Saves the properties to the given File using the provided delimiter as the destination's path delimiter. Load them via ResourceProperties.MutableResoureProperties.loadFrom(File, char...). The default implementation uses the hook method ResourceProperties.MutableResoureProperties.saveTo(OutputStream, String, char) to finally format and write the properties.
        Specified by:
        saveTo in interface ResourceProperties.MutableResoureProperties
        Parameters:
        aFile - The File from which to load the properties.
        aComment - The description for the properties file.
        aDelimiter - The path delimiter to be used when writing out the properties to the destination (in case the the serialized format supports / requires the such).
        Returns:
        The File representing the actual location where the properties have been saved to.
        Throws:
        java.io.IOException - thrown in case saving the properties failed
      • seekFrom

        public Properties seekFrom​(java.lang.Class<?> aResourceClass,
                                   java.lang.String aFilePath,
                                   org.refcodes.runtime.ConfigLocator aConfigLocator,
                                   char... aDelimiters)
                            throws java.io.IOException,
                                   java.text.ParseException
        Loads a properties file from the file path directly or (if not found) from the first folder containing such a file as of the ConfigLocator configuration passed. 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). The default implementation uses the hook method ResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...) to finally load and parse the properties.
        Specified by:
        seekFrom in interface ResourceProperties.MutableResoureProperties
        Parameters:
        aResourceClass - The class which's class loader is to take care of loading the properties (from inside a JAR).
        aFilePath - The file path from which to load the properties.
        aConfigLocator - The ConfigLocator describes the locations to additional crawl for the desired file.
        aDelimiters - The path delimiters to be used when parsing the source's properties (in case the the serialized format supports / requires the such).
        Returns:
        The Properties as loaded from the resource and applied to this instance.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • isFlushable

        public boolean isFlushable​()
        In case the resource has not been loaded from a writable File, then calling this method will return false.
        Specified by:
        isFlushable in interface org.refcodes.component.Flushable
      • reload

        public Properties reload​(ReloadMode aReloadMode)
                          throws java.io.IOException,
                                 java.lang.IllegalStateException,
                                 java.text.ParseException
        Reloads the ResourceProperties from the resource to which the ResourceProperties are attached to (such as a File as of ResourceProperties.MutableResoureProperties.loadFrom(File) or ResourceProperties.MutableResoureProperties.saveTo(File)). In case the resource (such as an InputStream) does not support reloading, then an IllegalStateException is thrown. Properties existing in the attached resource as well in the Properties itself are replaced. When "orphan removal" is set to false, then properties existing in the attached resource but not(!) in the Properties itself are not(!) removed. When "orphan removal" is set to true, then properties existing in the attached resource but not(!) in the Properties itself are(!) removed.
        Specified by:
        reload in interface ResourceProperties
        Parameters:
        aReloadMode - when set to ReloadMode.ORPHAN_REMOVAL, then properties existing in the attached resource but not(!) in the Properties itself are(!) removed. Else properties not existing in the attached resource are kept.
        Returns:
        The Properties as loaded from the resource and applied to this instance.
        Throws:
        java.io.IOException - thrown in case accessing the resource encountered an I/O problem.
        java.lang.IllegalStateException - in case the attached resource does not support reloading.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • createCanonicalMapFactory

        protected abstract org.refcodes.structure.ext.factory.CanonicalMapFactory createCanonicalMapFactory​()
        Abstract method to be implemented by the sub-classes returning the concrete CanonicalMapFactory responsible to fabricate the CanonicalMap instances as of the required notation.
        Returns:
        The CanonicalMapFactory supporting the required notation.