Package org.refcodes.configuration
Class AbstractResourcePropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>
- java.lang.Object
-
- org.refcodes.configuration.AbstractPropertiesDecorator<T>
-
- org.refcodes.configuration.AbstractPropertiesBuilderDecorator<T>
-
- org.refcodes.configuration.AbstractResourcePropertiesBuilderDecorator<T>
-
- All Implemented Interfaces:
java.io.Flushable
,java.util.Map<java.lang.String,java.lang.String>
,org.refcodes.component.Flushable
,org.refcodes.component.Flushable.FlushBuilder<ResourceProperties.ResourcePropertiesBuilder>
,Properties
,Properties.MutableProperties
,Properties.PropertiesBuilder
,ResourceProperties
,ResourceProperties.MutableResoureProperties
,ResourceProperties.ResourcePropertiesBuilder
,org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.Dumpable
,org.refcodes.mixin.TypeAccessor<java.lang.String>
,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,java.lang.String>
,org.refcodes.structure.Dictionary.MutableDictionary<java.lang.String,java.lang.String>
,org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<java.lang.String,java.lang.String,org.refcodes.structure.PathMap.PathMapBuilder<java.lang.String>>
,org.refcodes.structure.Keys<java.lang.String,java.lang.String>
,org.refcodes.structure.Keys.MutableKeys<java.lang.String,java.lang.String>
,org.refcodes.structure.Keys.MutableValues<java.lang.String,java.lang.String>
,org.refcodes.structure.PathMap<java.lang.String>
,org.refcodes.structure.PathMap.MutablePathMap<java.lang.String>
,org.refcodes.structure.PathMap.PathMapBuilder<java.lang.String>
,org.refcodes.structure.PropertiesAccessorMixin
,org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin<org.refcodes.structure.CanonicalMap.CanonicalMapBuilder>
,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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.structure.CanonicalMap
org.refcodes.structure.CanonicalMap.CanonicalMapBuilder, org.refcodes.structure.CanonicalMap.MutableCanonicalMap
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Dictionary
org.refcodes.structure.Dictionary.MutableDictionary<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Dictionary.MutableDictionary
org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<K extends java.lang.Object,V extends java.lang.Object,B extends org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<K,V,B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Flushable
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PathMap
org.refcodes.structure.PathMap.MutablePathMap<T extends java.lang.Object>, org.refcodes.structure.PathMap.PathMapBuilder<T extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.configuration.Properties
Properties.MutableProperties, Properties.PropertiesBuilder
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PropertiesAccessorMixin
org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin<T extends java.lang.Object>, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMixin, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMutatorMixin
-
Nested classes/interfaces inherited from interface org.refcodes.configuration.ResourceProperties
ResourceProperties.MutableResoureProperties, ResourceProperties.ResourcePropertiesBuilder
-
-
Field Summary
-
Fields inherited from interface org.refcodes.configuration.ResourceProperties
VALUE_ATTRIBUTES
-
Fields inherited from interface org.refcodes.configuration.ResourceProperties.MutableResoureProperties
DEFAULT_COMMENT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractResourcePropertiesBuilderDecorator()
Make sure to set the getProperties() member variable!AbstractResourcePropertiesBuilderDecorator(T aProperties)
Decorates the providedResourceProperties.ResourcePropertiesBuilder
with additional behavior or functionality.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Properties.PropertiesBuilder
childrenOf(java.lang.String aParentPath)
void
flush()
FlushesResourceProperties.MutableResoureProperties
to the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
).boolean
isFlushable()
Properties
loadFrom(java.io.File aFile, char... aDelimiters)
Loads the properties from the givenFile
.Properties
loadFrom(java.io.InputStream aInputStream, char... aDelimiters)
Loads the properties from the givenInputStream
.Properties
reload()
Reloads theResourceProperties
from the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
).Properties
reload(ReloadMode aReloadMode)
Reloads theResourceProperties
from the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
).Properties.PropertiesBuilder
retrieveFrom(java.lang.String aFromPath)
Properties.PropertiesBuilder
retrieveTo(java.lang.String aToPath)
java.io.File
saveTo(java.io.File aFile, java.lang.String aComment, char aDelimiter)
Saves the properties to the givenFile
using the provided delimiter as the destination's path delimiter.void
saveTo(java.io.OutputStream aOutputStream, java.lang.String aComment, char aDelimiter)
Saves the properties to the givenOutputStream
using the provided delimiter as the destination's path delimiter.Properties
seekFrom(java.lang.Class<?> aResourceClass, java.lang.String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters)
Loads a properties file from the file path directly or (if not found) from the first folder containing such a file as of theConfigLocator
configuration passed.java.lang.String
toSerialized(char aDelimiter)
Produces the external representation of the properties as of the serialized format supported by the implementing class.-
Methods inherited from class org.refcodes.configuration.AbstractPropertiesBuilderDecorator
clear, containsValue, entrySet, put, putAll, remove
-
Methods inherited from class org.refcodes.configuration.AbstractPropertiesDecorator
containsKey, get, getDelimiter, getProperties, isEmpty, keySet, setProperties, size, toDataStructure, values
-
Methods inherited from interface org.refcodes.structure.CanonicalMap
toInstance, toInstance, toType, toType
-
Methods inherited from interface org.refcodes.structure.CanonicalMap.CanonicalMapBuilder
withInsert, withInsert, withInsertFrom, withInsertTo
-
Methods inherited from interface org.refcodes.structure.CanonicalMap.MutableCanonicalMap
insert, insert, insertFrom, insertTo, putAll, toDump, toSourceCode, toSourceCode
-
Methods inherited from interface org.refcodes.component.Flushable.FlushBuilder
withFlush, withFlushUnchecked
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.structure.PathMap
directories, directories, entries, entries, fromExternalKey, get, get, getArray, getArray, getIndexes, getIndexes, getRootPath, hasIndexed, hasIndexed, hasParentPath, isArray, isArray, isDirectory, isEntry, isIndexed, isIndexed, isPath, isRecord, isRootPath, keySet, paths, paths, records, records, toDataStructure, toDataStructure, toExternalKey, toMap, toNormalizedPath, toNormalizedPath, toParentPath, toPath, toPath
-
Methods inherited from interface org.refcodes.structure.PathMap.MutablePathMap
insert, insert, insert, insert, insertFrom, insertFrom, insertTo, insertTo, put, putArray, putArray, remove, remove, removeAll, removeAll, removeAll, removeAll
-
Methods inherited from interface org.refcodes.structure.PathMap.PathMapBuilder
withInsert, withInsert, withInsertFrom, withInsertTo
-
Methods inherited from interface org.refcodes.configuration.Properties
getDelimiter, getType, toMap, toProperties, toPropertyPath
-
Methods inherited from interface org.refcodes.configuration.Properties.MutableProperties
containsValue, delete, delete, insert, insert, insertFrom, insertTo, put, putAll, putAll, putAll
-
Methods inherited from interface org.refcodes.configuration.Properties.PropertiesBuilder
getIndexed, getIndexed, retrieve, withInsert, withInsert, withInsertFrom, withInsertTo
-
Methods inherited from interface org.refcodes.structure.PropertiesAccessorMixin
containsKey, get, getBoolean, getBoolean, getByte, getByte, getCharacter, getCharacter, getDouble, getDouble, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getShort, getShort, use, useBoolean, useBoolean, useByte, useByte, useDouble, useDouble, useFloat, useFloat, useInteger, useInteger, useLong, useLong, useShort, useShort
-
Methods inherited from interface org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin
withPut
-
Methods inherited from interface org.refcodes.structure.PropertiesAccessorMixin.PropertiesMutatorMixin
put, put, putBoolean, putBoolean, putByte, putByte, putDouble, putDouble, putFloat, putFloat, putInteger, putInteger, putLong, putLong, putShort, putShort
-
Methods inherited from interface org.refcodes.configuration.ResourceProperties.MutableResoureProperties
fileTo, fileTo, fileTo, fileTo, fileTo, fileTo, fileTo, fileTo, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, parseFrom, parseFrom, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, toSerialized
-
Methods inherited from interface org.refcodes.configuration.ResourceProperties.ResourcePropertiesBuilder
withInsert, withInsert, withInsertFrom, withInsertTo, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withLoadFrom, withPut, withPut, withPutBoolean, withPutByte, withPutDouble, withPutFloat, withPutInteger, withPutLong, withPutShort, withRemoveFrom, withSeekFrom, withSeekFrom, withSeekFrom, withSeekFrom, withSeekFrom, withSeekFrom, withSeekFrom
-
-
-
-
Constructor Detail
-
AbstractResourcePropertiesBuilderDecorator
protected AbstractResourcePropertiesBuilderDecorator()
Make sure to set the getProperties() member variable!
-
AbstractResourcePropertiesBuilderDecorator
public AbstractResourcePropertiesBuilderDecorator(T aProperties)
Decorates the providedResourceProperties.ResourcePropertiesBuilder
with additional behavior or functionality. Changes applied to the providedResourceProperties.ResourcePropertiesBuilder
affect the decorator.- Parameters:
aProperties
- TheResourceProperties
to be decorated.
-
-
Method Detail
-
loadFrom
public Properties loadFrom(java.io.InputStream aInputStream, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads the properties from the givenInputStream
. Save them using the methodResourceProperties.MutableResoureProperties.saveTo(OutputStream)
. This is the hook-method of the default implementation for loading the properties. In case you want to implementResourceProperties
which support other notations than the properties notation (path=value
), then you overwrite this method in your implementation accordingly.- Specified by:
loadFrom
in interfaceResourceProperties.MutableResoureProperties
- Parameters:
aInputStream
- TheInputStream
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 failedjava.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 theConfigLocator
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 methodResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...)
to finally load and parse the properties.- Specified by:
seekFrom
in interfaceResourceProperties.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
- TheConfigLocator
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 givenOutputStream
using the provided delimiter as the destination's path delimiter. Load them viaResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...)
This is the hook-method of the default implementation for writing (saving) the properties. In case you want to implementResourceProperties
which support other notations than the properties notation (path=value
), then you overwrite this method in your implementation accordingly.- Specified by:
saveTo
in interfaceResourceProperties.MutableResoureProperties
- Parameters:
aOutputStream
- TheOutputStream
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() throws java.io.IOException, java.lang.IllegalStateException, java.text.ParseException
Reloads theResourceProperties
from the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
). In case the resource (such as anInputStream
) does not support reloading, then anIllegalStateException
is thrown. Properties existing in the attached resource as well in theProperties
itself are replaced. Properties existing in the attached resource but not(!) in theProperties
itself are not(!) removed. UseResourceProperties.reload(ReloadMode)
with an argument oftrue
(~ orphan removal) to remove properties not existing in the resource.- Specified by:
reload
in interfaceResourceProperties
- 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.
-
reload
public Properties reload(ReloadMode aReloadMode) throws java.io.IOException, java.lang.IllegalStateException, java.text.ParseException
Reloads theResourceProperties
from the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
). In case the resource (such as anInputStream
) does not support reloading, then anIllegalStateException
is thrown. Properties existing in the attached resource as well in theProperties
itself are replaced. When "orphan removal" is set tofalse
, then properties existing in the attached resource but not(!) in theProperties
itself are not(!) removed. When "orphan removal" is set totrue
, then properties existing in the attached resource but not(!) in theProperties
itself are(!) removed.- Specified by:
reload
in interfaceResourceProperties
- Parameters:
aReloadMode
- when set toReloadMode.ORPHAN_REMOVAL
, then properties existing in the attached resource but not(!) in theProperties
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.
-
flush
public void flush() throws org.refcodes.component.OpenException
FlushesResourceProperties.MutableResoureProperties
to the resource to which theResourceProperties
are attached to (such as aFile
as ofResourceProperties.MutableResoureProperties.loadFrom(File)
orResourceProperties.MutableResoureProperties.saveTo(File)
).- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in interfaceorg.refcodes.component.Flushable
- Specified by:
flush
in interfaceResourceProperties.MutableResoureProperties
- Throws:
org.refcodes.component.OpenException
-
isFlushable
public boolean isFlushable()
- Specified by:
isFlushable
in interfaceorg.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 givenFile
using the provided delimiter as the destination's path delimiter. Load them viaResourceProperties.MutableResoureProperties.loadFrom(File, char...)
. The default implementation uses the hook methodResourceProperties.MutableResoureProperties.saveTo(OutputStream, String, char)
to finally format and write the properties.- Specified by:
saveTo
in interfaceResourceProperties.MutableResoureProperties
- Parameters:
aFile
- TheFile
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
-
loadFrom
public Properties loadFrom(java.io.File aFile, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads the properties from the givenFile
. Save them using the methodResourceProperties.MutableResoureProperties.saveTo(File)
. The default implementation uses the hook methodResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...)
to finally load and parse the properties.- Specified by:
loadFrom
in interfaceResourceProperties.MutableResoureProperties
- Parameters:
aFile
- TheFile
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 failedjava.text.ParseException
- Signals that an error has been reached unexpectedly while parsing the data to be loaded.
-
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 interfaceResourceProperties.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.
-
retrieveFrom
public Properties.PropertiesBuilder retrieveFrom(java.lang.String aFromPath)
- Specified by:
retrieveFrom
in interfaceorg.refcodes.structure.CanonicalMap
- Specified by:
retrieveFrom
in interfaceorg.refcodes.structure.PathMap<T extends ResourceProperties.ResourcePropertiesBuilder>
- Specified by:
retrieveFrom
in interfaceProperties
- Specified by:
retrieveFrom
in interfaceProperties.MutableProperties
- Specified by:
retrieveFrom
in interfaceProperties.PropertiesBuilder
- Overrides:
retrieveFrom
in classAbstractPropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>
-
retrieveTo
public Properties.PropertiesBuilder retrieveTo(java.lang.String aToPath)
- Specified by:
retrieveTo
in interfaceorg.refcodes.structure.CanonicalMap
- Specified by:
retrieveTo
in interfaceorg.refcodes.structure.PathMap<T extends ResourceProperties.ResourcePropertiesBuilder>
- Specified by:
retrieveTo
in interfaceProperties
- Specified by:
retrieveTo
in interfaceProperties.MutableProperties
- Specified by:
retrieveTo
in interfaceProperties.PropertiesBuilder
- Overrides:
retrieveTo
in classAbstractPropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>
-
childrenOf
public Properties.PropertiesBuilder childrenOf(java.lang.String aParentPath)
- Specified by:
childrenOf
in interfaceorg.refcodes.structure.CanonicalMap
- Specified by:
childrenOf
in interfaceorg.refcodes.structure.PathMap<T extends ResourceProperties.ResourcePropertiesBuilder>
- Specified by:
childrenOf
in interfaceProperties
- Specified by:
childrenOf
in interfaceProperties.MutableProperties
- Specified by:
childrenOf
in interfaceProperties.PropertiesBuilder
- Overrides:
childrenOf
in classAbstractPropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder>
-
-