org.eclipse.smila.datamodel.id
Interface Id
- All Superinterfaces:
- java.io.Serializable
- All Known Implementing Classes:
- IdImpl
public interface Id
- extends java.io.Serializable
Interface for Ids of SMILA records. A record Id must contain:
- data source : symbolic unique name for the source of this record. It does not contain any access details itself,
but identifes a data source configuraton somewhere else in the system that contains the necessary details.
- key of source object in data source, relative to the definitions of the data source. Source objects can have
multiple named key values, e.g. in database tables with a primary key consisting of multiple columns. The data source
configuration is necessary to interpret the key information correctly.
During processing, the record Id may be be extended:
- Element: part of a container, e.g. path in archive (what about recursion: part of part of part...), attachment
index in mails, etc. The element is identified by another key which is relative to the container element.
- Fragment: identified by page number, section number, section name, etc.
Because Ids must be immutable objects to be used as hash keys, extending an Id means to create a new Id with the
additional part. Ids which contain fragment names already cannot be extended by new element keys.
- Author:
- jschumacher
Method Summary |
Id |
createCompoundId()
create a new Id for the containing compund of this Id. |
Id |
createElementId(Key elementKey)
create a new Id from this Id by adding a container element key. |
Id |
createElementId(java.lang.String elementName)
create a new Id from this Id by adding a simple unnamed container element key. |
Id |
createFragmentId(java.lang.String framentName)
create a new Id from this Id by adding a fragment name. |
java.util.List<? extends Key> |
getElementKeys()
get the list of container element keys. |
java.util.List<java.lang.String> |
getFragmentNames()
get the list of fragment names. |
java.lang.String |
getIdHash()
Create a hash string for this Id that can be used by databases as simple primary key. |
Key |
getKey()
key of the source object with respect to the data source configuration. |
java.lang.String |
getSource()
name of the data source containing the object. |
boolean |
hasElementKeys()
check if this Id contains element keys. |
boolean |
hasFragmentNames()
check if this Id contains fragment names. |
getSource
java.lang.String getSource()
- name of the data source containing the object.
- Returns:
- data source name.
getKey
Key getKey()
- key of the source object with respect to the data source configuration.
- Returns:
- source object key.
hasElementKeys
boolean hasElementKeys()
- check if this Id contains element keys.
- Returns:
- true if this contains element keys, else false.
getElementKeys
java.util.List<? extends Key> getElementKeys()
- get the list of container element keys. The implementation must ensure that a modification of this list does not
modify the Id.
- Returns:
- list of container element keys.
hasFragmentNames
boolean hasFragmentNames()
- check if this Id contains fragment names.
- Returns:
- true if this contains fragment names, else false.
getFragmentNames
java.util.List<java.lang.String> getFragmentNames()
- get the list of fragment names. The implementation must ensure that a modification of this list does not modify the
Id.
- Returns:
- list of fragment names.
createElementId
Id createElementId(Key elementKey)
throws IdHandlingException
- create a new Id from this Id by adding a container element key.
- Parameters:
elementKey
- the container element key
- Returns:
- an extended for the container element.
- Throws:
IdHandlingException
- if this cannot be extended with element keys, because it contains fragment names already.
createElementId
Id createElementId(java.lang.String elementName)
throws IdHandlingException
- create a new Id from this Id by adding a simple unnamed container element key.
- Parameters:
elementName
- the key value of the container element
- Returns:
- an extended for the container element.
- Throws:
IdHandlingException
- if this cannot be extended with element keys, because it contains fragment names already.
createFragmentId
Id createFragmentId(java.lang.String framentName)
- create a new Id from this Id by adding a fragment name.
- Parameters:
framentName
- name of the fragment
- Returns:
- an extended Id for the fragment.
createCompoundId
Id createCompoundId()
throws IdHandlingException
- create a new Id for the containing compund of this Id. This is the Id derived by removing the last fragment name,
if this Id has fragments or the last container element key, if it only has elements keys. If this Id has neither
element keys nor fragment names, an exception is thrown.
- Returns:
- Id of the compound containing this Id.
- Throws:
IdHandlingException
- if this is not a compund part Id.
getIdHash
java.lang.String getIdHash()
- Create a hash string for this Id that can be used by databases as simple primary key. The implementation must make
sure that different Ids lead to different Id hashes.
- Returns:
- a hash string for this Id