Package org.refcodes.structure
Class CanonicalMapImpl
- java.lang.Object
-
- org.refcodes.structure.CanonicalMapImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.Dumpable
,org.refcodes.mixin.TypeAccessor<java.lang.String>
,CanonicalMap
,Containable
,Dictionary<java.lang.String,T>
,Keys<java.lang.String,T>
,PathMap<java.lang.String>
,PropertiesAccessorMixin
public class CanonicalMapImpl extends java.lang.Object implements CanonicalMap
The Class CanonicalMapImpl.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.structure.CanonicalMap
CanonicalMap.CanonicalMapBuilder, 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
Dictionary.MutableDictionary<K,V>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Keys
Keys.MutableKeys<K,V>, Keys.MutableValues<K,V>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PathMap
PathMap.MutablePathMap<T>, PathMap.PathMapBuilder<T>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PropertiesAccessorMixin
PropertiesAccessorMixin.PropertiesBuilderMixin<T>, PropertiesAccessorMixin.PropertiesMixin, PropertiesAccessorMixin.PropertiesMutatorMixin
-
-
Field Summary
Fields Modifier and Type Field Description protected CanonicalMap.CanonicalMapBuilder
_canonicalMap
-
Fields inherited from interface org.refcodes.structure.CanonicalMap
DEFAULT_COMMENT
-
-
Constructor Summary
Constructors Constructor Description CanonicalMapImpl(java.lang.Object aObject)
Instantiates a new canonical map impl.CanonicalMapImpl(java.util.Map<?,?> aProperties)
Instantiates a new canonical map impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.Object aKey)
Tests whether there is an element with the given key.java.lang.String
get(java.lang.Object aKey)
Retrieves the element assigned to the given key.char
getDelimiter()
java.lang.Class<java.lang.String>
getType()
boolean
isEmpty()
Tests whether the accumulation is empty or not.java.util.Set<java.lang.String>
keySet()
Retrieves a collection containing all the keys found in the elements of this collection.CanonicalMap
retrieveFrom(java.lang.String aFromPath)
CanonicalMap
retrieveTo(java.lang.String aToPath)
int
size()
Returns the number of data elements contained in the collection.java.lang.Object
toDataStructure(java.lang.String aFromPath)
Similar to thePathMap.toMap(String)
method, though in case all the keys of a nestedMap
instance (applicable to the rootMap
as well) represent an array (as ofPathMap.getArray( String)
), then an array is generated where the index of each value in theMap
is represented by the number representation of theMap
's key for that value.java.util.Collection<java.lang.String>
values()
Returns aCollection
view of the values related to the contained keys.-
Methods inherited from interface org.refcodes.structure.CanonicalMap
containsValue, getBoolean, getBoolean, getByte, getByte, getCharacter, getCharacter, getDirAt, getDirAt, getDouble, getDouble, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getShort, getShort, query, query, queryFrom, queryTo, retrieve, retrieveFrom, retrieveFrom, retrieveTo, retrieveTo, retrieveTo, 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, containsKey, containsKey, 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, hasPath, hasPath, hasValueAt, hasValueAt, hasValueAt, hasValueAt, isArray, isArray, isArray, isArray, isArray, isArrayIndex, isArrayIndex, isArrayIndex, isArrayIndex, isArrayIndex, isChild, isChild, isChild, isDir, isDir, isDir, isDir, isDirIndex, isDirIndex, isDirIndex, isDirIndex, isLeaf, isLeaf, isLeaf, isLeaf, isRootPath, keySet, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, leaves, leaves, leaves, leaves, leaves, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, paths, paths, paths, paths, paths, queryPaths, retrieveFrom, toDataStructure, toExternalPath, toLeaf, toMap, toMap, toNormalizedPath, toParentPath, toPath, toPath, toPath, toPathElements
-
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
-
-
-
-
Field Detail
-
_canonicalMap
protected CanonicalMap.CanonicalMapBuilder _canonicalMap
-
-
Constructor Detail
-
CanonicalMapImpl
public CanonicalMapImpl(java.lang.Object aObject)
Instantiates a new canonical map impl.- Parameters:
aObject
- the object
-
CanonicalMapImpl
public CanonicalMapImpl(java.util.Map<?,?> aProperties)
Instantiates a new canonical map impl.- Parameters:
aProperties
- the properties
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object aKey)
Tests whether there is an element with the given key.- Specified by:
containsKey
in interfaceKeys<java.lang.String,T>
- Parameters:
aKey
- The key for which to test whether there is an element.- Returns:
- True in case there is an element for the given key.
-
get
public java.lang.String get(java.lang.Object aKey)
Retrieves the element assigned to the given key.
-
keySet
public java.util.Set<java.lang.String> keySet()
Retrieves a collection containing all the keys found in the elements of this collection.
-
values
public java.util.Collection<java.lang.String> values()
Returns aCollection
view of the values related to the contained keys.
-
size
public int size()
Returns the number of data elements contained in the collection.- Specified by:
size
in interfaceContainable
- Returns:
- An integer representing the number of items stored in the accumulation.
-
isEmpty
public boolean isEmpty()
Tests whether the accumulation is empty or not. Returns true if the accumulation is empty, else false is returned.- Specified by:
isEmpty
in interfaceContainable
- Returns:
- True if no element is contained in the accumulation - else false is returned.
-
retrieveFrom
public CanonicalMap retrieveFrom(java.lang.String aFromPath)
Extracts a newPathMap
from the elements of thisPathMap
found below the "from-path". The sub-paths will be the root paths for the newPathMap
. Given we have a value for path "/dog/cat" in thePathMap
and we callPathMap.retrieveFrom(String)
with "/dog", then the resultingPathMap
will contain the path "/cat" for that value.- Specified by:
retrieveFrom
in interfaceCanonicalMap
- Specified by:
retrieveFrom
in interfacePathMap<java.lang.String>
- Parameters:
aFromPath
- The path from where to start extracting the paths.- Returns:
- The
PathMap
with the elements below the provided path which are root elements in the newPathMap
.
-
retrieveTo
public CanonicalMap retrieveTo(java.lang.String aToPath)
Extracts a newPathMap
from thisPathMap
's elements with the paths relocated to the provided "to-path". Given we have a value for path "/dog/cat" in thePathMap
and we callPathMap.retrieveTo(String)
with "/animals", then the resultingPathMap
will contain the path "/animals/dog/cat" for that value.- Specified by:
retrieveTo
in interfaceCanonicalMap
- Specified by:
retrieveTo
in interfacePathMap<java.lang.String>
- Parameters:
aToPath
- The path where to relocate the paths of thisPathMap
to.- Returns:
- The
PathMap
with the elements from the providedPathMap
with accordingly relocated paths.
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
getType
public java.lang.Class<java.lang.String> getType()
- Specified by:
getType
in interfaceorg.refcodes.mixin.TypeAccessor<java.lang.String>
-
toDataStructure
public java.lang.Object toDataStructure(java.lang.String aFromPath)
Similar to thePathMap.toMap(String)
method, though in case all the keys of a nestedMap
instance (applicable to the rootMap
as well) represent an array (as ofPathMap.getArray( String)
), then an array is generated where the index of each value in theMap
is represented by the number representation of theMap
's key for that value. The result is a data structure consisting ofMap
instances and arrays.- Specified by:
toDataStructure
in interfacePathMap<java.lang.String>
- Parameters:
aFromPath
- The path below which thePathMap
to be converted into a data structure.- Returns:
- A data structure being a mixture of
Map
instances and arrays representing the data below the given path.
-
-