Class Column

java.lang.Object
net.sf.jailer.datamodel.Column

public class Column extends Object
Column of a table.
Author:
Ralf Wisser
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    true if column is identity column.
    boolean
    true if column is nullable.
    boolean
    true if column is virtual.
    final int
    The length (for VARCHAR, DECIMAL, ...) or 0 if type-length is not variable.
    final String
    The name.
    final int
    The precision (for DECIMAL, NUMBER ...) or -1 if precision is not variable.
    The type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Column(String name, String type, int length, int precision)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks equality based on name, type, and length.
    Gets filter for server-side column data filtering.
    Gets SQL expression for server-side column data filtering.
    int
    Returns a hash code based on name, type, and length.
    boolean
    Returns true iff this column is virtual.
    static Column
    parse(String columnDeclaration)
    Parses a column declaration in SQL syntax.
    static Column
    parse(String columnName, String theColumnDeclaration)
    Parses a column declaration in SQL syntax.
    void
    setFilter(Filter filter)
    Sets filter for server-side column data filtering.
    toSQL(String columnPrefix)
    Returns the column definition in SQL syntax.
    toSQL(String columnPrefix, Map<String,String> typeReplacement)
    Returns the column definition in SQL syntax.
    Returns a string representation of the column.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public final String name
      The name.
    • type

      public String type
      The type.
    • length

      public final int length
      The length (for VARCHAR, DECIMAL, ...) or 0 if type-length is not variable.
    • precision

      public final int precision
      The precision (for DECIMAL, NUMBER ...) or -1 if precision is not variable.
    • isIdentityColumn

      public boolean isIdentityColumn
      true if column is identity column.
    • isVirtual

      public boolean isVirtual
      true if column is virtual.
    • isNullable

      public boolean isNullable
      true if column is nullable.
  • Constructor Details

    • Column

      public Column(String name, String type, int length, int precision)
      Constructor.
      Parameters:
      name - the name (upper-case)
      type - the type (in SQL)
      length - the length (for VARCHAR, DECIMAL, ...) or 0 if type-length is not variable
      precision - the precision (for DECIMAL, NUMBER ...) or -1 if precision is not variable
  • Method Details

    • getFilterExpression

      public String getFilterExpression()
      Gets SQL expression for server-side column data filtering. Filter.OLD_VALUE_PROP is replaced by column name.
      Returns:
      SQL expression for server-side column data filtering or null, if no filter is defined for this column
    • getFilter

      public Filter getFilter()
      Gets filter for server-side column data filtering.
      Returns:
      filter for server-side column data filtering or null, if no filter is defined for this column
    • setFilter

      public void setFilter(Filter filter)
      Sets filter for server-side column data filtering.
      Parameters:
      filter - SQL expression for server-side column data filtering or null, if no filter is defined for this column
    • parse

      public static Column parse(String columnDeclaration)
      Parses a column declaration in SQL syntax.
      Parameters:
      columnDeclaration - the column declaration in SQL syntax
      Returns:
      the column
    • parse

      public static Column parse(String columnName, String theColumnDeclaration)
      Parses a column declaration in SQL syntax.
      Parameters:
      columnName - (optional) name of column
      theColumnDeclaration - the column declaration in SQL syntax
      Returns:
      the column
    • equals

      public boolean equals(Object obj)
      Checks equality based on name, type, and length.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if the columns are equal
    • hashCode

      public int hashCode()
      Returns a hash code based on name, type, and length.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • toSQL

      public String toSQL(String columnPrefix, Map<String,String> typeReplacement)
      Returns the column definition in SQL syntax.
      Parameters:
      columnPrefix - an optional prefix for the column name
      typeReplacement - column type replacements
      Returns:
      the column definition in SQL syntax
    • toSQL

      public String toSQL(String columnPrefix)
      Returns the column definition in SQL syntax.
      Parameters:
      columnPrefix - an optional prefix for the column name
      Returns:
      the column definition in SQL syntax
    • toString

      public String toString()
      Returns a string representation of the column.
      Overrides:
      toString in class Object
      Returns:
      the column definition in SQL syntax
    • isVirtual

      public boolean isVirtual()
      Returns true iff this column is virtual.
      Returns:
      true iff this column is virtual