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
-
DATABASE
- Key generated by the database.
-
DOCUMENT
- Key stored in document, not generated.
-
FOREIGN_KEY
- Foreign key.
-
KEYGENERATOR
- Key generated by a KeyGenerator.
-
PRIMARY_KEY
- Primary key.
-
UNIQUE_KEY
- Unique key (not primary key).
-
UNKNOWN
- Key or generation type is unknown.
-
createForeignKey(String)
- Create a new foreign key.
-
createPrimaryKey(String)
- Create a new primary key.
-
createUniqueKey(String)
- Create a new unique key.
-
getColumns()
- Get the list of columns in the key.
-
getKeyGeneration()
- How the key is generated.
-
getKeyGeneratorName()
- Get the logical name of the key generator, if any.
-
getName()
- Get the key's name.
-
getRemoteKey()
- Get the Key to which a foreign key points.
-
getRemoteTable()
- Get the Table to which a foreign key points.
-
getType()
- Get the key's type.
-
setColumns(Column[])
- Set the list of columns in the key.
-
setKeyGeneration(int, String)
- Set the method by which the key is generated.
-
setRemoteKey(Table, Key)
- Set the Table and Key to which a foreign key points.
UNKNOWN
public static final int UNKNOWN
- Key or generation type is unknown.
PRIMARY_KEY
public static final int PRIMARY_KEY
- Primary key.
UNIQUE_KEY
public static final int UNIQUE_KEY
- Unique key (not primary key).
FOREIGN_KEY
public static final int FOREIGN_KEY
- Foreign key.
DOCUMENT
public static final int DOCUMENT
- Key stored in document, not generated.
KEYGENERATOR
public static final int KEYGENERATOR
- Key generated by a KeyGenerator.
DATABASE
public static final int DATABASE
- Key generated by the database.
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.
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.
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.
getName
public final String getName()
- Get the key's name.
- Returns:
- The key's name.
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.
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.
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.
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.
getColumns
public final Column[] getColumns()
- Get the list of columns in the key.
- Returns:
- The columns in the key.
setColumns
public void setColumns(Column columns[])
- Set the list of columns in the key.
- Parameters:
- columns - The columns in the key.
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
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
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