public class AbstractResourcePropertiesBuilderDecorator<T extends ResourceProperties.ResourcePropertiesBuilder> extends AbstractPropertiesBuilderDecorator<T> implements ResourceProperties.ResourcePropertiesBuilder
ResourceProperties.MutableResoureProperties, ResourceProperties.ResourcePropertiesBuilder
Properties.MutableProperties, Properties.PropertiesBuilder
org.refcodes.structure.CanonicalMap.CanonicalMapBuilder, org.refcodes.structure.CanonicalMap.MutableCanonicalMap
org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin<T>, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMixin, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMutatorMixin
org.refcodes.structure.PathMap.MutablePathMap<T>, org.refcodes.structure.PathMap.PathMapBuilder<T>
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>
org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<K,V,B extends org.refcodes.structure.Dictionary.MutableDictionary.DictionaryBuilder<K,V,B>>
_properties
DEFAULT_COMMENT
Modifier | Constructor and Description |
---|---|
protected |
AbstractResourcePropertiesBuilderDecorator()
Make sure to set the _properties member variable!
|
|
AbstractResourcePropertiesBuilderDecorator(T aProperties)
Decorates the provided
ResourceProperties.ResourcePropertiesBuilder with additional
behavior or functionality. |
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes
ResourceProperties.MutableResoureProperties to the resource to which the
ResourceProperties are attached to (such as a File as
of ResourceProperties.MutableResoureProperties.loadFrom(File) or
ResourceProperties.MutableResoureProperties.saveTo(File) ). |
Properties |
loadFrom(File aFile,
char... aDelimiters)
Loads the properties from the given
File . |
Properties |
loadFrom(InputStream aInputStream,
char... aDelimiters)
Loads the properties from the given
InputStream . |
Properties |
reload()
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) ). |
Properties |
reload(ReloadMode aReloadMode)
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) ). |
File |
saveTo(File aFile,
String aComment,
char aDelimiter)
Saves the properties to the given
File using the provided
delimiter as the destination's path delimiter. |
void |
saveTo(OutputStream aOutputStream,
String aComment,
char aDelimiter)
Saves the properties to the given
OutputStream using the
provided delimiter as the destination's path delimiter. |
Properties |
seekFrom(Class<?> aResourceClass,
String aFilePath,
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 the specification
for the method
RuntimeUtility.toConfigDirs() . |
String |
toSerialized(char aDelimiter)
Produces the external representation of the properties as of the
serialized format supported by the implementing class.
|
clear, containsValue, entrySet, put, putAll, remove
childrenOf, containsKey, get, getDelimiter, isEmpty, keySet, retrieveFrom, retrieveTo, size, toDataStructure, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
withInsert, withInsert, withInsertFrom, withInsertTo
withInsert, withInsert, withInsertFrom, withInsertTo
withInsert, withInsert, withInsertFrom, withInsertTo
withPut
put, put, putBoolean, putBoolean, putByte, putByte, putDouble, putDouble, putFloat, putFloat, putInteger, putInteger, putLong, putLong, putShort, putShort
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, toSerialized
containsValue, delete, delete, insert, insert, insertFrom, insertTo, put, putAll, putAll, putAll
childrenOf, getDelimiter, getType, retrieve, retrieveFrom, retrieveTo, toMap, toProperties, toPropertyPath
insert, insert, insertFrom, insertTo, putAll, toDump, toSourceCode, toSourceCode
toInstance, toInstance, toType, toType
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
insert, insert, insert, insert, insertFrom, insertFrom, insertTo, insertTo, put, putArray, putArray, removeAll
directories, directories, entries, entries, fromExternalKey, getArray, getArray, getRootPath, hasParentPath, isArray, isArray, isDirectory, isEntry, isRecord, isRootPath, keySet, paths, paths, records, records, toDataStructure, toDataStructure, toExternalKey, toMap, toNormalizedPath, toNormalizedPath, toParentPath, toPath
protected AbstractResourcePropertiesBuilderDecorator()
public AbstractResourcePropertiesBuilderDecorator(T aProperties)
ResourceProperties.ResourcePropertiesBuilder
with additional
behavior or functionality. Changes applied to the provided
ResourceProperties.ResourcePropertiesBuilder
affect the decorator.aProperties
- The ResourceProperties
to be decorated.public Properties loadFrom(InputStream aInputStream, char... aDelimiters) throws IOException, ParseException
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.loadFrom
in interface ResourceProperties.MutableResoureProperties
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).Properties
as loaded from the resource and
applied to this instance.IOException
- thrown in case loading the properties failedParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public Properties seekFrom(Class<?> aResourceClass, String aFilePath, char... aDelimiters) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
. 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.seekFrom
in interface ResourceProperties.MutableResoureProperties
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.aDelimiters
- The path delimiters to be used when parsing the
source's properties (in case the the serialized format
supports / requires the such).Properties
as loaded from the resource and
applied to this instance.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.public void saveTo(OutputStream aOutputStream, String aComment, char aDelimiter) throws IOException
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.saveTo
in interface ResourceProperties.MutableResoureProperties
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).IOException
- thrown in case saving the properties failedpublic Properties reload() throws IOException, IllegalStateException, ParseException
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. Properties existing in the
attached resource but not(!) in the Properties
itself are not(!)
removed. Use ResourceProperties.reload(ReloadMode)
with an argument of
true
(~ orphan removal) to remove properties not existing in
the resource.reload
in interface ResourceProperties
Properties
as loaded from the resource and applied to
this instance.IOException
- thrown in case accessing the resource encountered an
I/O problem.IllegalStateException
- in case the attached resource does not
support reloading.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public Properties reload(ReloadMode aReloadMode) throws IOException, IllegalStateException, ParseException
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.reload
in interface ResourceProperties
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.Properties
as loaded from the resource and applied to
this instance.IOException
- thrown in case accessing the resource encountered an
I/O problem.IllegalStateException
- in case the attached resource does not
support reloading.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public void flush() throws org.refcodes.component.OpenException
ResourceProperties.MutableResoureProperties
to the resource to which the
ResourceProperties
are attached to (such as a File
as
of ResourceProperties.MutableResoureProperties.loadFrom(File)
or
ResourceProperties.MutableResoureProperties.saveTo(File)
).
flush
in interface Flushable
flush
in interface ResourceProperties.MutableResoureProperties
org.refcodes.component.OpenException
public File saveTo(File aFile, String aComment, char aDelimiter) throws IOException
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.saveTo
in interface ResourceProperties.MutableResoureProperties
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).File
representing the actual location where the
properties have been saved to.IOException
- thrown in case saving the properties failedpublic Properties loadFrom(File aFile, char... aDelimiters) throws IOException, ParseException
File
. Save them using the
method ResourceProperties.MutableResoureProperties.saveTo(File)
.
The default implementation uses the hook method
ResourceProperties.MutableResoureProperties.loadFrom(InputStream, char...)
to finally load and parse the
properties.loadFrom
in interface ResourceProperties.MutableResoureProperties
aFile
- The File
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).Properties
as loaded from the resource and
applied to this instance.IOException
- thrown in case loading the properties failedParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public String toSerialized(char aDelimiter)
toSerialized
in interface ResourceProperties.MutableResoureProperties
aDelimiter
- The path delimiter to be used when serializing the
properties (in case the the serialized format supports /
requires the such).Copyright © 2018. All rights reserved.