ResourcePropertiesFactory
, org.refcodes.mixin.FilenameExtensionsAccessor
public static class PolyglotProperties.PolyglotPropertiesFactory extends Object implements ResourcePropertiesFactory
PolyglotProperties.PolyglotPropertiesFactory
is a meta factory using a
collection of ResourcePropertiesFactory
instances to deliver
ResourceProperties
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(Properties)
or
toProperties(PropertiesBuilder)
will return
ResourceProperties
created by the first added
ResourcePropertiesFactory
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 |
---|---|
PolyglotPropertiesFactory() |
Initializes the
PolyglotProperties.PolyglotPropertiesFactory with a predefined
set of ResourcePropertiesFactory instances. |
PolyglotPropertiesFactory(ResourcePropertiesFactory... aFactories) |
Initializes the
PolyglotProperties.PolyglotPropertiesFactory with the given
ResourcePropertiesFactory instances. |
Modifier and Type | Method | Description |
---|---|---|
String[] |
getFilenameExtensions() |
Returns the filename extensions of the ResourcePropertiesFactory in
the given order.
|
static byte[] |
toByteArray(InputStream aInputStream) |
Converts a byte array from an
InputStream . |
ResourceProperties |
toProperties(File aFile,
org.refcodes.runtime.ConfigLocator aConfigLocator,
char... aDelimiters) |
Loads or seeks the properties from the given
File . |
ResourceProperties |
toProperties(InputStream aInputStream,
char... aDelimiters) |
Reads the properties from the given
InputStream . |
ResourceProperties |
toProperties(Class<?> aResourceClass,
String aFilePath,
org.refcodes.runtime.ConfigLocator aConfigLocator,
char... aDelimiters) |
Loads the properties from the given file's path.
|
ResourceProperties |
toProperties(Object aObj) |
Will return
ResourceProperties created by the first added
ResourcePropertiesFactory instance. |
ResourceProperties |
toProperties(String aFilePath,
org.refcodes.runtime.ConfigLocator aConfigLocator,
char... aDelimiters) |
Loads the properties from the given file's path.
|
ResourceProperties |
toProperties(URL aUrl,
char... aDelimiters) |
Loads the properties from the given
URL . |
ResourceProperties |
toProperties(Map<?,?> aProperties) |
Will return
ResourceProperties created by the first added
ResourcePropertiesFactory instance. |
ResourceProperties |
toProperties(Properties aProperties) |
Will return
ResourceProperties created by the first added
ResourcePropertiesFactory instance. |
ResourceProperties |
toProperties(Properties.PropertiesBuilder aProperties) |
Will return
ResourceProperties created by the first added
ResourcePropertiesFactory instance. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties
public PolyglotPropertiesFactory()
PolyglotProperties.PolyglotPropertiesFactory
with a predefined
set of ResourcePropertiesFactory
instances.public PolyglotPropertiesFactory(ResourcePropertiesFactory... aFactories)
PolyglotProperties.PolyglotPropertiesFactory
with the given
ResourcePropertiesFactory
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 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
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 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
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 toProperties(InputStream aInputStream, char... aDelimiters) throws IOException, ParseException
InputStream
.toProperties
in interface ResourcePropertiesFactory
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 toProperties(Map<?,?> aProperties)
ResourceProperties
created by the first added
ResourcePropertiesFactory
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
aProperties
- the properties to be added.ResourceProperties
.public ResourceProperties toProperties(Object aObj)
ResourceProperties
created by the first added
ResourcePropertiesFactory
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
aObj
- The object from which the elements are to be added.ResourceProperties
.public ResourceProperties toProperties(Properties aProperties)
ResourceProperties
created by the first added
ResourcePropertiesFactory
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
aProperties
- the properties to be added.ResourceProperties
.public ResourceProperties toProperties(Properties.PropertiesBuilder aProperties)
ResourceProperties
created by the first added
ResourcePropertiesFactory
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
aProperties
- the properties to be added.ResourceProperties
.public ResourceProperties 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
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 toProperties(URL aUrl, char... aDelimiters) throws IOException, ParseException
URL
.toProperties
in interface ResourcePropertiesFactory
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.