Package org.refcodes.configuration
Class PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
- java.lang.Object
-
- org.refcodes.configuration.PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
-
- All Implemented Interfaces:
ResourcePropertiesFactory
,ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
,org.refcodes.mixin.FilenameExtensionsAccessor
- Enclosing class:
- PolyglotPropertiesBuilder
public static class PolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory extends java.lang.Object implements ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
ThePolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
is a meta factory using a collection ofResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances to deliverResourceProperties.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 astoProperties(Map)
,toProperties(Object)
,toProperties(PropertiesBuilder)
ortoProperties(PropertiesBuilder)
will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.FilenameExtensionsAccessor
org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsBuilder<B extends org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsBuilder<B>>, org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsMutator, org.refcodes.mixin.FilenameExtensionsAccessor.FilenameExtensionsProperty
-
Nested classes/interfaces inherited from interface org.refcodes.configuration.ResourcePropertiesFactory
ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description PolyglotPropertiesBuilderFactory()
Initializes thePolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with a predefined set ofResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances.PolyglotPropertiesBuilderFactory(ResourcePropertiesFactory.ResourcePropertiesBuilderFactory... aFactories)
Initializes thePolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with the givenResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
getFilenameExtensions()
Returns the filename extensions of the ResourcePropertiesFactory in the given order.static byte[]
toByteArray(java.io.InputStream aInputStream)
Converts a byte array from anInputStream
.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.io.File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters)
Loads or seeks the properties from the givenFile
.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.io.InputStream aInputStream, char... aDelimiters)
Reads the properties from the givenInputStream
.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.lang.Class<?> aResourceClass, java.lang.String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters)
Loads the properties from the given file's path.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.lang.Object aObj)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.lang.String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters)
Loads the properties from the given file's path.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.net.URL aUrl, char... aDelimiters)
Loads the properties from the givenURL
.ResourceProperties.ResourcePropertiesBuilder
toProperties(java.util.Map<?,?> aPropertiesBuilder)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.ResourceProperties.ResourcePropertiesBuilder
toProperties(Properties aProperties)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.ResourceProperties.ResourcePropertiesBuilder
toProperties(Properties.PropertiesBuilder aPropertiesBuilder)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.configuration.ResourcePropertiesFactory.ResourcePropertiesBuilderFactory
toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties, toProperties
-
-
-
-
Constructor Detail
-
PolyglotPropertiesBuilderFactory
public PolyglotPropertiesBuilderFactory()
Initializes thePolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with a predefined set ofResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances.
-
PolyglotPropertiesBuilderFactory
public PolyglotPropertiesBuilderFactory(ResourcePropertiesFactory.ResourcePropertiesBuilderFactory... aFactories)
Initializes thePolyglotPropertiesBuilder.PolyglotPropertiesBuilderFactory
with the givenResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instances. Them factories will be queried in the order being provided.- Parameters:
aFactories
- The factories to be added.
-
-
Method Detail
-
getFilenameExtensions
public java.lang.String[] getFilenameExtensions()
Returns the filename extensions of the ResourcePropertiesFactory in the given order.- Specified by:
getFilenameExtensions
in interfaceorg.refcodes.mixin.FilenameExtensionsAccessor
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.lang.Class<?> aResourceClass, java.lang.String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads the properties from the given file's path. A providedConfigLocator
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).- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
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
- TheConfigLocator
describes the locations to additional crawl for the desired file.aDelimiters
- The path delimiters to be used when parsing the source's properties.- Returns:
- The accordingly constructed
ResourceProperties
. - 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.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.io.File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads or seeks the properties from the givenFile
. A providedConfigLocator
describes the locations to additional crawl for the desired file.- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aFile
- TheFile
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.- Returns:
- The accordingly constructed
ResourceProperties
. - 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.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.io.InputStream aInputStream, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Reads the properties from the givenInputStream
.- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aInputStream
- TheInputStream
from which to read the properties.aDelimiters
- The path delimiters to be used when parsing the source's properties.- Returns:
- The accordingly constructed
ResourceProperties
. - 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.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.util.Map<?,?> aPropertiesBuilder)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance. Create aResourceProperties
instance containing the elements of the providedMap
instance using the path delimiter "/" (Delimiter.PATH
) for the path declarations- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aPropertiesBuilder
- the properties to be added.- Returns:
- The accordingly constructed
ResourceProperties
.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.lang.Object aObj)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance. Create aResourceProperties
instance containing the elements as ofPathMap.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 typeMap
,Collection
and arrays are identified and handled as of their type: The path for each value in aMap
is appended with its according key. The path for each value in aCollection
or array is appended with its according index of occurrence (in case of aList
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."- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aObj
- The object from which the elements are to be added.- Returns:
- The accordingly constructed
ResourceProperties
.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(Properties aProperties)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance. Create aResourceProperties
instance containing the elements of the providedProperties
instance using the path delimiter "/" (Delimiter.PATH
) for the path declarations- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aProperties
- the properties to be added.- Returns:
- The accordingly constructed
ResourceProperties
.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(Properties.PropertiesBuilder aPropertiesBuilder)
Will returnResourceProperties.ResourcePropertiesBuilder
created by the first addedResourcePropertiesFactory.ResourcePropertiesBuilderFactory
instance. Create aResourceProperties
instance containing the elements of the providedProperties.PropertiesBuilder
instance using the default path delimiter "/" (Delimiter.PATH
) for the path declarations- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aPropertiesBuilder
- the properties to be added.- Returns:
- The accordingly constructed
ResourceProperties
.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.lang.String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads the properties from the given file's path. A providedConfigLocator
describes the locations to additional crawl for the desired file.- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aFilePath
- The path to the file 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.- Returns:
- The accordingly constructed
ResourceProperties
. - 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.
-
toProperties
public ResourceProperties.ResourcePropertiesBuilder toProperties(java.net.URL aUrl, char... aDelimiters) throws java.io.IOException, java.text.ParseException
Loads the properties from the givenURL
.- Specified by:
toProperties
in interfaceResourcePropertiesFactory
- Specified by:
toProperties
in interfaceResourcePropertiesFactory.ResourcePropertiesBuilderFactory
- Parameters:
aUrl
- TheURL
from which to read the properties.aDelimiters
- The path delimiters to be used when parsing the source's properties.- Returns:
- The accordingly constructed
ResourceProperties
. - 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.
-
toByteArray
public static byte[] toByteArray(java.io.InputStream aInputStream) throws java.io.IOException
Converts a byte array from anInputStream
.- Parameters:
aInputStream
- TheInputStream
to be converted.- Returns:
- The byte array from the
InputStream
. - Throws:
java.io.IOException
- Thrown in case there were problems reading theInputStream
.
-
-