Class DbColumn

java.lang.Object
org.silverpeas.components.mydb.model.DbColumn

public class DbColumn extends Object
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 Details

    • getType

      public int getType()
      Gets the SQL type of the values this column can contain. The values are define by the Types class.
      Returns:
      an integer identifying a generic SQL type.
    • getName

      public String getName()
      Gets the name of this column.
      Returns:
      the column's name.
    • getTypeName

      public String 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 the JDBCType class.
      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 the getName() method.
      Returns:
      true if the values in this column are the primary keys of another table. False otherwise.
    • getForeignKeyName

      public String 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, then NullPointerException is thrown.
      Returns:
      the unique foreign key name.
    • getReferencedColumn

      public String 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, then NullPointerException is thrown.
      Returns:
      the name of the column referenced by this foreign key.
    • getReferencedTable

      public String 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, then NullPointerException is 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

      public String getDefaultValue()
      Gets the String representation of the value by default of this column when no one is explicitly set.
      Returns:
      as a String the 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

      public Object getJdbcValueOf(String value)
      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.