diff options
author | bvosburgh | 2008-09-24 13:27:47 +0000 |
---|---|---|
committer | bvosburgh | 2008-09-24 13:27:47 +0000 |
commit | 348030eb050a6265ab998f5ee66a73a5e19c5f90 (patch) | |
tree | f3268060c2921e58167874070e518fdf5584beca /jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db | |
parent | 211fcc6e56a58676def89897eca447284786af9c (diff) | |
download | webtools.dali-348030eb050a6265ab998f5ee66a73a5e19c5f90.tar.gz webtools.dali-348030eb050a6265ab998f5ee66a73a5e19c5f90.tar.xz webtools.dali-348030eb050a6265ab998f5ee66a73a5e19c5f90.zip |
[248031] API enhancements for OEPE
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db')
3 files changed, 93 insertions, 14 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java index e631a6da75..b502f61ca6 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Column.java @@ -30,15 +30,32 @@ public interface Column */ Table getTable(); + + // ********** constraints ********** + /** * Return whether the column is part of it's table's primary key. */ - boolean isPrimaryKeyColumn(); + boolean isPartOfPrimaryKey(); /** * Return whether the column is part of one of it's table's foreign keys. */ - boolean isForeignKeyColumn(); + boolean isPartOfForeignKey(); + + /** + * Return whether the column is part of a unique constraint defined for its + * table. + */ + boolean isPartOfUniqueConstraint(); + + /** + * Return whether the column is nullable. + */ + boolean isNullable(); + + + // ********** data type ********** /** * Return the name of the column's datatype. @@ -46,10 +63,33 @@ public interface Column String getDataTypeName(); /** + * Return whether the column's type is numeric. + */ + boolean isNumeric(); + + /** + * Return the column's precision if it is a NumericalDataType; + * otherwise, return -1. + */ + public int getPrecision(); + + /** + * Return the column's scale if it is an ExactNumericDataType; + * otherwise, return -1. + */ + public int getScale(); + + /** + * If the column is a CharacterStringDataType, return its length; + * otherwise, return -1. + */ + public int getLength(); + + /** * Return whether the column's datatype is a LOB type * (i.e. BLOB, CLOB, or NCLOB). */ - boolean dataTypeIsLOB(); + boolean isLOB(); // ********** Java type ********** diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java index 709d8d1736..6caf00bffd 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java @@ -12,7 +12,10 @@ package org.eclipse.jpt.db.internal; import java.text.Collator; import org.eclipse.datatools.modelbase.dbdefinition.PredefinedDataTypeDefinition; +import org.eclipse.datatools.modelbase.sql.datatypes.CharacterStringDataType; import org.eclipse.datatools.modelbase.sql.datatypes.DataType; +import org.eclipse.datatools.modelbase.sql.datatypes.ExactNumericDataType; +import org.eclipse.datatools.modelbase.sql.datatypes.NumericalDataType; import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType; import org.eclipse.datatools.modelbase.sql.datatypes.PrimitiveType; import org.eclipse.jpt.db.Column; @@ -58,19 +61,63 @@ final class DTPColumnWrapper return (DTPTableWrapper) this.getParent(); } - public boolean isPrimaryKeyColumn() { + public boolean isPartOfPrimaryKey() { return this.getTable().primaryKeyColumnsContains(this); } - public boolean isForeignKeyColumn() { + public boolean isPartOfForeignKey() { return this.getTable().foreignKeyBaseColumnsContains(this); } + public boolean isPartOfUniqueConstraint() { + return this.dtpColumn.isPartOfUniqueConstraint(); + } + + public boolean isNullable() { + return this.dtpColumn.isNullable(); + } + public String getDataTypeName() { DataType dataType = this.dtpColumn.getDataType(); return (dataType == null) ? null : dataType.getName(); } + public boolean isLOB() { + DataType dataType = this.dtpColumn.getDataType(); + return (dataType instanceof PredefinedDataType) ? + primitiveTypeIsLob(((PredefinedDataType) dataType).getPrimitiveType()) + : + false; + } + + public boolean isNumeric() { + return this.dtpColumn.getDataType() instanceof NumericalDataType; + } + + public int getPrecision() { + DataType dataType = this.dtpColumn.getDataType(); + return (dataType instanceof NumericalDataType) ? + ((NumericalDataType) dataType).getPrecision() + : + -1; + } + + public int getScale(){ + DataType dataType = this.dtpColumn.getDataType(); + return (dataType instanceof ExactNumericDataType) ? + ((ExactNumericDataType) dataType).getScale() + : + -1; + } + + public int getLength() { + DataType dataType = this.dtpColumn.getDataType(); + return (dataType instanceof CharacterStringDataType) ? + ((CharacterStringDataType) dataType).getLength() + : + -1; + } + public String getJavaTypeDeclaration() { return this.getJavaType().declaration(); } @@ -101,14 +148,6 @@ final class DTPColumnWrapper return this.getDatabase().getDTPDefinition().getPredefinedDataTypeDefinition(dataType.getName()); } - public boolean dataTypeIsLOB() { - DataType dataType = this.dtpColumn.getDataType(); - return (dataType instanceof PredefinedDataType) ? - primitiveTypeIsLob(((PredefinedDataType) dataType).getPrimitiveType()) - : - false; - } - // ********** Comparable implementation ********** diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java index 8317bb926e..6e2e375569 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPForeignKeyWrapper.java @@ -168,7 +168,7 @@ final class DTPForeignKeyWrapper return new FilteringIterator<Column, Column>(this.baseColumns()) { @Override protected boolean accept(Column column) { - return ! column.isPrimaryKeyColumn(); + return ! column.isPartOfPrimaryKey(); } }; } |