Package org.refcodes.configuration
Class NormalizedPropertiesDecorator
- java.lang.Object
-
- org.refcodes.configuration.AbstractPropertiesDecorator<Properties>
-
- org.refcodes.configuration.NormalizedPropertiesDecorator
-
- All Implemented Interfaces:
Properties
,org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.Dumpable
,org.refcodes.mixin.TypeAccessor<java.lang.String>
,org.refcodes.structure.CanonicalMap
,org.refcodes.structure.Containable
,org.refcodes.structure.Dictionary<java.lang.String,T>
,org.refcodes.structure.Keys<java.lang.String,T>
,org.refcodes.structure.PathMap<java.lang.String>
,org.refcodes.structure.PropertiesAccessorMixin
public class NormalizedPropertiesDecorator extends AbstractPropertiesDecorator<Properties> implements Properties
TheNormalizedPropertiesDecorator
type decorates aProperties
instance and converts a path delimiter such as the full-stop (".") to theProperties
properties' path delimiter slash ("/", as ofAbstractPropertiesDecorator.getDelimiter()
). E.g. you get a projection of yourProperties
using "." as the path delimiter as if them had a "/" as path delimiter. InvokingNormalizedPropertiesDecorator(Properties, char[])
the constructor, you can define the delimiters to be projected to the default "/" delimiter (as ofAbstractPropertiesDecorator.getDelimiter()
). Upon accessing a key, the implementation first tests whether the decorated (underlying)Properties
contain this key, then the decorated (underlying)Properties
' keys are tested by converting the keys using the first provided delimiter to be replaced by the "/" delimiter". If we have a match, then this property is processed, else the procedure continues with the next delimiter. This means that the first match wins, if we have succeeding matches with succeeding delimiters then anAmbigousKeyRuntimeException
is thrown In case of accessing thekeySet()
, all keys are converted by replacing all the provided delimiters (or the full-stop ("."), depending on the constructor you called) to the default delimiter "/". In case we have a key collision then anAmbigousKeyRuntimeException
is thrown.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.structure.CanonicalMap
org.refcodes.structure.CanonicalMap.CanonicalMapBuilder, org.refcodes.structure.CanonicalMap.MutableCanonicalMap
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Dictionary
org.refcodes.structure.Dictionary.MutableDictionary<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Keys
org.refcodes.structure.Keys.MutableKeys<K extends java.lang.Object,V extends java.lang.Object>, org.refcodes.structure.Keys.MutableValues<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PathMap
org.refcodes.structure.PathMap.MutablePathMap<T extends java.lang.Object>, org.refcodes.structure.PathMap.PathMapBuilder<T extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.configuration.Properties
Properties.MutableProperties, Properties.PropertiesBuilder
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PropertiesAccessorMixin
org.refcodes.structure.PropertiesAccessorMixin.PropertiesBuilderMixin<T extends java.lang.Object>, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMixin, org.refcodes.structure.PropertiesAccessorMixin.PropertiesMutatorMixin
-
-
Field Summary
-
Fields inherited from interface org.refcodes.configuration.Properties
DEFAULT_COMMENT
-
-
Constructor Summary
Constructors Constructor Description NormalizedPropertiesDecorator(Properties aProperties)
Decorates the providedProperties
with additional behavior by normalizing the key representing the path pointing to the according value.NormalizedPropertiesDecorator(Properties aProperties, char[] aDelimiters)
Decorates the providedProperties
with additional behavior by normalizing the key representing the path pointing to the according value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.Object aKey)
protected static java.lang.String
fromNormalized(java.lang.String aKey, char aFromDelimiter, char aToDelimiter)
java.lang.String
get(java.lang.Object aKey)
java.util.Set<java.lang.String>
keySet()
Properties
retrieveFrom(java.lang.String aFromPath)
Properties
retrieveTo(java.lang.String aToPath)
protected java.lang.String
toDelimiters()
protected static java.lang.String
toNormalized(java.lang.String aKey, char aToDelimiter, char... aFromDelimiters)
-
Methods inherited from class org.refcodes.configuration.AbstractPropertiesDecorator
getDelimiter, getProperties, isEmpty, setProperties, size, toDataStructure, values
-
Methods inherited from interface org.refcodes.structure.CanonicalMap
getBoolean, getBoolean, getByte, getByte, getCharacter, getCharacter, getDouble, getDouble, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getShort, getShort, toInstance, toInstance, toType, toType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.structure.PathMap
children, children, children, children, children, dirs, dirs, dirs, dirs, dirs, fromExternalPath, get, get, getArray, getArray, getArray, getArray, getArrayIndexes, getArrayIndexes, getArrayIndexes, getArrayIndexes, getDirAt, getDirAt, getDirAt, getDirIndexes, getDirIndexes, getDirIndexes, getDirIndexes, getRootPath, getValueAt, getValueAt, getValueAt, getValueAt, getValueAt, hasChildren, hasChildren, hasChildren, hasChildren, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasParentPath, hasPath, hasValueAt, hasValueAt, hasValueAt, hasValueAt, isArray, isArray, isArray, isArray, isArray, isChild, isChild, isChild, isDir, isDir, isDir, isDir, isDirectory, isDirectory, isDirectory, isDirectory, isRecord, isRecord, isRecord, isRecord, isRootPath, keySet, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, paths, paths, paths, paths, paths, queryPaths, records, records, records, records, records, toDataStructure, toDataStructure, toExternalPath, toLeaf, toMap, toNormalizedPath, toParentPath, toPath, toPath, toPath, toPathElements
-
Methods inherited from interface org.refcodes.configuration.Properties
containsValue, getDelimiter, getDirAt, getDirAt, getType, query, query, queryFrom, queryTo, retrieve, retrieveFrom, retrieveFrom, retrieveFrom, retrieveTo, retrieveTo, retrieveTo, toMap, toProperties, toPropertyPath
-
Methods inherited from interface org.refcodes.structure.PropertiesAccessorMixin
asArray, asArray, asArray, asArray, asArray, asArray, asBooleanArray, asBooleanArray, asBooleanArray, asBooleanArray, asBooleanArray, asBooleanArray, asByteArray, asByteArray, asByteArray, asByteArray, asByteArray, asByteArray, asCharacterArray, asCharacterArray, asCharacterArray, asCharacterArray, asCharacterArray, asCharacterArray, asDoubleArray, asDoubleArray, asDoubleArray, asDoubleArray, asDoubleArray, asDoubleArray, asFloatArray, asFloatArray, asFloatArray, asFloatArray, asFloatArray, asFloatArray, asIntegerArray, asIntegerArray, asIntegerArray, asIntegerArray, asIntegerArray, asIntegerArray, asLongArray, asLongArray, asLongArray, asLongArray, asLongArray, asLongArray, asShortArray, asShortArray, asShortArray, asShortArray, asShortArray, asShortArray, containsKey, get, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCharacter, getCharacter, getCharacter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInteger, getInteger, getInteger, getLong, getLong, getLong, getShort, getShort, getShort, use, useBoolean, useBoolean, useByte, useByte, useDouble, useDouble, useFloat, useFloat, useInteger, useInteger, useLong, useLong, useShort, useShort
-
-
-
-
Constructor Detail
-
NormalizedPropertiesDecorator
public NormalizedPropertiesDecorator(Properties aProperties)
Decorates the providedProperties
with additional behavior by normalizing the key representing the path pointing to the according value. You provideProperties
with a path delimiter different from the default delimiter and you getProperties
which act as if the delimiter was the default delimiter: Paths containing the namespace delimiter "." (as ofDelimiter.NAMESPACE
are converted to paths' with delimiter "/" (as ofDelimiter.PATH
. Changes applied to the providedProperties
affect the decorator.- Parameters:
aProperties
- TheProperties
to be decorated.
-
NormalizedPropertiesDecorator
public NormalizedPropertiesDecorator(Properties aProperties, char[] aDelimiters)
Decorates the providedProperties
with additional behavior by normalizing the key representing the path pointing to the according value. You provideProperties
with a path delimiter different from the default delimiter and you getProperties
which act as if the delimiter was the default delimiter: Paths containing the provided delimiters are converted to the paths' with delimiter "/" (as ofDelimiter.PATH
. Changes applied to the providedProperties
affect the decorator.- Parameters:
aProperties
- TheProperties
to be decorated.aDelimiters
- The delimiters to be converted forth and back
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object aKey)
- Specified by:
containsKey
in interfaceorg.refcodes.structure.Keys<java.lang.String,T extends java.lang.Object>
- Overrides:
containsKey
in classAbstractPropertiesDecorator<Properties>
-
get
public java.lang.String get(java.lang.Object aKey)
- Specified by:
get
in interfaceorg.refcodes.structure.Keys<java.lang.String,T extends java.lang.Object>
- Overrides:
get
in classAbstractPropertiesDecorator<Properties>
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfaceorg.refcodes.structure.Keys<java.lang.String,T extends java.lang.Object>
- Overrides:
keySet
in classAbstractPropertiesDecorator<Properties>
-
retrieveFrom
public Properties retrieveFrom(java.lang.String aFromPath)
- Specified by:
retrieveFrom
in interfaceorg.refcodes.structure.CanonicalMap
- Specified by:
retrieveFrom
in interfaceorg.refcodes.structure.PathMap<java.lang.String>
- Specified by:
retrieveFrom
in interfaceProperties
- Overrides:
retrieveFrom
in classAbstractPropertiesDecorator<Properties>
-
retrieveTo
public Properties retrieveTo(java.lang.String aToPath)
- Specified by:
retrieveTo
in interfaceorg.refcodes.structure.CanonicalMap
- Specified by:
retrieveTo
in interfaceorg.refcodes.structure.PathMap<java.lang.String>
- Specified by:
retrieveTo
in interfaceProperties
- Overrides:
retrieveTo
in classAbstractPropertiesDecorator<Properties>
-
toDelimiters
protected java.lang.String toDelimiters()
-
fromNormalized
protected static java.lang.String fromNormalized(java.lang.String aKey, char aFromDelimiter, char aToDelimiter)
-
toNormalized
protected static java.lang.String toNormalized(java.lang.String aKey, char aToDelimiter, char... aFromDelimiters)
-
-