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 corresponding variable instance, too. In addition, the same identity may have a differentiating index when applied as a key in a map.

Nulls in key attribute values are handled as pattern parameters.

An optional attribute may be applied to identify a named attribute within a variable.

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

 org.norther.tammi.demo.Test@Name-1:10001J 10002J
 

Version:
$Id: Identity.java,v 1.38 2010-04-07 15:45:47 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static char ATTRIBUTE_DELIMITER
          The attribute delimiter.
static char ELEMENT_DELIMITER
          The element delimiter.
static char IDENTIFIER_DELIMITER
          The identifier delimiter.
 
Constructor Summary
Identity(String name, Object... ids)
          Constucts a new identity.
Identity(String type, String attrib, Object... ids)
          Constucts a new attribute identity.
Identity(Variable var)
          Constucts a new variable identity.
Identity(Variable var, String attrib)
          Constucts a new variable attribute identity.
 
Method Summary
 Object clone()
           
 boolean equals(Object object)
           
static Object fromString(String str)
          Returns the string id as an object.
 String getAttribute()
          Gets the attribute.
 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.
 boolean isIndexed()
          Checks whether indexed.
 int length()
          Returns the length of the id value array.
 void setAttribute(String attrib)
          Sets the attribute.
 void setIndex(int ind)
          Sets the index.
 String toPath()
          Returns a path-like representation of the identity.
 String toString()
           
static String toString(Object id)
          Returns the specified id as a string.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT_DELIMITER

public static final char ELEMENT_DELIMITER
The element delimiter.

See Also:
Constant Field Values

ATTRIBUTE_DELIMITER

public static final char ATTRIBUTE_DELIMITER
The attribute delimiter.

See Also:
Constant Field Values

IDENTIFIER_DELIMITER

public static final char IDENTIFIER_DELIMITER
The identifier delimiter.

See Also:
Constant Field Values
Constructor Detail

Identity

public Identity(String name,
                Object... ids)
Constucts a new identity.

Note that the keys should appear in the definition order of the corresponding attributes.

Parameters:
name - the canonical name or class type.
ids - optional key values.

Identity

public Identity(String type,
                String attrib,
                Object... ids)
Constucts a new attribute identity.

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

Identity

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

Parameters:
var - the variable.

Identity

public Identity(Variable var,
                String attrib)
Constucts a new variable attribute identity.

Parameters:
var - the variable.
attrib - the attribute.
Method Detail

toString

public static String toString(Object id)
Returns the specified id as a string.

Parameters:
id - the id.
Returns:
the string.

fromString

public static Object fromString(String str)
Returns the string id as an object.

Parameters:
str - the string.
Returns:
the object.

equals

public boolean equals(Object object)
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

toPath

public String toPath()
Returns a path-like representation of the identity.

Returns:
the path to the identity.

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.

getAttribute

public String getAttribute()
Gets the attribute.

Returns:
the attribute.

setAttribute

public void setAttribute(String attrib)
Sets the attribute.

Parameters:
attrib - the attribute.

isIndexed

public boolean isIndexed()
Checks whether indexed.

Returns:
true if indexed, false otherwise.

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.