com.semarchy.mdm.runtime.model.dataaccess
Class FromClause

java.lang.Object
  extended by com.semarchy.mdm.runtime.model.dataaccess.FromClause

public class FromClause
extends Object

Represents a generic SQL from clause.

The from clause can either be:

 from [table_name] [alias]
        [joins to other tables or sub-queries]*
 
Or
 from (
        [sub-query SQL select statement]
        ) [alias]
        [joins to other tables or sub-queries]*
 

The isSubQueryClause() method indicates whether one should get information from either getTableName() or from getSubQuerySQL()

Author:
skamel

Constructor Summary
FromClause(boolean pSubQueryClause)
          Creates a from clause (either based on a table or based on a sub query)
 
Method Summary
 void addJoinClause(JoinClause pJoinClause)
          adds a join clause to the base driving table
 List<JoinClause> getJoinClauses()
           
 String getSubQuerySQL()
           
 String getTableAlias()
           
 String getTableName()
           
 boolean isSubQueryClause()
           
 void setSubQuerySQL(String pSubQuerySQL)
          Sets the sub query Select statement clause.
 void setTableAlias(String pTableAlias)
          Sets the table alias
 void setTableName(String pTableName)
          Set the table name of this from clause
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FromClause

public FromClause(boolean pSubQueryClause)
Creates a from clause (either based on a table or based on a sub query)

Parameters:
pSubQueryClause - if set to true, indicates that this from clause is based on a sub-query
Method Detail

getTableName

public String getTableName()
Returns:
the base table name (driving table)

getTableAlias

public String getTableAlias()
Returns:
the base table alias of the driving table as used in all subsequent SQL expressions

getJoinClauses

public List<JoinClause> getJoinClauses()
Returns:
the non-null list of join clauses. Can be empty if from clause does not join to any other table

addJoinClause

public void addJoinClause(JoinClause pJoinClause)
adds a join clause to the base driving table

Parameters:
pJoinClause -

isSubQueryClause

public boolean isSubQueryClause()
Returns:
whether this from clause is based on a sub-query rather than on a table

getSubQuerySQL

public String getSubQuerySQL()
Returns:
the sub-query SQL or null if the from clause is not sub-query based (use isSubQueryClause() to figure out)

setSubQuerySQL

public void setSubQuerySQL(String pSubQuerySQL)
Sets the sub query Select statement clause.

Parameters:
pSubQuerySQL - select statement to set
Throws:
RuntimeException - a runtime exception if the from clause was not built with isSubQueryClause() set to true

setTableName

public void setTableName(String pTableName)
Set the table name of this from clause

Parameters:
pTableName - table name to set
Throws:
RuntimeException - a runtime exception if the from clause was not built with isSubQueryClause() set to false

setTableAlias

public void setTableAlias(String pTableAlias)
Sets the table alias

Parameters:
pTableAlias - table alias to use for the sub-query or table in this from clause


Copyright © 2015. All Rights Reserved.