de.fuberlin.wiwiss.d2rq.map
Class Column

java.lang.Object
  extended byde.fuberlin.wiwiss.d2rq.map.Column
All Implemented Interfaces:
java.lang.Cloneable, Prefixable, ValueSource

public class Column
extends java.lang.Object
implements ValueSource, Prefixable

A database column.

History:
08-03-2004: Initial version of this class.

Version:
V0.2
Author:
Richard Cyganiak

Field Summary
private  java.lang.String columnName
           
private  java.lang.String qualifiedName
           
private  java.lang.String tableName
           
 
Constructor Summary
Column(java.lang.String qualifiedName)
          Constructs a new Column from a fully qualified column name
Column(java.lang.String tableName, java.lang.String colName)
           
 
Method Summary
static java.lang.String appendTableColumn(java.lang.String t, java.lang.String c)
           
 java.lang.Object clone()
          Make a shallow copy of this.
 boolean couldFit(java.lang.String value)
          Checks if a given value fits this source without querying the database.
 boolean equals(java.lang.Object other)
          Compares this instance to another object.
 java.lang.String getColumnName()
          Extracts the database column name from a tablename.columnname combination.
 java.util.Set getColumns()
          Returns a set of all columns containing data necessary for this ValueSource.
 java.util.Map getColumnValues(java.lang.String value)
          Returns a map of database fields and values corresponding to the argument.
 java.lang.String getQualifiedName()
          Returns the column name in Table.Column form
 java.lang.String getQualifiedName(java.util.Map aliasMap)
           
 java.lang.String getTableName()
          Extracts the database table name from a tablename.columnname combination.
 java.lang.String getValue(java.lang.String[] row, java.util.Map columnNameNumberMap)
          Returns the value of this column from a database row.
 int hashCode()
          Returns a hash code for this intance.
 void prefixTables(TablePrefixer prefixer)
          Changes the fields in a newly created clone that are to be modified when making aliasses.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

qualifiedName

private java.lang.String qualifiedName

tableName

private java.lang.String tableName

columnName

private final java.lang.String columnName
Constructor Detail

Column

public Column(java.lang.String qualifiedName)
Constructs a new Column from a fully qualified column name

Parameters:
qualifiedName - the column's name, for example Table.Column

Column

public Column(java.lang.String tableName,
              java.lang.String colName)
Method Detail

appendTableColumn

public static java.lang.String appendTableColumn(java.lang.String t,
                                                 java.lang.String c)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Prefixable
Make a shallow copy of this. General advice: Do not overwrite clone(). prefixTables() works best with shallow copy which Object implements. Issues: I have not found a (preferred) static equivalent of clone(). Since Objects clone() method is protected, we cannot just declare Cloneable, if we want to call clone() from outside of that class hierarchy. Instead it must be public and implemented in each Prefixable class by a call to super.clone().

Specified by:
clone in interface Prefixable
Throws:
java.lang.CloneNotSupportedException

prefixTables

public void prefixTables(TablePrefixer prefixer)
Description copied from interface: Prefixable
Changes the fields in a newly created clone that are to be modified when making aliasses.

Specified by:
prefixTables in interface Prefixable
Parameters:
prefixer - does the actual prefixing of simple and complex types.

getQualifiedName

public java.lang.String getQualifiedName()
Returns the column name in Table.Column form

Returns:
the column name

getQualifiedName

public java.lang.String getQualifiedName(java.util.Map aliasMap)

getColumnName

public java.lang.String getColumnName()
Extracts the database column name from a tablename.columnname combination.

Returns:
database column name.

getTableName

public java.lang.String getTableName()
Extracts the database table name from a tablename.columnname combination.

Returns:
database table name.

couldFit

public boolean couldFit(java.lang.String value)
Description copied from interface: ValueSource
Checks if a given value fits this source without querying the database.

Specified by:
couldFit in interface ValueSource

getColumns

public java.util.Set getColumns()
Description copied from interface: ValueSource
Returns a set of all columns containing data necessary for this ValueSource.

Specified by:
getColumns in interface ValueSource
Returns:
a set of {Column}s

getColumnValues

public java.util.Map getColumnValues(java.lang.String value)
Description copied from interface: ValueSource
Returns a map of database fields and values corresponding to the argument.

For example, a ValueSource that corresponds directly to a single DB column would return a single-entry map with that column as the key, and value as the value.

Specified by:
getColumnValues in interface ValueSource
Parameters:
value - a non-null value
Returns:
a map with Column keys, and string values.

getValue

public java.lang.String getValue(java.lang.String[] row,
                                 java.util.Map columnNameNumberMap)
Returns the value of this column from a database row.

Specified by:
getValue in interface ValueSource
Parameters:
row - a database row
columnNameNumberMap - a map from qualified column names to indices into the row array
Returns:
this column's value

toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object other)
Compares this instance to another object. Two Columns are considered equal when they have the same fully qualified name. We need this because we want to use Column instances as map keys. TODO: should not be equal if from different databases


hashCode

public int hashCode()
Returns a hash code for this intance. We need this because we want to use Column instances as map keys. TODO: should be different for same-name columns from different databases