org.mymedialite.data
Class HierarchicalEntityMapping
java.lang.Object
org.mymedialite.data.EntityMapping
org.mymedialite.data.HierarchicalEntityMapping
- All Implemented Interfaces:
- IEntityMapping, IHierarchicalEntityMapping
public class HierarchicalEntityMapping
- extends EntityMapping
- implements IHierarchicalEntityMapping
Class to map external hierarchical entity IDs to unique internal integer ones.
Hierarchical attributes must be defined by a path-like string which is divided into hierarchical nodes by a separator character.
The default separator character is "/" but it can be explicitly specified in the Constructor.
Leading and trailing separator characters are ignored in all methods.
When an internal ID is requested for a hierarchical attribute using the toInternalID methods an internal ID is
allocated to each attribute and all its parent nodes.
Method Summary |
java.lang.Integer |
getParentID(int internal_id)
Get the internal ID of the parent node of a hierarchical attribute. |
IntList |
toInternalID(java.util.List<java.lang.String> original_id_list)
Get the internal IDs of a list of given entities. |
java.lang.Integer |
toInternalID(java.lang.String original_id)
Get internal ID of a given entity. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HierarchicalEntityMapping
public HierarchicalEntityMapping()
HierarchicalEntityMapping
public HierarchicalEntityMapping(java.lang.String s)
- Create a HierarchicalEntityMapping with a specified path separator character.
- Parameters:
s
- the path separator character.
toInternalID
public java.lang.Integer toInternalID(java.lang.String original_id)
- Description copied from class:
EntityMapping
- Get internal ID of a given entity.
If the given external ID is unknown, create a new internal ID for it and store the mapping.
- Specified by:
toInternalID
in interface IEntityMapping
- Overrides:
toInternalID
in class EntityMapping
- Parameters:
original_id
- the original (external) ID of the entity
- Returns:
- the internal ID of the entity
toInternalID
public IntList toInternalID(java.util.List<java.lang.String> original_id_list)
- Description copied from class:
EntityMapping
- Get the internal IDs of a list of given entities.
- Specified by:
toInternalID
in interface IEntityMapping
- Overrides:
toInternalID
in class EntityMapping
- Parameters:
original_id_list
- the list of original (external) IDs
- Returns:
- a list of internal IDs
getParentID
public java.lang.Integer getParentID(int internal_id)
- Description copied from interface:
IHierarchicalEntityMapping
- Get the internal ID of the parent node of a hierarchical attribute.
- Specified by:
getParentID
in interface IHierarchicalEntityMapping
- Parameters:
internal_id
- the internal ID of the hierarchical attribute.
- Returns:
- the internal ID of the parent, or null if the parent is the root