Package org.apache.torque
Class ColumnImpl
- java.lang.Object
-
- org.apache.torque.ColumnImpl
-
- All Implemented Interfaces:
Serializable,Column
public class ColumnImpl extends Object implements Column, Serializable
An implementation of the column interface. This class is immutable, i.e cannot be changed once constructed.- Version:
- $Id: ColumnImpl.java 1879929 2020-07-16 07:42:57Z gk $
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ColumnImpl(String sqlExpression)Constructor which tries to guess schema, table and column names from an SQL expression.ColumnImpl(String tableName, String columnName)Constructor.ColumnImpl(String schemaName, String tableName, String columnName)Constructor.ColumnImpl(String schemaName, String tableName, String columnName, String sqlExpression)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)StringgetColumnName()Returns the column name.StringgetFullTableName()Returns the table name prefixed with the schema name if it exists.StringgetSchemaName()Returns the name of any fixed schema prefix for the column's table (if any).StringgetSqlExpression()Returns the SQL expression for the column, qualified by the table name but not by the schema name.StringgetTableName()Returns the table name.inthashCode()StringtoString()
-
-
-
Constructor Detail
-
ColumnImpl
public ColumnImpl(String tableName, String columnName)
Constructor.- Parameters:
tableName- the table name, not null or blank.columnName- the column name, not null or blank.- Throws:
NullPointerException- if columnName or tableName are null.IllegalArgumentException- if columnName or tableName are blank.
-
ColumnImpl
public ColumnImpl(String schemaName, String tableName, String columnName)
Constructor.- Parameters:
schemaName- the schema name, may be null but not blank.tableName- the table name, may be null but not blank. If it contains a dot, then only the portion after the dot will be taken as table name. If it contains a dot and schemaName is null, then the schema name will be set as the portion before the dot.columnName- the column name, not null or blank.- Throws:
NullPointerException- if columnName or tableName are null.IllegalArgumentException- if columnName or tableName are blank.
-
ColumnImpl
public ColumnImpl(String schemaName, String tableName, String columnName, String sqlExpression)
Constructor.- Parameters:
schemaName- the schema name, may be null but not blank.tableName- the table name, may be null but not blank. If it contains a dot, then only the portion after the dot will be taken as table name. If it contains a dot and schemaName is null, then the schema name will be set as the portion before the dot.columnName- the column name, may be null but not blank.sqlExpression- the SQL expression for the column, not null or blank.- Throws:
NullPointerException- if tableName or sqlExpression are null.IllegalArgumentException- if tableName or sqlExpression are blank.
-
ColumnImpl
public ColumnImpl(String sqlExpression)
Constructor which tries to guess schema, table and column names from an SQL expression. If a schema name can be identified in the SQL expression, it is removed from the SQL expression in the column.- Parameters:
sqlExpression- the SQL expression, not null, not blank.- Throws:
NullPointerException- if sqlExpression is null.IllegalArgumentException- if table or column name cannot be guessed from sqlExpression.
-
-
Method Detail
-
getColumnName
public String getColumnName()
Returns the column name.- Specified by:
getColumnNamein interfaceColumn- Returns:
- the column name, may be null.
-
getTableName
public String getTableName()
Returns the table name.- Specified by:
getTableNamein interfaceColumn- Returns:
- the table name, may be null.
-
getFullTableName
public String getFullTableName()
Returns the table name prefixed with the schema name if it exists. I.e. if a schema name exists, the result will be schemaName.tableName, and otherwise it will just be tableName.- Specified by:
getFullTableNamein interfaceColumn- Returns:
- the fully qualified table name of the column, may be null but not blank.
-
getSchemaName
public String getSchemaName()
Returns the name of any fixed schema prefix for the column's table (if any).- Specified by:
getSchemaNamein interfaceColumn- Returns:
- the schema name, or null if the schema is not known.
-
getSqlExpression
public String getSqlExpression()
Returns the SQL expression for the column, qualified by the table name but not by the schema name. This can also be a pseudocolumn (e.g. count(*)).- Specified by:
getSqlExpressionin interfaceColumn- Returns:
- the SQL expression for the column, not null.
-
-