All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.maps.Key

java.lang.Object
   |
   +----org.xmlmiddleware.xmldbms.maps.MapBase
           |
           +----org.xmlmiddleware.xmldbms.maps.Key

public class Key
extends MapBase
Describes a key in a table; not for general use.

The Key class contains the information describing a key in a table: its name, an ordered list (array) of columns, its type (primary, unique, or foreign), and, if the key is a primary key, whether to generate it. Key names are arbitrary strings used to identify keys in map documents. They are also used to name key constraints in CREATE TABLE statements.

Keys are stored in Table and LinkInfo objects.

Version:
2.0
Author:
Ronald Bourret, 2001

Variable Index

 o DATABASE
Key generated by the database.
 o DOCUMENT
Key stored in document, not generated.
 o FOREIGN_KEY
Foreign key.
 o KEYGENERATOR
Key generated by a KeyGenerator.
 o PRIMARY_KEY
Primary key.
 o UNIQUE_KEY
Unique key (not primary key).
 o UNKNOWN
Key or generation type is unknown.

Method Index

 o createForeignKey(String)
Create a new foreign key.
 o createPrimaryKey(String)
Create a new primary key.
 o createUniqueKey(String)
Create a new unique key.
 o getColumns()
Get the list of columns in the key.
 o getKeyGeneration()
How the key is generated.
 o getKeyGeneratorName()
Get the logical name of the key generator, if any.
 o getName()
Get the key's name.
 o getRemoteKey()
Get the Key to which a foreign key points.
 o getRemoteTable()
Get the Table to which a foreign key points.
 o getType()
Get the key's type.
 o setColumns(Column[])
Set the list of columns in the key.
 o setKeyGeneration(int, String)
Set the method by which the key is generated.
 o setRemoteKey(Table, Key)
Set the Table and Key to which a foreign key points.

Variables

 o UNKNOWN
 public static final int UNKNOWN
Key or generation type is unknown.

 o PRIMARY_KEY
 public static final int PRIMARY_KEY
Primary key.

 o UNIQUE_KEY
 public static final int UNIQUE_KEY
Unique key (not primary key).

 o FOREIGN_KEY
 public static final int FOREIGN_KEY
Foreign key.

 o DOCUMENT
 public static final int DOCUMENT
Key stored in document, not generated.

 o KEYGENERATOR
 public static final int KEYGENERATOR
Key generated by a KeyGenerator.

 o DATABASE
 public static final int DATABASE
Key generated by the database.

Methods

 o createPrimaryKey
 public static Key createPrimaryKey(String keyName)
Create a new primary key.

Parameters:
keyName - Name of the key. Used in map documents and CREATE TABLE statements. If this is null, "PrimaryKey" is used.
Returns:
The new Key.
 o createUniqueKey
 public static Key createUniqueKey(String keyName)
Create a new unique key.

Parameters:
keyName - Name of the key. Used in map documents and CREATE TABLE statements. Must be non-null.
Returns:
The new Key.
 o createForeignKey
 public static Key createForeignKey(String keyName)
Create a new foreign key.

Parameters:
keyName - Name of the key. Used in map documents and CREATE TABLE statements. Must be non-null.
Returns:
The new Key.
 o getName
 public final String getName()
Get the key's name.

Returns:
The key's name.
 o getType
 public final int getType()
Get the key's type.

Returns:
The key's type. Key.PRIMARY_KEY, Key.UNIQUE_KEY, or Key.FOREIGN_KEY.
 o getKeyGeneration
 public final int getKeyGeneration()
How the key is generated.

Keys have three sources. Key.DOCUMENT means that elements, attributes, or PCDATA from the XML document are mapped to the key column(s). Key.KEYGENERATOR means that XML-DBMS generates the key, using a KeyGenerator supplied by application at run time. Key.DATABASE means that the database generates the key.

This method should only be called for primary keys -- that is, when getType() returns Key.PRIMARY_KEY. If getType() returns another value, the value returned by this method is undefined.

Returns:
How the key is generated.
 o getKeyGeneratorName
 public final String getKeyGeneratorName()
Get the logical name of the key generator, if any.

This method should only be called for primary keys that XML-DBMS generates -- that is, when getType() returns Key.PRIMARY_KEY and getKeyGeneration() returns Key.KEYGENERATOR. If either method returns another value, the value returned by this method is undefined.

Returns:
Logical key generator name.
 o setKeyGeneration
 public void setKeyGeneration(int generate,
                              String generatorName)
Set the method by which the key is generated.

Keys have three sources. Key.DOCUMENT means that elements, attributes, or PCDATA from the XML document are mapped to the key column(s). Key.KEYGENERATOR means that XML-DBMS generates the key, using a KeyGenerator supplied by application at run time. Key.DATABASE means that the database generates the key.

This method may only be called for primary keys. Call getType() to determine whether the key is primary.

Parameters:
generate - How the key is generated.
generatorName - Logical name of the key generator. Must be non-null if generate is Key.KEYGENERATOR and null otherwise.
 o getColumns
 public final Column[] getColumns()
Get the list of columns in the key.

Returns:
The columns in the key.
 o setColumns
 public void setColumns(Column columns[])
Set the list of columns in the key.

Parameters:
columns - The columns in the key.
 o getRemoteTable
 public final Table getRemoteTable()
Get the Table to which a foreign key points.

This method may only be called for foreign keys.

Returns:
The Table
 o getRemoteKey
 public final Key getRemoteKey()
Get the Key to which a foreign key points.

This method may only be called for foreign keys.

Returns:
The Key
 o setRemoteKey
 public final void setRemoteKey(Table remoteTable,
                                Key remoteKey)
Set the Table and Key to which a foreign key points.

This method may only be called for foreign keys.

Parameters:
remoteTable - The Table
remoteKey - The Key. Must be a primary or unique key.

All Packages  Class Hierarchy  This Package  Previous  Next  Index