de.fuberlin.wiwiss.d2rq.algebra
Class Attribute

java.lang.Object
  extended by de.fuberlin.wiwiss.d2rq.algebra.Attribute
All Implemented Interfaces:
ProjectionSpec, Comparable<ProjectionSpec>

public class Attribute
extends Object
implements ProjectionSpec

A database column. TODO: Attribute should track its DataType TODO: Attribute should track whether it is nullable

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
Attribute(RelationName relationName, String attributeName)
           
Attribute(String schemaName, String tableName, String attributeName)
          Constructs a new attribute from a schema name, table name and attribute name.
 
Method Summary
 String attributeName()
          Extracts the database column name from a tablename.columnname combination.
 int compareTo(ProjectionSpec other)
          Compares columns alphanumerically by qualified name, case sensitive.
 boolean equals(Object other)
          Compares this instance to another object.
 int hashCode()
          Returns a hash code for this intance.
 Expression notNullExpression(ConnectedDB db, AliasMap aliases)
           
 String qualifiedName()
          Returns the column name in Table.Column form
 RelationName relationName()
          Returns the table name, including the schema if the table is in a schema.
 ProjectionSpec renameAttributes(ColumnRenamer renamer)
           
 Set<Attribute> requiredAttributes()
           
 String schemaName()
          Extracts the database schema name from a schema.table.colum combination.
 Expression selectValue(String value)
           
 String tableName()
          Returns the database table name.
 Expression toExpression()
           
 String toSQL(ConnectedDB database, AliasMap aliases)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String schemaName,
                 String tableName,
                 String attributeName)
Constructs a new attribute from a schema name, table name and attribute name.

Parameters:
schemaName - The schema name, or null if not in a schema
tableName - The table name
attributeName - The column name

Attribute

public Attribute(RelationName relationName,
                 String attributeName)
Method Detail

qualifiedName

public String qualifiedName()
Returns the column name in Table.Column form

Returns:
the column name

toSQL

public String toSQL(ConnectedDB database,
                    AliasMap aliases)
Specified by:
toSQL in interface ProjectionSpec

attributeName

public String attributeName()
Extracts the database column name from a tablename.columnname combination.

Returns:
database column name.

tableName

public String tableName()
Returns the database table name.

Returns:
database table name.

relationName

public RelationName relationName()
Returns the table name, including the schema if the table is in a schema.

Returns:
The table name in "table" or "schema.table" notation

schemaName

public String schemaName()
Extracts the database schema name from a schema.table.colum combination.

Returns:
database schema name, or null if no schema is specified.

requiredAttributes

public Set<Attribute> requiredAttributes()
Specified by:
requiredAttributes in interface ProjectionSpec

selectValue

public Expression selectValue(String value)

renameAttributes

public ProjectionSpec renameAttributes(ColumnRenamer renamer)
Specified by:
renameAttributes in interface ProjectionSpec

toExpression

public Expression toExpression()
Specified by:
toExpression in interface ProjectionSpec

notNullExpression

public Expression notNullExpression(ConnectedDB db,
                                    AliasMap aliases)
Specified by:
notNullExpression in interface ProjectionSpec

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(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

Overrides:
equals in class Object

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

Overrides:
hashCode in class Object

compareTo

public int compareTo(ProjectionSpec other)
Compares columns alphanumerically by qualified name, case sensitive. Attributes with schema are larger than attributes without schema.

Specified by:
compareTo in interface Comparable<ProjectionSpec>