org.norther.tammi.core.rt.util
Class Identity

java.lang.Object
  extended by org.norther.tammi.core.rt.util.Identity
All Implemented Interfaces:
Serializable, Cloneable

public class Identity
extends Object
implements Cloneable, Serializable

A variable identity uniquely identifying a variable by its type and a set of key attribute values. The string representation of Identity is unique for the correponding variable instance, too. The string representation should contain only valid HTML4 id characters (A-Za-z), (0-9), (.), (-), (_) and (:).

Note that getters return direct references to value and key arrays causing changes to their elements to affect the internal state of the identity.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
Identity(Object[] ids, String type)
          Constucts a new identity with multiple ids.
Identity(Object[] ids, String type, int ind)
          Constucts a new indexed identity with multiple ids.
Identity(Object id, String type)
          Constucts a new identity.
Identity(Object id, String type, int ind)
          Constucts a new indexed identity.
Identity(String name)
          Constucts a new identity from the typed canonical name.
Identity(Variable var)
          Constucts a new variable identity.
Identity(Variable var, int ind)
          Constucts a new variable identity with multiple keys.
 
Method Summary
 Object clone()
           
 boolean equals(Object other)
           
 int getIndex()
          Gets the index.
 String getType()
          Gets the class type.
 Object getValue()
          Gets the key attribute value.
 Object[] getValues()
          Gets the key attribute values.
 int hashCode()
           
 boolean identifies(Variable var)
          Checks whether this identity identifies the specified variable.
 int length()
          Returns the length of the id value array.
 void setIndex(int ind)
          Sets the index.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Identity

public Identity(Object id,
                String type)
Constucts a new identity.

Parameters:
id - the key value.
type - the class type.

Identity

public Identity(Object[] ids,
                String type)
Constucts a new identity with multiple ids.

Parameters:
ids - the key values.
type - the class type.

Identity

public Identity(Object id,
                String type,
                int ind)
Constucts a new indexed identity.

Parameters:
id - the key value.
type - the class type.
ind - the index.

Identity

public Identity(Object[] ids,
                String type,
                int ind)
Constucts a new indexed identity with multiple ids.

Parameters:
ids - the key values.
type - the class type.
ind - the index.

Identity

public Identity(Variable var)
Constucts a new variable identity.

Parameters:
var - the variable.
key - the key attribute.

Identity

public Identity(Variable var,
                int ind)
Constucts a new variable identity with multiple keys.

Parameters:
var - the variable.
keys - the key attributes.
ind - the index.

Identity

public Identity(String name)
Constucts a new identity from the typed canonical name.

Parameters:
name - the canonical name.
Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

getValue

public Object getValue()
Gets the key attribute value.

Returns:
the attribute value.

getValues

public Object[] getValues()
Gets the key attribute values.

Returns:
the attribute values.

getType

public String getType()
Gets the class type.

Returns:
the class type.

getIndex

public int getIndex()
Gets the index.

Returns:
the index.

setIndex

public void setIndex(int ind)
Sets the index.

Parameters:
ind - the index.

length

public int length()
Returns the length of the id value array.

Returns:
the number of primary key values.

identifies

public boolean identifies(Variable var)
Checks whether this identity identifies the specified variable.

Parameters:
var - the varianble.
Returns:
true or false.


Copyright © 2004 The Norther Organization. All rights reserved.