SMILA (incubation) API documentation

org.eclipse.smila.datamodel.id
Interface Key

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
KeyImpl

public interface Key
extends java.io.Serializable

Interface of ID Keys. Keys can be simple and consist just of a single key value with an optional name (e.g. a file path or an URL), or they can be composite keys containing a mapping of names to key values (e.g. database primary keys consisting of multiple columns). Keys must be immutable objects to make them usable as hash keys. This means that the must also define sensible equals() and hashCode() methods.

Author:
jschumacher

Method Summary
 java.lang.String getKey()
          Get the value of a simple key.
 java.lang.String getKey(java.lang.String name)
          Get the key for the given name.
 java.lang.String getKeyName()
          Get the name of a simple key.
 java.util.Iterator<java.lang.String> getKeyNames()
          Get the names of this key.
 java.util.Map<java.lang.String,java.lang.String> getKeyValues()
          create a map representation of this key.
 boolean isCompositeKey()
          Checks if this is a simple or composite key.
 

Method Detail

isCompositeKey

boolean isCompositeKey()
Checks if this is a simple or composite key.

Returns:
true, if this is a composite key. false, if it is a simple key.

getKey

java.lang.String getKey()
Get the value of a simple key.

Returns:
the simple key value. returns null for composite keys.

getKeyName

java.lang.String getKeyName()
Get the name of a simple key.

Returns:
the simple key name. returns null for unnamed simple keys or composite keys.

getKeyNames

java.util.Iterator<java.lang.String> getKeyNames()
Get the names of this key. This also creates an iterator for simple keys containing either a single name for named simple keys or no elements unnamed simple keys. It must not be possible to modify the key using this iterator.

Returns:
an iterator on all key names.

getKey

java.lang.String getKey(java.lang.String name)
Get the key for the given name. Works for simple keys, too, by returning the simple key value if the key name is correct (use null for unnamed keys) or null, else.

Parameters:
name - a key name
Returns:
the associated key value or null if no such value exists.

getKeyValues

java.util.Map<java.lang.String,java.lang.String> getKeyValues()
create a map representation of this key. If this is a simple unnamed key, the key name in the map will be null. The implementation must ensure that it is not possible do modify the key using this map.

Returns:
map representation of the key values.

SMILA (incubation) API documentation