ResourcePropertiesFactory
, ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
, org.refcodes.mixin.FilenameExtensionsAccessor
public static class PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory extends Object implements ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
is a meta factory using a
collection of ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances to
deliver ResourceProperties.ResourcePropertiesBuilder
instances.
In case a properties file for a filename was not found, then the
according factories filename extension
(FilenameExtensionsAccessor.getFilenameExtensions()
) is
append to the filename and probing is repeated.
Any factory method such as toProperties(Map)
,
toProperties(Object)
, toProperties(PropertiesBuilder)
or toProperties(PropertiesBuilder)
will return
ResourceProperties.ResourcePropertiesBuilder
created by the first added
ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsBuilder<B extends org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsBuilder<B>>, org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsMutator, org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsProperty
ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
Constructor | Description |
---|---|
PolyglotPropertiesBuilderFactory() |
Initializes the
PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory with a
predefined set of ResourcePropertiesFactory.ResourcePropertiesBuilderFactory instances. |
PolyglotPropertiesBuilderFactory(ResourcePropertiesFactory.ResourcePropertiesBuilderFactory... aFactories) |
Initializes the
PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory with the
given ResourcePropertiesFactory.ResourcePropertiesBuilderFactory instances. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties
public PolyglotPropertiesBuilderFactory()
PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with a
predefined set of ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances.public PolyglotPropertiesBuilderFactory(ResourcePropertiesFactory.ResourcePropertiesBuilderFactory... aFactories)
PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with the
given ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances. Them
factories will be queried in the order being provided.aFactories
- The factories to be added.public String[] getFilenameExtensions()
getFilenameExtensions
in interface org.refcodes.mixin.FilenameExtensionsAccessor
public ResourceProperties.ResourcePropertiesBuilder toProperties(Class<?> aResourceClass, String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws IOException, ParseException
ConfigLocator
describes the locations to additional
crawl for the desired file.
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).toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
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.ResourceProperties
.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 ResourceProperties.ResourcePropertiesBuilder toProperties(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws IOException, ParseException
File
.
A provided ConfigLocator
describes the locations to additional
crawl for the desired file.toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
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.ResourceProperties
.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 ResourceProperties.ResourcePropertiesBuilder toProperties(InputStream aInputStream, char... aDelimiters) throws IOException, ParseException
InputStream
.toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aInputStream
- The InputStream
from which to read the
properties.aDelimiters
- The path delimiters to be used when parsing the
source's properties.ResourceProperties
.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 ResourceProperties.ResourcePropertiesBuilder toProperties(Map<?,?> aPropertiesBuilder)
ResourceProperties.ResourcePropertiesBuilder
created by the first
added ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.
Create a ResourceProperties
instance containing the elements of
the provided Map
instance using the path delimiter "/"
(Delimiter.PATH
) for the path declarationstoProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aPropertiesBuilder
- the properties to be added.ResourceProperties
.public ResourceProperties.ResourcePropertiesBuilder toProperties(Object aObj)
ResourceProperties.ResourcePropertiesBuilder
created by the first
added ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.
Create a ResourceProperties
instance containing the elements as
of PathMap.MutablePathMap.insert(Object)
using the 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."toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aObj
- The object from which the elements are to be added.ResourceProperties
.public ResourceProperties.ResourcePropertiesBuilder toProperties(Properties aProperties)
ResourceProperties.ResourcePropertiesBuilder
created by the first
added ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.
Create a ResourceProperties
instance containing the elements of
the provided Properties
instance using the path delimiter "/"
(Delimiter.PATH
) for the path declarationstoProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aProperties
- the properties to be added.ResourceProperties
.public ResourceProperties.ResourcePropertiesBuilder toProperties(Properties.PropertiesBuilder aPropertiesBuilder)
ResourceProperties.ResourcePropertiesBuilder
created by the first
added ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.
Create a ResourceProperties
instance containing the elements of
the provided Properties.PropertiesBuilder
instance using the default path
delimiter "/" (Delimiter.PATH
) for the path declarationstoProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aPropertiesBuilder
- the properties to be added.ResourceProperties
.public ResourceProperties.ResourcePropertiesBuilder toProperties(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws IOException, ParseException
ConfigLocator
describes the locations to additional
crawl for the desired file.toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
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.ResourceProperties
.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 ResourceProperties.ResourcePropertiesBuilder toProperties(URL aUrl, char... aDelimiters) throws IOException, ParseException
URL
.toProperties
in interface ResourcePropertiesFactory
toProperties
in interface ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
aUrl
- The URL
from which to read the properties.aDelimiters
- The path delimiters to be used when parsing the
source's properties.ResourceProperties
.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 static byte[] toByteArray(InputStream aInputStream) throws IOException
InputStream
.aInputStream
- The InputStream
to be converted.InputStream
.IOException
- Thrown in case there were problems reading the
InputStream
.Copyright © 2018. All rights reserved.