public class JavaPropertiesBuilder extends AbstractResourcePropertiesBuilder implements ResourceProperties.ResourcePropertiesBuilder
ResourceProperties.ResourcePropertiesBuilder
interface with
support of so called "Java properties" (or just "properties").
For Java properties, see "https://en.wikipedia.org/wiki/.properties".AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
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>>
_propertiesFile
DEFAULT_COMMENT
Constructor and Description |
---|
JavaPropertiesBuilder()
Create an empty
JavaPropertiesBuilder instance using the default
path delimiter "/" (Delimiter.PATH ) for the path declarations. |
JavaPropertiesBuilder(Class<?> aResourceClass,
String aFilePath)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(Class<?> aResourceClass,
String aFilePath,
boolean isSeekFile)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(Class<?> aResourceClass,
String aFilePath,
boolean isSeekFile,
char... aDelimiters)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(Class<?> aResourceClass,
String aFilePath,
char... aDelimiters)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(File aFile)
Loads the Java properties from the given
File . |
JavaPropertiesBuilder(File aFile,
boolean isSeekFile)
Loads or seeks the Java properties from the given
File . |
JavaPropertiesBuilder(File aFile,
boolean isSeekFile,
char... aDelimiters)
Loads or seeks the Java properties from the given
File . |
JavaPropertiesBuilder(File aFile,
char... aDelimiters)
Loads the Java properties from the given
File . |
JavaPropertiesBuilder(InputStream aInputStream)
Reads the Java properties from the given
InputStream . |
JavaPropertiesBuilder(InputStream aInputStream,
char... aDelimiters)
Reads the Java properties from the given
InputStream . |
JavaPropertiesBuilder(Map<?,?> aProperties)
Create a
JavaPropertiesBuilder instance containing the elements
of the provided Map instance using the default path delimiter "/"
(Delimiter.PATH ) for the path declarations |
JavaPropertiesBuilder(Object aObj)
Create a
JavaPropertiesBuilder instance containing the elements
as of 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. |
JavaPropertiesBuilder(Properties.PropertiesBuilder aProperties)
Create a
JavaPropertiesBuilder instance containing the elements
of the provided PropertiesBuilder instance using the default path
delimiter "/" (Delimiter.PATH ) for the path declarations |
JavaPropertiesBuilder(Properties aProperties)
Create a
JavaPropertiesBuilder instance containing the elements
of the provided Properties instance using the default path
delimiter "/" (Delimiter.PATH ) for the path declarations |
JavaPropertiesBuilder(String aFilePath)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(String aFilePath,
boolean isSeekFile)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(String aFilePath,
boolean isSeekFile,
char... aDelimiters)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(String aFilePath,
char... aDelimiters)
Loads the Java properties from the given file's path.
|
JavaPropertiesBuilder(URL aUrl)
Loads the Java properties from the given
URL . |
JavaPropertiesBuilder(URL aUrl,
char... aDelimiters)
Loads the Java properties from the given
URL . |
Modifier and Type | Method and Description |
---|---|
Properties |
loadFrom(InputStream aInputStream,
char... aDelimiters)
Loads the properties from the given
InputStream . |
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. |
flush, isFlushable, loadFrom, reload, reload, saveTo, seekFrom
childrenOf, retrieveFrom, retrieveTo
compute, computeIfAbsent, computeIfPresent, containsKey, get, getDelimiter, getOrDefault, getType, merge, put, putIfAbsent, remove, remove, replace, replace, toDataStructure
clear, clone, containsValue, entrySet, forEach, isEmpty, keySet, putAll, replaceAll, size, values
equals, hashCode, toString
finalize, getClass, notify, notifyAll, 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, flush, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, loadFrom, parseFrom, parseFrom, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, saveTo, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, seekFrom, toSerialized, toSerialized
reload, reload
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
public JavaPropertiesBuilder()
JavaPropertiesBuilder
instance using the default
path delimiter "/" (Delimiter.PATH
) for the path declarations.public JavaPropertiesBuilder(Object aObj)
JavaPropertiesBuilder
instance containing the elements
as of 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."aObj
- The object from which the elements are to be added.public JavaPropertiesBuilder(Properties aProperties)
JavaPropertiesBuilder
instance containing the elements
of the provided Properties
instance using the default path
delimiter "/" (Delimiter.PATH
) for the path declarationsaProperties
- the properties to be added.public JavaPropertiesBuilder(Properties.PropertiesBuilder aProperties)
JavaPropertiesBuilder
instance containing the elements
of the provided PropertiesBuilder
instance using the default path
delimiter "/" (Delimiter.PATH
) for the path declarationsaProperties
- the properties to be added.public JavaPropertiesBuilder(Map<?,?> aProperties)
JavaPropertiesBuilder
instance containing the elements
of the provided Map
instance using the default path delimiter "/"
(Delimiter.PATH
) for the path declarationsaProperties
- the properties to be added.public JavaPropertiesBuilder(File aFile) throws IOException, ParseException
File
.aFile
- The File
from which to load the properties.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 JavaPropertiesBuilder(File aFile, char... aDelimiters) throws IOException, ParseException
File
.aFile
- The File
from which to load the properties.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 JavaPropertiesBuilder(File aFile, boolean isSeekFile) throws IOException, ParseException
File
.
In case you enable the "seek" argument and directly loading from the
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
RuntimeUtility.toConfigDirs()
.aFile
- The File
from which to load the properties.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.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 JavaPropertiesBuilder(File aFile, boolean isSeekFile, char... aDelimiters) throws IOException, ParseException
File
.
In case you enable the "seek" argument and directly loading from the
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
RuntimeUtility.toConfigDirs()
.aFile
- The File
from which to load the properties.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 JavaPropertiesBuilder(String aFilePath) throws IOException, ParseException
aFilePath
- The path to the file from which to load the properties.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 JavaPropertiesBuilder(String aFilePath, char... aDelimiters) throws IOException, ParseException
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.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 JavaPropertiesBuilder(Class<?> aResourceClass, String aFilePath) throws IOException, ParseException
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.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 JavaPropertiesBuilder(Class<?> aResourceClass, String aFilePath, char... aDelimiters) throws IOException, ParseException
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.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 JavaPropertiesBuilder(String aFilePath, boolean isSeekFile) throws IOException, ParseException
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
RuntimeUtility.toConfigDirs()
.aFilePath
- The path to the file from which to load the properties.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.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 JavaPropertiesBuilder(String aFilePath, boolean isSeekFile, char... aDelimiters) throws IOException, ParseException
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
RuntimeUtility.toConfigDirs()
.aFilePath
- The path to the file from which to load the properties.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 JavaPropertiesBuilder(Class<?> aResourceClass, String aFilePath, boolean isSeekFile) throws IOException, ParseException
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
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).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.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.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 JavaPropertiesBuilder(Class<?> aResourceClass, String aFilePath, boolean isSeekFile, char... aDelimiters) throws IOException, ParseException
File
does not succeed, then loads from the first folder
containing such a file as of the specification for the method
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). *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.isSeekFile
- When true, then the properties are loaded as of the
"seek" functionality described above.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 JavaPropertiesBuilder(URL aUrl) throws IOException, ParseException
URL
.aUrl
- The URL
from which to read the properties.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 JavaPropertiesBuilder(URL aUrl, char... aDelimiters) throws IOException, ParseException
URL
.aUrl
- The URL
from which to read the properties.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 JavaPropertiesBuilder(InputStream aInputStream) throws IOException, ParseException
InputStream
.aInputStream
- The InputStream
from which to read the
properties.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 JavaPropertiesBuilder(InputStream aInputStream, char... aDelimiters) throws IOException, ParseException
InputStream
.aInputStream
- The InputStream
from which to read the
properties.aDelimiters
- The path delimiters to be used when parsing the
source's properties.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 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 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 failedCopyright © 2018. All rights reserved.