org.apache.empire.db.expr.join
Class DBJoinExpr

java.lang.Object
  extended by org.apache.empire.db.DBObject
      extended by org.apache.empire.db.DBExpr
          extended by org.apache.empire.db.expr.join.DBJoinExpr
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DBJoinExprEx

public class DBJoinExpr
extends DBExpr

This class is used for building a join expression of an SQL statement.

There is no need to explicitly create instances of this class.
Instead use @link DBCommand.join(DBColumnExpr, DBColumn, DBJoinType)

See Also:
Serialized Form

Field Summary
 DBCompareExpr compExpr
           
protected  DBColumnExpr left
           
protected  DBColumnExpr right
           
protected  DBJoinType type
           
 
Fields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE
 
Constructor Summary
DBJoinExpr(DBColumnExpr left, DBColumnExpr right, DBJoinType type)
          Constructs a new DBJoinExpr object initialize this object with the left and right column and the data type of the join expression.
 
Method Summary
 void addReferencedColumns(Set<DBColumn> list)
          Internal function to obtain all DBColumnExpr-objects used by this expression.
 void addSQL(StringBuilder buf, long context)
          Not allowed, this operation have to be done in the DBCommand object.
 DBCompareExpr and(DBColumnExpr c1, DBColumnExpr c2)
          This function adds an additional constraint to the join.
 boolean equals(Object obj)
          Compares two DBJoinExpr objects.
 DBDatabase getDatabase()
          Returns the current DBDatabase object.
 DBColumnExpr getLeft()
           
 DBRowSet getOuterTable()
          Returns the left table name if the data type= JOIN_LEFT and returns the right table if the data type= JOIN_RIGHT.
 DBColumnExpr getRight()
           
 DBJoinType getType()
           
 boolean isJoinOn(DBRowSet rowset)
           
 void reverse()
          This function swaps the left and the right statements of the join expression.
 void where(DBCompareExpr expr)
          This function adds an additional constraint to the join.
 
Methods inherited from class org.apache.empire.db.DBExpr
getObjectValue, getValueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

left

protected DBColumnExpr left

right

protected DBColumnExpr right

type

protected DBJoinType type

compExpr

public DBCompareExpr compExpr
Constructor Detail

DBJoinExpr

public DBJoinExpr(DBColumnExpr left,
                  DBColumnExpr right,
                  DBJoinType type)
Constructs a new DBJoinExpr object initialize this object with the left and right column and the data type of the join expression.

Parameters:
left - left value
right - right value
type - data type (JOIN_INNER, JOIN_LEFT or JOIN_RIGHT)
Method Detail

getDatabase

public DBDatabase getDatabase()
Returns the current DBDatabase object.

Specified by:
getDatabase in class DBObject
Returns:
the current DBDatabase object

getLeft

public DBColumnExpr getLeft()

getRight

public DBColumnExpr getRight()

getType

public DBJoinType getType()

isJoinOn

public boolean isJoinOn(DBRowSet rowset)

getOuterTable

public DBRowSet getOuterTable()
Returns the left table name if the data type= JOIN_LEFT and returns the right table if the data type= JOIN_RIGHT. If the data type = JOIN_INNER the return value is null.

Returns:
the current DBDatabase object

reverse

public void reverse()
This function swaps the left and the right statements of the join expression.


where

public void where(DBCompareExpr expr)
This function adds an additional constraint to the join.

Parameters:
expr - the compare expression

and

public DBCompareExpr and(DBColumnExpr c1,
                         DBColumnExpr c2)
This function adds an additional constraint to the join.

Parameters:
c1 - the first column
c2 - the second column
Returns:
the compare expression

addReferencedColumns

public void addReferencedColumns(Set<DBColumn> list)
Description copied from class: DBExpr
Internal function to obtain all DBColumnExpr-objects used by this expression.

Specified by:
addReferencedColumns in class DBExpr
Parameters:
list - list to which all used column expressions must be added
See Also:
DBExpr.addReferencedColumns(Set)

addSQL

public void addSQL(StringBuilder buf,
                   long context)
Not allowed, this operation have to be done in the DBCommand object.

Specified by:
addSQL in class DBExpr
Parameters:
buf - the string buffer used to build the sql command
context - context flag for this SQL-Command (see CTX_??? constants).

equals

public boolean equals(Object obj)
Compares two DBJoinExpr objects.

Overrides:
equals in class Object
Parameters:
obj - other DBJoinExpr object
Returns:
true if the other DBJoinExpr object is equal to this object


Copyright © 2008-2011 Apache Software Foundation. All Rights Reserved.