SMILA (incubation) API documentation

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

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

public class KeyImpl
extends java.lang.Object
implements Key

standard implementation of ID Keys.

Author:
jschumacher
See Also:
Serialized Form

Constructor Summary
KeyImpl(java.util.Map<java.lang.String,java.lang.String> keyValues)
          create a key with the given name-value-mapping.
KeyImpl(java.lang.String key)
          create simple unnamed key.
KeyImpl(java.lang.String name, java.lang.String keyValue)
          create a simple named key.
 
Method Summary
static KeyImpl ensureImpl(Key someKey)
          convert other key implementations to the default KeyImpl, if necessary.
 boolean equals(java.lang.Object obj)
          
 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.
 int hashCode()
          
 boolean isCompositeKey()
          Checks if this is a simple or composite key.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyImpl

public KeyImpl(java.util.Map<java.lang.String,java.lang.String> keyValues)
create a key with the given name-value-mapping. If the map has a size of 1, a simple key is created, else it will be a composite key.

Parameters:
keyValues - names and key values to use

KeyImpl

public KeyImpl(java.lang.String name,
               java.lang.String keyValue)
create a simple named key.

Parameters:
name - key name
keyValue - key value.

KeyImpl

public KeyImpl(java.lang.String key)
create simple unnamed key.

Parameters:
key - the key value
Method Detail

ensureImpl

public static KeyImpl ensureImpl(Key someKey)
convert other key implementations to the default KeyImpl, if necessary.

Parameters:
someKey - key in deliberate implementation
Returns:
same key as KeyImpl instance.

getKey

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

Specified by:
getKey in interface Key
Returns:
the simple key value. returns null for composite keys.
See Also:
Key.getKey()

getKeyName

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

Specified by:
getKeyName in interface Key
Returns:
the simple key name. returns null for unnamed simple keys or composite keys.
See Also:
Key.getKeyName()

isCompositeKey

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

Specified by:
isCompositeKey in interface Key
Returns:
true, if this is a composite key. false, if it is a simple key.
See Also:
Key.isCompositeKey()

getKeyNames

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

Specified by:
getKeyNames in interface Key
Returns:
an iterator on all key names.
See Also:
Key.getKeyNames()

getKey

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

Specified by:
getKey in interface Key
Parameters:
name - a key name
Returns:
the associated key value or null if no such value exists.
See Also:
Key.getKey(java.lang.String)

getKeyValues

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

Specified by:
getKeyValues in interface Key
Returns:
map representation of the key values.
See Also:
Key.getKeyValues()

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