de.fesenmeyer.dbnormalizer.core
Class TableColumn

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.AbstractDBItem
      extended by de.fesenmeyer.dbnormalizer.core.TableColumn
All Implemented Interfaces:
Comparable<TableColumn>

public class TableColumn
extends AbstractDBItem
implements Comparable<TableColumn>

Represents a column of a table in a DB. Contains most of the common properties which can be retrieved by means of the JDBC-Interface DatabaseMetaData.

Author:
DF
See Also:
DatabaseMetaData

Field Summary
private  int columnSize
          The column size, e.g.
private  int dataType
          The data type (database-independent int representation).
private  int decimalDigits
          The decimal digits, e.g. for the column someNumber NUMBER(9,2) the decimal digits value is 2.
private  String defaultValue
          The default value.
private  boolean nullable
          A Flag specifying whether the column can be null or not, defaults to true.
private  String typeName
          The typeName (database specific), e.g.
 
Constructor Summary
TableColumn()
           
 
Method Summary
 int compareTo(TableColumn col)
          Compares this column to another column based on their names.
 TableColumn copy()
          Creates a copy of this TableColumn.
 boolean equals(Object o)
          Overridden Method, tests if this column is equal to the o argument based on the name.
 int getColumnSize()
          Gets the column size.
 int getDataType()
          Gets the data type.
 int getDecimalDigits()
          Gets the decimal digits.
 String getDefaultValue()
          Gets the default value.
 String getTypeName()
          Gets the typeName.
 int hashCode()
          Overridden method, returns a hash code based on the column's name.
 boolean isNullable()
          Gets whether the column can be null or not.
 void setColumnSize(int columnSize)
          Sets the column size.
 void setDataType(int dataType)
          Sets the data type.
 void setDecimalDigits(int decimalDigits)
          Sets the decimal digits
 void setDefaultValue(String defaultValue)
          Sets the default value.
 void setNullable(boolean nullable)
          Sets whether the column can be null or not.
 void setTypeName(String type)
          Sets the typeName.
 
Methods inherited from class de.fesenmeyer.dbnormalizer.core.AbstractDBItem
getName, setName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

typeName

private String typeName
The typeName (database specific), e.g. "VARCHAR2" (oracle-specific).


nullable

private boolean nullable
A Flag specifying whether the column can be null or not, defaults to true.


dataType

private int dataType
The data type (database-independent int representation).


decimalDigits

private int decimalDigits
The decimal digits, e.g. for the column someNumber NUMBER(9,2) the decimal digits value is 2.


columnSize

private int columnSize
The column size, e.g.

defaultValue

private String defaultValue
The default value.

Constructor Detail

TableColumn

public TableColumn()
Method Detail

getDecimalDigits

public int getDecimalDigits()
Gets the decimal digits.

Returns:
the decimal digits

setDecimalDigits

public void setDecimalDigits(int decimalDigits)
Sets the decimal digits

Parameters:
decimalDigits - the decimal digits

getColumnSize

public int getColumnSize()
Gets the column size.

Returns:
the column size

setColumnSize

public void setColumnSize(int columnSize)
Sets the column size.

Parameters:
columnSize - the column size

getDefaultValue

public String getDefaultValue()
Gets the default value.

Returns:
the default value

setDefaultValue

public void setDefaultValue(String defaultValue)
Sets the default value.

Parameters:
defaultValue - the default value

getTypeName

public String getTypeName()
Gets the typeName.

Returns:
the typeName

setTypeName

public void setTypeName(String type)
Sets the typeName.

Parameters:
type - the typeName

isNullable

public boolean isNullable()
Gets whether the column can be null or not.

Returns:
true, if the table can be null; false, otherwise

setNullable

public void setNullable(boolean nullable)
Sets whether the column can be null or not.

Parameters:
nullable - true, if the table can be null; false, otherwise

setDataType

public void setDataType(int dataType)
Sets the data type.

Parameters:
dataType - the data type

getDataType

public int getDataType()
Gets the data type.

Returns:
the data type

compareTo

public int compareTo(TableColumn col)
Compares this column to another column based on their names. Can be used to sort the columns alphabetically.

Specified by:
compareTo in interface Comparable<TableColumn>
Parameters:
col - another TableColumn

copy

public TableColumn copy()
Creates a copy of this TableColumn.

Returns:
the copy of this TableColumn

equals

public boolean equals(Object o)
Overridden Method, tests if this column is equal to the o argument based on the name.

Overrides:
equals in class Object
Parameters:
o - the Object to test if it is equal to this table
Returns:
true, if o is not null, is a TableColumn and the AbstractDBItem.getName() method returns equal values for both this TableColumn and the TableColumn specified by the o argument; false, otherwise

hashCode

public int hashCode()
Overridden method, returns a hash code based on the column's name.

Overrides:
hashCode in class Object
Returns:
the hash code