Package org.refcodes.structure
Class PathMapImpl<T>
- java.lang.Object
-
- org.refcodes.structure.PathMapImpl<T>
-
- Type Parameters:
T
- the generic type
- All Implemented Interfaces:
org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.Dumpable
,org.refcodes.mixin.TypeAccessor<T>
,Containable
,Dictionary<java.lang.String,T>
,Keys<K,V>
,PathMap<T>
public class PathMapImpl<T> extends java.lang.Object implements PathMap<T>
The Class PathMapImpl.
-
-
Nested Class Summary
-
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>
-
-
Constructor Summary
Constructors Modifier Constructor Description PathMapImpl(char aDelimiter, java.lang.Class<T> aType)
Create aPathMap
instance using the provided path delimiter for the path declarations.PathMapImpl(java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl(java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapImpl(java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl(java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
for the path declarations.protected
PathMapImpl(PathMap<T> aPathMap)
Create aPathMap
instance from the providedPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using thePathMap
's path delimiter for the path declarations the the type of thePathMap
.
-
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.boolean
containsValue(java.lang.Object aValue)
This method is defined for the sake ofMap
conformity.T
get(java.lang.Object aKey)
Retrieves the element assigned to the given key.char
getDelimiter()
java.lang.Class<T>
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.PathMap<T>
retrieveFrom(java.lang.String aFromPath)
PathMap<T>
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<T>
values()
Returns aCollection
view of the values related to the contained keys.-
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, directories, directories, directories, directories, directories, fromExternalKey, get, get, getArray, getArray, getBoolean, getBoolean, getByte, getByte, getCharacter, getCharacter, getDouble, getDouble, getFloat, getFloat, getIndexed, getIndexed, getIndexes, getIndexes, getInteger, getInteger, getLong, getLong, getRootPath, getShort, getShort, hasChildren, hasChildren, hasChildren, hasIndexed, hasIndexed, hasParentPath, isArray, isArray, isArray, isArray, isArray, isChild, isChild, isChild, isDirectory, isDirectory, isDirectory, isDirectory, isIndexed, isIndexed, isPath, isRecord, isRecord, isRecord, isRecord, isRootPath, keySet, paths, paths, paths, paths, paths, query, query, queryFrom, queryPaths, queryTo, records, records, records, records, records, retrieve, retrieveFrom, retrieveFrom, retrieveFrom, retrieveTo, retrieveTo, retrieveTo, toDataStructure, toExternalKey, toMap, toMap, toNormalizedPath, toNormalizedPath, toParentPath, toPath, toPath
-
-
-
-
Constructor Detail
-
PathMapImpl
protected PathMapImpl(PathMap<T> aPathMap)
Create aPathMap
instance from the providedPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using thePathMap
's path delimiter for the path declarations the the type of thePathMap
.- Parameters:
aPathMap
- ThePathMap
from which the elements are to be added.
-
PathMapImpl
public PathMapImpl(char aDelimiter, java.lang.Class<T> aType)
Create aPathMap
instance using the provided path delimiter for the path declarations.- Parameters:
aDelimiter
- The path delimiter to be used for the path declarations.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.- Parameters:
aObj
- The object from which the elements are to be added.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.- Parameters:
aToPath
- The sub-path where to insert the object's introspected values to.aObj
- The object from which the elements are to be added.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.- Parameters:
aObj
- The object from which the elements are to be added.aFromPath
- The path from where to start adding elements of the provided object.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
for the path declarations.- Parameters:
aToPath
- The sub-path where to insert the object's introspected values to.aObj
- The object from which the elements are to be added.aFromPath
- The path from where to start adding elements of the provided object.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.- Parameters:
aObj
- The object from which the elements are to be added.aDelimiter
- The path delimiter to be used for the path declarations.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.- Parameters:
aToPath
- The sub-path where to insert the object's introspected values to.aObj
- The object from which the elements are to be added.aDelimiter
- The path delimiter to be used for the path declarations.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.- Parameters:
aObj
- The object from which the elements are to be added.aFromPath
- The path from where to start adding elements of the provided object.aDelimiter
- The path delimiter to be used for the path declarations.aType
- The type of the values being referenced by the paths.
-
PathMapImpl
public PathMapImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.- Parameters:
aToPath
- The sub-path where to insert the object's introspected values to.aObj
- The object from which the elements are to be added.aFromPath
- The path from where to start adding elements of the provided object.aDelimiter
- The path delimiter to be used for the path declarations.aType
- The type of the values being referenced by the paths.
-
-
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<K,V>
- 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.
-
containsValue
public boolean containsValue(java.lang.Object aValue)
This method is defined for the sake ofMap
conformity. Tests whether the provided value has a key assigned.- Specified by:
containsValue
in interfaceKeys<K,V>
- Parameters:
aValue
- The value to test if a key references this value.- Returns:
- True in case the given value is referenced by a key.
-
get
public T 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<T> 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.
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
retrieveFrom
public PathMap<T> 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 interfacePathMap<T>
- 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 PathMap<T> 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.
-
getType
public java.lang.Class<T> getType()
- Specified by:
getType
in interfaceorg.refcodes.mixin.TypeAccessor<T>
-
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<T>
- 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.
-
-