Class DbColumn
java.lang.Object
org.silverpeas.components.mydb.model.DbColumn
A column in a database table. The column doesn't contain any values, it defines the column in
a
DbTable instance by a name and a type.- Author:
- mmoquillon
-
Method Summary
Modifier and TypeMethodDescriptionGets the String representation of the value by default of this column when no one is explicitly set.Gets the name of the foreign key to which this column is a component.getJdbcValueOf(String value) Gets a JDBC value of given value.getName()Gets the name of this column.Gets the column that is referenced by this column if this column is a foreign key.Gets the table that is referenced by this column if this column is a foreign key.intgetSize()Gets the size of this column.intgetType()Gets the SQL type of the values this column can contain.Gets the name of the SQL type of the values this column can contain.booleanIs the valuation of this column autogenerated when a new tuple is inserted into the table?booleanIs there a default value defined for this column?booleanIs this column references a column of another table.booleanIs this column accepts null values?booleanIs this column is of type binary (BLOB, VARBINARY, ...)?booleanIs this column is of type text (VARCHAR, CLOB, ...)?booleanIs this column represents a primary key?
-
Method Details
-
getType
public int getType()Gets the SQL type of the values this column can contain. The values are define by theTypesclass.- Returns:
- an integer identifying a generic SQL type.
-
getName
Gets the name of this column.- Returns:
- the column's name.
-
getTypeName
Gets the name of the SQL type of the values this column can contain. The name is determined from the SQL type code by using theJDBCTypeclass.- Returns:
- the name of the column's SQL type (VARCHAR, TIMESTAMP, ...)
-
getSize
public int getSize()Gets the size of this column. It depends on its type; for example for VARCHAR(256), its size is 256.- Returns:
- the size of this column according to its type.
-
isPrimaryKey
public boolean isPrimaryKey()Is this column represents a primary key?- Returns:
- true if the values in this column are or are part of a primary key. False otherwise.
-
isForeignKey
public boolean isForeignKey()Is this column references a column of another table. If true, then the column takes part of a foreign key whose name is given by thegetName()method.- Returns:
- true if the values in this column are the primary keys of another table. False otherwise.
-
getForeignKeyName
Gets the name of the foreign key to which this column is a component. Several columns can be part of the same foreign key; in this case, the foreign key name is a way to figure out them. If this column isn't a foreign key, thenNullPointerExceptionis thrown.- Returns:
- the unique foreign key name.
-
getReferencedColumn
Gets the column that is referenced by this column if this column is a foreign key. If this column isn't a foreign key, thenNullPointerExceptionis thrown.- Returns:
- the name of the column referenced by this foreign key.
-
getReferencedTable
Gets the table that is referenced by this column if this column is a foreign key. If this column isn't a foreign key, thenNullPointerExceptionis thrown.- Returns:
- the name of the table referenced by this foreign key.
-
isNullable
public boolean isNullable()Is this column accepts null values?- Returns:
- true if this column is nullable. False otherwise.
-
isAutoValued
public boolean isAutoValued()Is the valuation of this column autogenerated when a new tuple is inserted into the table?- Returns:
- true if this column is auto-valuated by the database when a row is newly inserted into the table this column belongs to.
-
isDefaultValueDefined
public boolean isDefaultValueDefined()Is there a default value defined for this column?- Returns:
- true if a default value is defined for this column, false otherwise.
-
getDefaultValue
Gets the String representation of the value by default of this column when no one is explicitly set.- Returns:
- as a
Stringthe default value of this column.
-
isOfTypeText
public boolean isOfTypeText()Is this column is of type text (VARCHAR, CLOB, ...)?- Returns:
- true if the values of this column are textual. False otherwise.
-
isOfTypeBinary
public boolean isOfTypeBinary()Is this column is of type binary (BLOB, VARBINARY, ...)?- Returns:
- true if the values of this column are binary. False otherwise.
-
getJdbcValueOf
Gets a JDBC value of given value. The aim is to get a value to fill into JDBC query criteria filters.Comma character is used to define a list of values.
- Parameters:
value- a value to convert.- Returns:
- a JDBC value according to the SQL type of the column.
-