Class AbstractResourcePropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>

  • All Implemented Interfaces:
    java.io.Flushable, java.util.Map<java.lang.String,T>, org.refcodes.component.Flushable, org.refcodes.component.Flushable.FlushBuilder<T>, Properties, Properties.MutableProperties, Properties.PropertiesBuilder, ResourceProperties, ResourceProperties.MutableResoureProperties, ResourceProperties.ResourcePropertiesBuilder, org.refcodes.mixin.DelimiterAccessor, org.refcodes.mixin.Dumpable, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.structure.CanonicalMap, org.refcodes.structure.CanonicalMap.CanonicalMapBuilder, org.refcodes.structure.CanonicalMap.MutableCanonicalMap, org.refcodes.structure.Clearable, org.refcodes.structure.Containable, org.refcodes.structure.Dictionary<java.lang.String,T>, org.refcodes.structure.Dictionary.MutableDictionary<java.lang.String,T>, org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<java.lang.String,T,org.refcodes.structure.PathMap.PathMapBuilder<T>>, org.refcodes.structure.Keys<java.lang.String,T>, org.refcodes.structure.Keys.MutableKeys<java.lang.String,T>, org.refcodes.structure.Keys.MutableValues<java.lang.String,T>, org.refcodes.structure.PathMap<T>, org.refcodes.structure.PathMap.MutablePathMap<T>, org.refcodes.structure.PathMap.PathMapBuilder<T>, org.refcodes.structure.PropertiesAccessorMixin, org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin<T>, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMixin, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMutatorMixin
    Direct Known Subclasses:
    PolyglotPropertiesBuilder, ScheduledResourcePropertiesBuilderDecorator


    public class AbstractResourcePropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>
    extends AbstractPropertiesBuilderDecorator<T>
    implements ResourceProperties.ResourcePropertiesBuilder
    • Constructor Detail

      • AbstractResourcePropertiesBuilderDecorator

        protected AbstractResourcePropertiesBuilderDecorator​()
        Make sure to set the getProperties() member variable!
    • 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.
      • 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.
      • saveTo

        public void saveTo​(java.io.OutputStream aOutputStream,
                           java.lang.String aComment,
                           char aDelimiter)
                    throws java.io.IOException
        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
      • 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.
      • isFlushable

        public boolean isFlushable​()
        Specified by:
        isFlushable in interface org.refcodes.component.Flushable
      • 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
      • toSerialized

        public java.lang.String toSerialized​(char aDelimiter)
        Produces the external representation of the properties as of the serialized format supported by the implementing class.
        Specified by:
        toSerialized in interface ResourceProperties
        Specified by:
        toSerialized in interface ResourceProperties.MutableResoureProperties
        Parameters:
        aDelimiter - The path delimiter to be used when serializing the properties (in case the the serialized format supports / requires the such).
        Returns:
        The external (serialized) representation of the properties.