org.apache.torque.criteria
Class FromElement

java.lang.Object
  extended by org.apache.torque.criteria.FromElement
All Implemented Interfaces:
Serializable

public class FromElement
extends Object
implements Serializable

This class describes an Element in the From-part of a SQL clause. It must contain the name of the database table. It might contain an alias for the table name, a join type a join condition and prepared statement replacements. The class is immutable.

See Also:
Serialized Form

Constructor Summary
FromElement(String tableName)
          Constructor with join type null and joinCondition null.
FromElement(String fromExpression, JoinType joinType, PreparedStatementPart joinCondition)
          Constructor.
FromElement(String fromExpression, JoinType joinType, String joinCondition)
          Constructor.
FromElement(String fromExpression, JoinType joinType, String joinCondition, List<Object> preparedStatementReplacements)
          Constructor.
 
Method Summary
 boolean equals(Object obj)
           
 String getFromExpression()
          Returns the fromExpression, which might e.g.
 String getJoinCondition()
          Returns the join condition.
 JoinType getJoinType()
          Returns the join type.
 List<Object> getPreparedStatementReplacements()
          Returns the replacements for prepared statement placeholders in the fromExpression.
 int hashCode()
           
 String toString()
          Returns a SQL representation of the element.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FromElement

public FromElement(String tableName)
Constructor with join type null and joinCondition null.

Parameters:
tableName - the table name, might contain an appended alias name e.g.
table_1
table_1 alias_for_table_1

FromElement

public FromElement(String fromExpression,
                   JoinType joinType,
                   String joinCondition)
Constructor.

Parameters:
fromExpression - the expression to add to the from clause, e.g. a simple table name or a table name with an alias, e.g.
table_1
table_1 alias_for_table_1
joinType - the type of the join, e.g. JoinType.LEFT_JOIN, or null if no excplicit join is wanted
joinCondition - the join condition, e.g. table_a.id = table_b.a_id, or null if no explicit join is wanted (In this case, the join condition is appended to the whereClause instead)

FromElement

public FromElement(String fromExpression,
                   JoinType joinType,
                   String joinCondition,
                   List<Object> preparedStatementReplacements)
Constructor.

Parameters:
fromExpression - the expression to add to the from clause, e.g. a simple table name or a table name with an alias, e.g.
table_1
table_1 alias_for_table_1
joinType - the type of the join, e.g. JoinType.LEFT_JOIN, or null if no explicit join is wanted
joinCondition - the join condition, e.g. table_a.id = table_b.a_id, or null if no explicit join is wanted (In this case, the join condition is appended to the whereClause instead)
preparedStatementReplacements - the replacements for placeholders which might occur in the fromExpression, may be null.

FromElement

public FromElement(String fromExpression,
                   JoinType joinType,
                   PreparedStatementPart joinCondition)
Constructor.

Parameters:
fromExpression - the expression to add to the from clause, e.g. a simple table name or a table name with an alias, e.g.
table_1
table_1 alias_for_table_1
joinType - the type of the join, e.g. JoinType.LEFT_JOIN, or null if no explicit join is wanted
joinCondition - the join condition, e.g. table_a.id = table_b.a_id, not null.
Method Detail

getJoinCondition

public String getJoinCondition()
Returns the join condition.

Returns:
the join condition, e.g. table_a.id = table_b.a_id, or null if the join is not an explicit join

getJoinType

public JoinType getJoinType()
Returns the join type.

Returns:
the type of the join, e.g. JoinType.LEFT_JOIN, or null if the join is not an explicit join

getFromExpression

public String getFromExpression()
Returns the fromExpression, which might e.g. be a simple table name or a table name or a subquery with an alias appended.

Returns:
the tablename, might contain an appended alias name, e.g.
table_1
table_1 alias_for_table_1

getPreparedStatementReplacements

public List<Object> getPreparedStatementReplacements()
Returns the replacements for prepared statement placeholders in the fromExpression.

Returns:
the replacements, not null.

toString

public String toString()
Returns a SQL representation of the element.

Overrides:
toString in class Object
Returns:
a SQL representation of the element

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2000-2012 The Apache Software Foundation. All Rights Reserved.