FileDocCategorySizeDatePackage
DatabaseTable.javaAPI DocGlassfish v2 API7994Tue May 22 16:54:34 BST 2007oracle.toplink.essentials.internal.helper

DatabaseTable

public class DatabaseTable extends Object implements Serializable, Cloneable
INTERNAL:

Purpose: Define a fully qualified table name.

Responsibilities:

  • Allow specification of a qualifier to the table, i.e. creator or database.
see
DatabaseField

Fields Summary
protected String
name
protected String
tableQualifier
protected String
qualifiedName
protected Vector
uniqueConstraints
Constructors Summary
public DatabaseTable()
Initialize the newly allocated instance of this class. By default their is no qualifier.

        this("", "");
    
public DatabaseTable(String possiblyQualifiedName)

        setPossiblyQualifiedName(possiblyQualifiedName);
        uniqueConstraints = new Vector<String[]>();
    
public DatabaseTable(String tableName, String qualifier)

        this.name = tableName;
        this.tableQualifier = qualifier;
        uniqueConstraints = new Vector<String[]>();
    
Methods Summary
public voidaddUniqueConstraints(java.lang.String[] columnNames)
Add the unique constraint for the columns names. Used for DDL generation.

        uniqueConstraints.add(columnNames);
    
public java.lang.Objectclone()
Return a shallow copy of the receiver.

return
Object An Object must be returned or the signature of this method will conflict with the signature in Object.

        try {
            return super.clone();
        } catch (CloneNotSupportedException exception) {
        }

        return null;
    
public booleanequals(java.lang.Object object)
Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned. This allows an unqualified table to equal the same fully qualified one.

        if (object instanceof DatabaseTable) {
            return equals((DatabaseTable)object);
        }
        return false;
    
public booleanequals(oracle.toplink.essentials.internal.helper.DatabaseTable table)
Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned. This allows an unqualified table to equal the same fully qualified one.

        if (this == table) {
            return true;
        }
        if (DatabasePlatform.shouldIgnoreCaseOnFieldComparisons()) {
            if (getName().equalsIgnoreCase(table.getName())) {
                if ((getTableQualifier().length() == 0) || (table.getTableQualifier().length() == 0) || (getTableQualifier().equalsIgnoreCase(table.getTableQualifier()))) {
                    return true;
                }
            }
        } else {
            if (getName().equals(table.getName())) {
                if ((getTableQualifier().length() == 0) || (table.getTableQualifier().length() == 0) || (getTableQualifier().equals(table.getTableQualifier()))) {
                    return true;
                }
            }
        }

        return false;
    
public java.lang.StringgetName()
Get method for table name.

        return name;
    
public java.lang.StringgetQualifiedName()

        if (qualifiedName == null) {
            if (tableQualifier.equals("")) {
                qualifiedName = getName();
            } else {
                qualifiedName = getTableQualifier() + "." + getName();
            }
        }

        return qualifiedName;
    
public java.lang.StringgetTableQualifier()

        return tableQualifier;
    
public java.util.VectorgetUniqueConstraints()
Return a vector of the unique constraints for this table. Used for DDL generation.

        return uniqueConstraints;
    
public booleanhasName()
Determine whether the receiver has any identification information. Return true if the name or qualifier of the receiver are nonempty.

        if ((getName().length() == 0) && (getTableQualifier().length() == 0)) {
            return false;
        }

        return true;
    
public inthashCode()
Return the hashcode of the name, because it is fairly unqiue.

        return getName().hashCode();
    
public booleanisDecorated()
INTERNAL: Is this decorated / has an AS OF (some past time) clause. Example: SELECT ... FROM EMPLOYEE AS OF TIMESTAMP (exp) t0 ...

        return false;
    
protected voidresetQualifiedName()

        this.qualifiedName = null;
    
public voidsetName(java.lang.String name)
This method will set the table name regardless if the name has a qualifier. Used when aliasing table names.

param
name

        this.name = name;
        resetQualifiedName();
    
public voidsetPossiblyQualifiedName(java.lang.String possiblyQualifiedName)
Used to map the project xml. Anytime a string name is read from the project xml, we must check if it is fully qualified and split the actual name from the qualifier.

param
possiblyQualifiedName

        resetQualifiedName();
        
        int index = possiblyQualifiedName.lastIndexOf('.");

        if (index == -1) {
            this.name = possiblyQualifiedName;
            this.tableQualifier = "";
        } else {
            this.name = possiblyQualifiedName.substring(index + 1, possiblyQualifiedName.length());
            this.tableQualifier = possiblyQualifiedName.substring(0, index);
        }
    
public voidsetTableQualifier(java.lang.String qualifier)

        this.tableQualifier = qualifier;
        resetQualifiedName();
    
public java.lang.StringtoString()

        return "DatabaseTable(" + getQualifiedName() + ")";