de.fuberlin.wiwiss.d2rq.map
Class Join

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

public class Join
extends java.lang.Object
implements Prefixable

Represents an SQL join between two tables, spanning one or more columns.

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

Version:
V0.2
Author:
Richard Cyganiak

Field Summary
private  java.util.Set fromColumns
           
private  java.lang.String fromTable
           
private  java.util.Map otherSide
           
private  java.lang.String sqlExpression
           
private  java.util.Set toColumns
           
private  java.lang.String toTable
           
 
Constructor Summary
Join()
           
 
Method Summary
 void addCondition(java.lang.String joinCondition)
           
static Join buildJoin(java.lang.String condition)
           
static java.util.Set buildJoins(java.util.Collection joinConditions)
          Builds a list of Join objects from a list of join condition strings.
 java.lang.Object clone()
          Make a shallow copy of this.
 boolean containsColumn(Column column)
           
 boolean containsTable(java.lang.String tableName)
           
private static Column getColumn(java.lang.String joinCondition, boolean first)
           
 java.util.Set getFirstColumns()
           
 java.lang.String getFirstTable()
           
 Column getOtherSide(Column column)
           
 java.util.Set getSecondColumns()
           
 java.lang.String getSecondTable()
           
 boolean isOneSide(java.util.Set columns)
          Checks if one side of the join is equal to the argument set of Columns.
 void prefixTables(TablePrefixer prefixer)
          Changes the fields in a newly created clone that are to be modified when making aliasses.
 java.lang.String sqlExpression()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fromColumns

private java.util.Set fromColumns

toColumns

private java.util.Set toColumns

otherSide

private java.util.Map otherSide

fromTable

private java.lang.String fromTable

toTable

private java.lang.String toTable

sqlExpression

private java.lang.String sqlExpression
Constructor Detail

Join

public Join()
Method Detail

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.

addCondition

public void addCondition(java.lang.String joinCondition)

containsTable

public boolean containsTable(java.lang.String tableName)

containsColumn

public boolean containsColumn(Column column)

getFirstTable

public java.lang.String getFirstTable()

getSecondTable

public java.lang.String getSecondTable()

getFirstColumns

public java.util.Set getFirstColumns()

getSecondColumns

public java.util.Set getSecondColumns()

isOneSide

public boolean isOneSide(java.util.Set columns)
Checks if one side of the join is equal to the argument set of Columns.

Parameters:
columns - a set of Column instances
Returns:
true if one side of the join is equal to the column set

getOtherSide

public Column getOtherSide(Column column)

getColumn

private static Column getColumn(java.lang.String joinCondition,
                                boolean first)

buildJoins

public static java.util.Set buildJoins(java.util.Collection joinConditions)
Builds a list of Join objects from a list of join condition strings. Groups multiple condition that connect the same two table (multi-column keys) into a single join.

Parameters:
joinConditions - a collection of strings
Returns:
a set of Join instances

buildJoin

public static Join buildJoin(java.lang.String condition)

sqlExpression

public java.lang.String sqlExpression()

toString

public java.lang.String toString()