SMILA (incubation) API documentation

org.eclipse.smila.datamodel.id.impl
Class IdImpl

java.lang.Object
  extended by org.eclipse.smila.datamodel.id.impl.IdImpl
All Implemented Interfaces:
java.io.Serializable, Id

public class IdImpl
extends java.lang.Object
implements Id

default implementation of SMILA record IDs.

Author:
jschumacher
See Also:
Serialized Form

Constructor Summary
IdImpl(java.lang.String sourceName, Key sourceKey)
          create new Id.
IdImpl(java.lang.String sourceName, Key sourceKey, java.util.List<KeyImpl> newElementKeys, java.util.List<java.lang.String> newFragmentNames)
          create a complete Id with optional element keys and fragment names.
 
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 fragmentName)
          create a new Id from this Id by adding a fragment name.
 boolean equals(java.lang.Object obj)
          
 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.
 int hashCode()
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdImpl

public IdImpl(java.lang.String sourceName,
              Key sourceKey)
create new Id.

Parameters:
sourceName - data source name
sourceKey - source object key

IdImpl

public IdImpl(java.lang.String sourceName,
              Key sourceKey,
              java.util.List<KeyImpl> newElementKeys,
              java.util.List<java.lang.String> newFragmentNames)
create a complete Id with optional element keys and fragment names.

Parameters:
sourceName - data source name
sourceKey - name-value mapping for key
newElementKeys - container element keys. can be null or empty for non-container-element Ids
newFragmentNames - fragment names, can be null or empty for non-fragment Ids
Method Detail

getSource

public java.lang.String getSource()
name of the data source containing the object.

Specified by:
getSource in interface Id
Returns:
data source name.
See Also:
Id.getSource()

getKey

public Key getKey()
key of the source object with respect to the data source configuration.

Specified by:
getKey in interface Id
Returns:
source object key.
See Also:
Id.getKey()

hasElementKeys

public boolean hasElementKeys()
check if this Id contains element keys.

Specified by:
hasElementKeys in interface Id
Returns:
true if this contains element keys, else false.
See Also:
Id.hasElementKeys()

getElementKeys

public 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.

Specified by:
getElementKeys in interface Id
Returns:
list of container element keys.
See Also:
Id.getElementKeys()

hasFragmentNames

public boolean hasFragmentNames()
check if this Id contains fragment names.

Specified by:
hasFragmentNames in interface Id
Returns:
true if this contains fragment names, else false.
See Also:
Id.hasFragmentNames()

getFragmentNames

public 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.

Specified by:
getFragmentNames in interface Id
Returns:
list of fragment names.
See Also:
Id.getFragmentNames()

createElementId

public Id createElementId(java.lang.String elementName)
                   throws IdHandlingException
create a new Id from this Id by adding a simple unnamed container element key.

Specified by:
createElementId in interface Id
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.
See Also:
Id.createElementId(java.lang.String)

createElementId

public Id createElementId(Key elementKey)
                   throws IdHandlingException
create a new Id from this Id by adding a container element key.

Specified by:
createElementId in interface Id
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.
See Also:
Id.createElementId(org.eclipse.smila.datamodel.id.Key)

createFragmentId

public Id createFragmentId(java.lang.String fragmentName)
create a new Id from this Id by adding a fragment name.

Specified by:
createFragmentId in interface Id
Parameters:
fragmentName - name of the fragment
Returns:
an extended Id for the fragment.
See Also:
Id.createFragmentId(java.lang.String)

createCompoundId

public 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.

Specified by:
createCompoundId in interface Id
Returns:
Id of the compound containing this Id.
Throws:
IdHandlingException - if this is not a compund part Id.
See Also:
Id.createCompoundId()

getIdHash

public 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.

Specified by:
getIdHash in interface Id
Returns:
a hash string for this Id
See Also:
Id.getIdHash()

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

SMILA (incubation) API documentation