- java.lang.Object
-
- org.tentackle.sql.metadata.ColumnMetaData
-
- Direct Known Subclasses:
MySqlColumnMetaData,OracleColumnMetaData,PostgresColumnMetaData
public class ColumnMetaData extends java.lang.ObjectMeta data for a column- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description ColumnMetaData(TableMetaData tableMetaData)Creates column meta data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetColumnName()Gets the columnName of the column.java.lang.StringgetComment()Gets the comment.java.lang.StringgetDefaultValue()Gets the column's default.intgetScale()Gets the numeric scale.intgetSize()Gets the column's size.TableMetaDatagetTableMetaData()Gets the table meta data.intgetType()Gets the column's type.java.lang.StringgetTypeName()Gets the backend-specific type columnName.booleanisNullable()Returns whether column is nullable.booleanmatchesSqlType(SqlType sqlType)Checks whether colunm's type matches given SqlType according to the backend.voidsetColumnName(java.lang.String columnName)Sets the column name.voidsetComment(java.lang.String comment)Sets the comment.voidsetDefaultValue(java.lang.String defaultValue)Sets the default value.voidsetNullable(boolean nullable)Sets whether column is nullable.voidsetScale(int scale)Sets the scale.voidsetSize(int size)Sets the size.voidsetType(int type)Sets the type.voidsetTypeName(java.lang.String typeName)Sets the type name.voidsetupColumnFromMetaData(java.sql.ResultSet resultSet)Sets up the column from the database meta data result.java.lang.StringtoString()voidvalidate()Validates and postprocesses the column data.
-
-
-
Constructor Detail
-
ColumnMetaData
public ColumnMetaData(TableMetaData tableMetaData)
Creates column meta data.- Parameters:
tableMetaData- the table meta data this column belongs to
-
-
Method Detail
-
getTableMetaData
public TableMetaData getTableMetaData()
Gets the table meta data.- Returns:
- the table this column belongs to
-
setupColumnFromMetaData
public void setupColumnFromMetaData(java.sql.ResultSet resultSet) throws java.sql.SQLExceptionSets up the column from the database meta data result.- Parameters:
resultSet- the column result set- Throws:
java.sql.SQLException- the processing the result set failed
-
getColumnName
public java.lang.String getColumnName()
Gets the columnName of the column.- Returns:
- the columnName (always in lowercase)
-
setColumnName
public void setColumnName(java.lang.String columnName)
Sets the column name.- Parameters:
columnName- the column name
-
getComment
public java.lang.String getComment()
Gets the comment.- Returns:
- the comment, null if none
-
setComment
public void setComment(java.lang.String comment)
Sets the comment.- Parameters:
comment- the comment
-
getType
public int getType()
Gets the column's type.- Returns:
- the type
- See Also:
Types
-
setType
public void setType(int type)
Sets the type.- Parameters:
type- the type
-
getTypeName
public java.lang.String getTypeName()
Gets the backend-specific type columnName.- Returns:
- the type columnName
-
setTypeName
public void setTypeName(java.lang.String typeName)
Sets the type name.- Parameters:
typeName- the type name
-
getSize
public int getSize()
Gets the column's size.- Returns:
- the size
-
setSize
public void setSize(int size)
Sets the size.- Parameters:
size- the size
-
getScale
public int getScale()
Gets the numeric scale.- Returns:
- the scale
-
setScale
public void setScale(int scale)
Sets the scale.- Parameters:
scale- the scale
-
getDefaultValue
public java.lang.String getDefaultValue()
Gets the column's default.- Returns:
- the default value
-
setDefaultValue
public void setDefaultValue(java.lang.String defaultValue)
Sets the default value.- Parameters:
defaultValue- the default value
-
isNullable
public boolean isNullable()
Returns whether column is nullable.- Returns:
- true if nullable
-
setNullable
public void setNullable(boolean nullable)
Sets whether column is nullable.- Parameters:
nullable- true if nullable
-
matchesSqlType
public boolean matchesSqlType(SqlType sqlType)
Checks whether colunm's type matches given SqlType according to the backend.- Parameters:
sqlType- the sqltype- Returns:
- true if matches
-
validate
public void validate()
Validates and postprocesses the column data.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-