com.is.jrf
Class JoinTable

java.lang.Object
  |
  +--com.is.jrf.JoinTable
Direct Known Subclasses:
OuterJoinTable

public class JoinTable
extends java.lang.Object

Instances of this class represent a plain old inner join.


Field Summary
protected  java.lang.String i_joinColumnNames
          This is used to do the table join
protected  java.util.List i_joinColumns
          List of JoinColumn objects
protected  java.util.List i_joinTables
          List of JoinTable objects
protected  java.lang.String i_mainColumnNames
          This is used to do the table join
protected  java.lang.String i_tableAlias
           
protected  java.lang.String i_tableName
           
 
Constructor Summary
JoinTable(java.lang.String tableName, java.lang.String mainColumnNames, java.lang.String joinColumnNames)
          Construct an instance that is ready to be used.
 
Method Summary
 void addJoinColumn(JoinColumn aJoinColumn)
          Add a subclass instance of JoinColumn.
 void addJoinTable(JoinTable aJoinTable)
          Add an instance of JoinTable that will be joined with this JoinTable.
protected  java.lang.String ansiJoinCommand()
          Return something like "JOIN" or "LEFT OUTER JOIN", etc...
 java.lang.String buildANSIJoin(java.lang.String mainTableAlias)
          Build an ANSI join statement.
protected  void buildFromString(java.lang.StringBuffer sqlBuffer)
          Add a list of table names to the StringBuffer like this:
'Video V, Media M, Genre G'
 java.lang.String buildNonANSIJoin(java.lang.String mainTableAlias, DatabasePolicy dbPolicy)
          Build a non-standard join that goes into the WHERE clause.
protected  void buildSelectColumnString(java.lang.StringBuffer sqlBuffer)
           
protected  java.lang.String buildWhereJoin(java.lang.String mainColumnName, java.lang.String joinColumnName, DatabasePolicy dbPolicy)
          This method is overridden by the OuterJoinTable subclass.
protected  void copyColumnValuesToPersistentObject(JDBCHelper aJDBCHelper, PersistentObject aPO)
           
 java.lang.String getJoinColumnNames()
          This should be a string of column names separated by commas if there is more than one.
 java.util.List getJoinColumns()
          This vector holds subclass instances of JoinColumn.
 java.util.List getJoinTables()
          This vector holds instances of JoinTable.
 java.lang.String getMainColumnNames()
          This should be a string of column names separated by commas if there is more than one.
 java.lang.String getTableAlias()
           
 java.lang.String getTableName()
           
 void setJoinColumnNames(java.lang.String joinColumnNames)
          This would be a string of comma-separated column name(s) like:
"id,code" or just "id"
 void setMainColumnNames(java.lang.String mainColumnNames)
          This would be a string of comma-separated column name(s) like:
"id,code" or just "id"
 void setTableAlias(java.lang.String alias)
           
 void setTableName(java.lang.String s)
          If the name looks like this: 'Customer c', then put 'Customer' into the tableName variable and put 'c' into the tableAlias variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i_tableName

protected java.lang.String i_tableName

i_tableAlias

protected java.lang.String i_tableAlias

i_mainColumnNames

protected java.lang.String i_mainColumnNames
This is used to do the table join

i_joinColumnNames

protected java.lang.String i_joinColumnNames
This is used to do the table join

i_joinColumns

protected java.util.List i_joinColumns
List of JoinColumn objects

i_joinTables

protected java.util.List i_joinTables
List of JoinTable objects
Constructor Detail

JoinTable

public JoinTable(java.lang.String tableName,
                 java.lang.String mainColumnNames,
                 java.lang.String joinColumnNames)
Construct an instance that is ready to be used.
Parameters:
tableName - a value of type 'String' - This can include an alias
mainColumnNames - a value of type 'String'
joinColumnNames - a value of type 'String'
Method Detail

addJoinColumn

public void addJoinColumn(JoinColumn aJoinColumn)
Add a subclass instance of JoinColumn.
Parameters:
aJoinColumn - a value of type 'JoinColumn'

getJoinColumns

public java.util.List getJoinColumns()
This vector holds subclass instances of JoinColumn.
Returns:
a value of type 'List'

setTableName

public void setTableName(java.lang.String s)
If the name looks like this: 'Customer c', then put 'Customer' into the tableName variable and put 'c' into the tableAlias variable.
Parameters:
s - a value of type 'String'

getTableName

public java.lang.String getTableName()

setTableAlias

public void setTableAlias(java.lang.String alias)

getTableAlias

public java.lang.String getTableAlias()

getMainColumnNames

public java.lang.String getMainColumnNames()
This should be a string of column names separated by commas if there is more than one.
Returns:
a value of type 'String'

setMainColumnNames

public void setMainColumnNames(java.lang.String mainColumnNames)
This would be a string of comma-separated column name(s) like:
"id,code" or just "id"
Parameters:
mainColumnNames - a value of type 'String'

getJoinColumnNames

public java.lang.String getJoinColumnNames()
This should be a string of column names separated by commas if there is more than one.
Returns:
a value of type 'String'

setJoinColumnNames

public void setJoinColumnNames(java.lang.String joinColumnNames)
This would be a string of comma-separated column name(s) like:
"id,code" or just "id"
Parameters:
joinColumnNames - a value of type 'String'

addJoinTable

public void addJoinTable(JoinTable aJoinTable)
Add an instance of JoinTable that will be joined with this JoinTable.
Parameters:
aJoinTable - a value of type 'JoinTable'

getJoinTables

public java.util.List getJoinTables()
This vector holds instances of JoinTable.
Returns:
a value of type 'List'

buildANSIJoin

public java.lang.String buildANSIJoin(java.lang.String mainTableAlias)
Build an ANSI join statement.
Parameters:
mainTableName - a value of type 'String'
Returns:
a value of type 'String'

buildNonANSIJoin

public java.lang.String buildNonANSIJoin(java.lang.String mainTableAlias,
                                         DatabasePolicy dbPolicy)
Build a non-standard join that goes into the WHERE clause. Match up the main column names with the join column names.
Parameters:
mainTableName - a value of type 'String'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

copyColumnValuesToPersistentObject

protected void copyColumnValuesToPersistentObject(JDBCHelper aJDBCHelper,
                                                  PersistentObject aPO)
                                           throws java.sql.SQLException

buildSelectColumnString

protected void buildSelectColumnString(java.lang.StringBuffer sqlBuffer)

buildFromString

protected void buildFromString(java.lang.StringBuffer sqlBuffer)
Add a list of table names to the StringBuffer like this:
'Video V, Media M, Genre G'
Parameters:
sqlBuffer - a value of type 'StringBuffer'

ansiJoinCommand

protected java.lang.String ansiJoinCommand()
Return something like "JOIN" or "LEFT OUTER JOIN", etc... Subclasses override.
Returns:
a value of type 'String'

buildWhereJoin

protected java.lang.String buildWhereJoin(java.lang.String mainColumnName,
                                          java.lang.String joinColumnName,
                                          DatabasePolicy dbPolicy)
This method is overridden by the OuterJoinTable subclass. In the case of outer join, this returns a non-standard SQL name/value pair to be used in a where clause join. i.e. T1.id = T2.id(+) (Oracle)
Parameters:
mainColumnName - a value of type 'String'
joinColumnName - a value of type 'String'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'