easik.sketch.attribute
Class UniqueKey

java.lang.Object
  extended by easik.sketch.attribute.UniqueKey

public class UniqueKey
extends java.lang.Object

Class used to keep track of attributes used in unique key constraints.

Since:
2006-06-06 Kevin Green
Version:
2006-07-13 Kevin Green
Author:
Kevin Green 2006

Field Summary
private  java.util.ArrayList<EntityAttribute> _attributes
          The attributes contributing to this unique key
private  java.lang.String _keyName
          The name of this key
private  EntityNode _parent
          The entity node to which this key applies
private  javax.swing.tree.DefaultMutableTreeNode _uniqueKeyNode
          The DefaultMutableTreeNode which represents this key graphically on the information tree
 
Constructor Summary
UniqueKey(EntityNode inParent, java.util.ArrayList<EntityAttribute> inAtts, java.lang.String inName)
          Default constructor
 
Method Summary
 java.util.ArrayList getAttributes()
          Returns an ArrayList of the attributes used in the key
 java.lang.String getId()
          Gets the id of this unique key.
 java.lang.String getKeyName()
          Returns the name of the key
 javax.swing.tree.DefaultMutableTreeNode getNode()
          Returns the node used to display the unique key in the tree
 EntityNode getParent()
          Returns the parent entity for the key
static boolean isKeyNameUsed(EntityNode inNode, java.lang.String keyName)
          Returns if the name of a key is already used
static boolean isKeyUnique(EntityNode inNode, java.lang.String keyID)
          Returns if the key is unique or if another key exists with the exact same attributes
 void setAttributes(java.util.ArrayList<EntityAttribute> inAtts)
          Sets the attributes involved in this unique key to the attributes present in inAtts
 void setKeyName(java.lang.String inName)
          Sets the key name to the name described in inName
 void setNode(javax.swing.tree.DefaultMutableTreeNode inNode)
          Sets the node used to display the unique key in the tree
static void testUnique(EntityNode inNode)
          Tests to see if there is any duplicate unique keys
 java.lang.String toString()
          Overwriten method returns attribute list separated by semicolons
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_attributes

private java.util.ArrayList<EntityAttribute> _attributes
The attributes contributing to this unique key


_keyName

private java.lang.String _keyName
The name of this key


_parent

private EntityNode _parent
The entity node to which this key applies


_uniqueKeyNode

private javax.swing.tree.DefaultMutableTreeNode _uniqueKeyNode
The DefaultMutableTreeNode which represents this key graphically on the information tree

Constructor Detail

UniqueKey

public UniqueKey(EntityNode inParent,
                 java.util.ArrayList<EntityAttribute> inAtts,
                 java.lang.String inName)
Default constructor

Parameters:
inParent - The EntityNode to which this unique key applies
inAtts - An ArrayList of the attributes used in the key
inName - The name of the key
Method Detail

toString

public java.lang.String toString()
Overwriten method returns attribute list separated by semicolons

Overrides:
toString in class java.lang.Object
Returns:
The name of this unique key formatted for use on the information tree

getId

public java.lang.String getId()
Gets the id of this unique key. The id is formatted by getting the name of each attribute and placing a semicolon between each name

Returns:
The id of this attribute

getAttributes

public java.util.ArrayList getAttributes()
Returns an ArrayList of the attributes used in the key

Returns:
An ArrayList of the attributes used in the key

setAttributes

public void setAttributes(java.util.ArrayList<EntityAttribute> inAtts)
Sets the attributes involved in this unique key to the attributes present in inAtts

Parameters:
inAtts - Arraylist of EntityAttribute

getKeyName

public java.lang.String getKeyName()
Returns the name of the key

Returns:
The name of the key

setKeyName

public void setKeyName(java.lang.String inName)
Sets the key name to the name described in inName

Parameters:
inName - The name of this attribute

getParent

public EntityNode getParent()
Returns the parent entity for the key

Returns:
The parent entity for the key

setNode

public void setNode(javax.swing.tree.DefaultMutableTreeNode inNode)
Sets the node used to display the unique key in the tree

Parameters:
inNode - The node used to display the unique key in the tree

getNode

public javax.swing.tree.DefaultMutableTreeNode getNode()
Returns the node used to display the unique key in the tree

Returns:
The node used to display the unique key in the tree

isKeyNameUsed

public static boolean isKeyNameUsed(EntityNode inNode,
                                    java.lang.String keyName)
Returns if the name of a key is already used

Parameters:
inNode - The entity being checked against
keyName - The name of the key
Returns:
If the key name is used or not

isKeyUnique

public static boolean isKeyUnique(EntityNode inNode,
                                  java.lang.String keyID)
Returns if the key is unique or if another key exists with the exact same attributes

Parameters:
inNode - The entity being checked against
keyID - The list of attributes in the key
Returns:
If the key is unique or if another key exists with the exact same attributes

testUnique

public static void testUnique(EntityNode inNode)
Tests to see if there is any duplicate unique keys

Parameters:
inNode - The node being tested