org.apache.openjpa.jdbc.schema
Class Table

java.lang.Object
  extended by org.apache.openjpa.jdbc.schema.NameSet
      extended by org.apache.openjpa.jdbc.schema.Table
All Implemented Interfaces:
Serializable, Comparable<Object>, SourceTracker

public class Table
extends NameSet
implements Comparable<Object>, SourceTracker

Represents a database table.

Author:
Abe White, Stephen Kim
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
 
Constructor Summary
Table()
          Default constructor.
Table(DBIdentifier name, Schema schema)
           
Table(String name, Schema schema)
          Deprecated.  
 
Method Summary
 Column addColumn(DBIdentifier name)
           
 Column addColumn(DBIdentifier name, DBIdentifier validName)
           
 Column addColumn(String name)
          Deprecated.  
 Column addColumn(String name, String validName)
          Deprecated.  
 void addCorrectedColumnName(DBIdentifier name, boolean validate)
           
 void addCorrectedColumnName(String name, boolean validate)
          Deprecated.  
 ForeignKey addForeignKey()
          Add a foreign key to the table.
 ForeignKey addForeignKey(DBIdentifier name)
           
 ForeignKey addForeignKey(String name)
          Deprecated.  
 Index addIndex(DBIdentifier name)
           
 Index addIndex(String name)
          Deprecated.  
 PrimaryKey addPrimaryKey()
          Set the primary key for the table.
 PrimaryKey addPrimaryKey(DBIdentifier name)
           
 PrimaryKey addPrimaryKey(String name)
          Deprecated.  
 Unique addUnique(DBIdentifier name)
           
 Unique addUnique(String name)
          Deprecated.  
(package private)  void changeAutoAssigned(Column col)
          Called by columns when their auto increment status changes.
(package private)  void changeRelationId(Column col)
          Called by columns when their relation id status changes.
 int compareTo(Object other)
           
 boolean containsColumn(DBIdentifier name)
           
 boolean containsColumn(DBIdentifier name, DBDictionary dict)
           
 boolean containsColumn(String name)
          Deprecated.  
 boolean containsColumn(String name, DBDictionary dict)
          Deprecated.  
 Column[] getAutoAssignedColumns()
          Return this table's auto-assigned columns.
 int getColNumber()
          Return the column number in the line of the file at which this instance was parsed.
 Column getColumn(DBIdentifier name)
           
 Column getColumn(String name)
          Deprecated.  
 String[] getColumnNames()
           
 Column[] getColumns()
          Return the table's columns, in alphabetical order.
 String getComment()
           
 ForeignKey getForeignKey(DBIdentifier name)
           
 ForeignKey getForeignKey(String name)
          Deprecated.  
 ForeignKey[] getForeignKeys()
          Return all foreign keys for the table.
 DBIdentifier getFullIdentifier()
           
 String getFullName()
          Deprecated.  
 DBIdentifier getIdentifier()
           
 Index getIndex(DBIdentifier name)
           
 Index getIndex(String name)
          Deprecated.  
 Index[] getIndexes()
          Return the table's indexes.
 int getLineNumber()
          Return the line number of the file at which this instance was parsed.
 String getName()
          Deprecated.  
 PrimaryKey getPrimaryKey()
          Return the primary key for the table, if any.
 QualifiedDBIdentifier getQualifiedPath()
           
 Column[] getRelationIdColumns()
          Return this table's relation id columns.
 String getResourceName()
          Return the domain-meaningful name of the resource that was loaded from this source.
 Schema getSchema()
          Return the schema for the table.
 DBIdentifier getSchemaIdentifier()
           
 String getSchemaName()
          Deprecated.  
 File getSourceFile()
          Return the file from which this instance was parsed.
 Object getSourceScope()
          Return the domain-dependent scope of this instance within its file.
 int getSourceType()
          Return the type of source.
 Unique getUnique(DBIdentifier name)
           
 Unique getUnique(String name)
          Deprecated.  
 Unique[] getUniques()
          Return the table's unique constraints.
 boolean hasComment()
           
 Column importColumn(Column col)
          Import a column from another table.
 ForeignKey importForeignKey(ForeignKey fk)
          Import a foreign key; column names must match columns of this table.
 Index importIndex(Index idx)
          Import an index; column names must match columns of this table.
 PrimaryKey importPrimaryKey(PrimaryKey pk)
          Import a primary key; column names must match columns of this table.
 Unique importUnique(Unique unq)
          Import a constraint; column names must match columns of this table.
(package private)  void indexColumns()
          Called by columns to ensure that all columns are properly indexed before returning that information to the user.
(package private)  void indexForeignKeys()
          Called by foreign keys to ensure that all fks are properly indexed before returning that information to the user.
 boolean isAssociation()
           
(package private)  void remove()
          Called when the table is removed from its schema.
 boolean removeColumn(Column col)
          Remove the given column from the table.
 boolean removeForeignKey(ForeignKey fk)
          Remove the given foreign key from the table.
 boolean removeIndex(Index idx)
          Remove the given index from the table.
 boolean removePrimaryKey()
          Remove the primary key from this table.
 boolean removeUnique(Unique unq)
          Remove the given unique constraint from the table.
 void setAssociation()
           
 void setColNumber(int colNum)
           
 void setComment(String comment)
           
 void setIdentifier(DBIdentifier name)
           
 void setLineNumber(int lineNum)
           
 void setName(String name)
          Deprecated.  
 void setSchemaIdentifier(DBIdentifier name)
           
 void setSchemaName(String name)
          Deprecated.  
 void setSource(File source, int srcType)
           
 String toString()
           
 
Methods inherited from class org.apache.openjpa.jdbc.schema.NameSet
addName, addName, isNameTaken, isNameTaken, removeName, removeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table()
Default constructor.


Table

public Table(String name,
             Schema schema)
Deprecated. 

Constructor.

Parameters:
name - the table name
schema - the table schema

Table

public Table(DBIdentifier name,
             Schema schema)
Method Detail

setAssociation

public void setAssociation()

isAssociation

public boolean isAssociation()

remove

void remove()
Called when the table is removed from its schema. Removes all table members, and invalidates the table.


getSchema

public Schema getSchema()
Return the schema for the table.


getSchemaName

public String getSchemaName()
Deprecated. 

The table's schema name.


getSchemaIdentifier

public DBIdentifier getSchemaIdentifier()

setSchemaName

public void setSchemaName(String name)
Deprecated. 

The table's schema name. You can only call this method on tables whose schema object is not set.


setSchemaIdentifier

public void setSchemaIdentifier(DBIdentifier name)

getName

public String getName()
Deprecated. 

Return the name of the table.


getIdentifier

public DBIdentifier getIdentifier()

setName

public void setName(String name)
Deprecated. 

Set the name of the table. This method can only be called on tables that are not part of a schema.


setIdentifier

public void setIdentifier(DBIdentifier name)

getFullName

public String getFullName()
Deprecated. 

Return the table name, including schema, using '.' as the catalog separator.


getQualifiedPath

public QualifiedDBIdentifier getQualifiedPath()

getFullIdentifier

public DBIdentifier getFullIdentifier()

getSourceFile

public File getSourceFile()
Description copied from interface: SourceTracker
Return the file from which this instance was parsed.

Specified by:
getSourceFile in interface SourceTracker

getSourceScope

public Object getSourceScope()
Description copied from interface: SourceTracker
Return the domain-dependent scope of this instance within its file.

Specified by:
getSourceScope in interface SourceTracker

getSourceType

public int getSourceType()
Description copied from interface: SourceTracker
Return the type of source.

Specified by:
getSourceType in interface SourceTracker

setSource

public void setSource(File source,
                      int srcType)

getResourceName

public String getResourceName()
Description copied from interface: SourceTracker
Return the domain-meaningful name of the resource that was loaded from this source. I.e., if we had loaded the source for a Java class, this would return the name of the class.

Specified by:
getResourceName in interface SourceTracker

getColumns

public Column[] getColumns()
Return the table's columns, in alphabetical order.


getAutoAssignedColumns

public Column[] getAutoAssignedColumns()
Return this table's auto-assigned columns.


getRelationIdColumns

public Column[] getRelationIdColumns()
Return this table's relation id columns.


getColumnNames

public String[] getColumnNames()

getColumn

public Column getColumn(String name)
Deprecated. 

Return the column with the given name, or null if none.


getColumn

public Column getColumn(DBIdentifier name)

containsColumn

public boolean containsColumn(String name)
Deprecated. 

Affirms if this table contains the column of the given name without any side-effect.

See Also:
can have side-effect of creating a column for dynamic table implementation.

containsColumn

public boolean containsColumn(DBIdentifier name)

containsColumn

public boolean containsColumn(String name,
                              DBDictionary dict)
Deprecated. 

Affirms if this table contains the column of the given name without any side-effect.

Parameters:
dict - the current database dictionary or null.
See Also:
can have side-effect of creating a column for dynamic table implementation.

containsColumn

public boolean containsColumn(DBIdentifier name,
                              DBDictionary dict)

addColumn

public Column addColumn(String name)
Deprecated. 

Add a column to the table.


addColumn

public Column addColumn(DBIdentifier name)

addColumn

public Column addColumn(String name,
                        String validName)
Deprecated. 

Add a column with a shortened (i.e., validated) name to the table


addColumn

public Column addColumn(DBIdentifier name,
                        DBIdentifier validName)

addCorrectedColumnName

public void addCorrectedColumnName(String name,
                                   boolean validate)
Deprecated. 

Add a name to this NameSet


addCorrectedColumnName

public void addCorrectedColumnName(DBIdentifier name,
                                   boolean validate)

removeColumn

public boolean removeColumn(Column col)
Remove the given column from the table.

Returns:
true if the column was removed, false if not in the table

importColumn

public Column importColumn(Column col)
Import a column from another table.


getPrimaryKey

public PrimaryKey getPrimaryKey()
Return the primary key for the table, if any.


addPrimaryKey

public PrimaryKey addPrimaryKey()
Set the primary key for the table.


addPrimaryKey

public PrimaryKey addPrimaryKey(String name)
Deprecated. 

Set the primary key for the table.


addPrimaryKey

public PrimaryKey addPrimaryKey(DBIdentifier name)

removePrimaryKey

public boolean removePrimaryKey()
Remove the primary key from this table.

Returns:
true if there was a pk to remove, false otherwise

importPrimaryKey

public PrimaryKey importPrimaryKey(PrimaryKey pk)
Import a primary key; column names must match columns of this table.


getForeignKey

public ForeignKey getForeignKey(String name)
Deprecated. 

Return the foreign key with the given name. If multiple foreign keys have the name, the first match is returned.


getForeignKey

public ForeignKey getForeignKey(DBIdentifier name)

getForeignKeys

public ForeignKey[] getForeignKeys()
Return all foreign keys for the table.


addForeignKey

public ForeignKey addForeignKey()
Add a foreign key to the table.


addForeignKey

public ForeignKey addForeignKey(String name)
Deprecated. 

Add a foreign key to the table. Duplicate key names are not allowed.


addForeignKey

public ForeignKey addForeignKey(DBIdentifier name)

removeForeignKey

public boolean removeForeignKey(ForeignKey fk)
Remove the given foreign key from the table.

Returns:
true if the key was removed, false if not in the table

importForeignKey

public ForeignKey importForeignKey(ForeignKey fk)
Import a foreign key; column names must match columns of this table.


getIndexes

public Index[] getIndexes()
Return the table's indexes.


getIndex

public Index getIndex(String name)
Deprecated. 

Return the index with the given name, or null if none.


getIndex

public Index getIndex(DBIdentifier name)

addIndex

public Index addIndex(String name)
Deprecated. 

Add an index to the table.


addIndex

public Index addIndex(DBIdentifier name)

removeIndex

public boolean removeIndex(Index idx)
Remove the given index from the table.

Returns:
true if the index was removed, false if not in the table

importIndex

public Index importIndex(Index idx)
Import an index; column names must match columns of this table.


getUniques

public Unique[] getUniques()
Return the table's unique constraints.


getUnique

public Unique getUnique(String name)
Deprecated. 

Return the unique constraint with the given name, or null if none.


getUnique

public Unique getUnique(DBIdentifier name)

addUnique

public Unique addUnique(String name)
Deprecated. 

Add a unique constraint to the table.


addUnique

public Unique addUnique(DBIdentifier name)

removeUnique

public boolean removeUnique(Unique unq)
Remove the given unique constraint from the table.

Returns:
true if the constraint was removed, false if not in the table

importUnique

public Unique importUnique(Unique unq)
Import a constraint; column names must match columns of this table.


indexColumns

void indexColumns()
Called by columns to ensure that all columns are properly indexed before returning that information to the user.


indexForeignKeys

void indexForeignKeys()
Called by foreign keys to ensure that all fks are properly indexed before returning that information to the user.


changeAutoAssigned

void changeAutoAssigned(Column col)
Called by columns when their auto increment status changes.


changeRelationId

void changeRelationId(Column col)
Called by columns when their relation id status changes.


compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable<Object>

toString

public String toString()
Overrides:
toString in class Object

hasComment

public boolean hasComment()

getComment

public String getComment()

setComment

public void setComment(String comment)

getLineNumber

public int getLineNumber()
Description copied from interface: SourceTracker
Return the line number of the file at which this instance was parsed.

Specified by:
getLineNumber in interface SourceTracker

setLineNumber

public void setLineNumber(int lineNum)

getColNumber

public int getColNumber()
Description copied from interface: SourceTracker
Return the column number in the line of the file at which this instance was parsed.

Specified by:
getColNumber in interface SourceTracker

setColNumber

public void setColNumber(int colNum)


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.