Package com.mckoi.database
Class JoiningSet
- java.lang.Object
-
- com.mckoi.database.JoiningSet
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public final class JoiningSet extends java.lang.Object implements java.io.Serializable, java.lang.CloneableUsed in TableSet to describe how we naturally join the tables together. This is used when the TableSet has evaluated the search condition and it is required for any straggling tables to be naturally joined. In SQL, these joining types are specified in the FROM clause.For example,
FROM table_a LEFT OUTER JOIN table_b ON ( table_a.id = table_b.id ), ...
A ',' should donate an INNER_JOIN in an SQL FROM clause.
- Author:
- Tobias Downer
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJoiningSet.JoinPart
-
Field Summary
Fields Modifier and Type Field Description static intFULL_OUTER_JOINstatic intINNER_JOINStatics for Join Types.static intLEFT_OUTER_JOINstatic intRIGHT_OUTER_JOIN
-
Constructor Summary
Constructors Constructor Description JoiningSet()Constructs the JoiningSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJoin(int type)Adds a joining type to the set with no 'on' expression.voidaddJoin(int type, Expression on_expression)Adds a joining type to the set, and an 'on' expression.voidaddPreviousJoin(int type, Expression on_expression)Hack, add a joining type to the previous entry from the end.voidaddTable(TableName table_name)Adds a new table into the set being joined.java.lang.Objectclone()Performs a deep clone on this object.TableNamegetFirstTable()Returns the first table in the join set.intgetJoinType(int n)Returns the type of join after table 'n' in the set.ExpressiongetOnExpression(int n)Returns the ON Expression for the type of join after table 'n' in the set.TableNamegetTable(int n)Returns table 'n' in the result set where table 0 is the first table in the join set.intgetTableCount()Returns the number of tables that are in this set.voidprepare(DatabaseConnection connection)Resolves the schema of tables in this joining set.
-
-
-
Field Detail
-
INNER_JOIN
public static final int INNER_JOIN
Statics for Join Types.- See Also:
- Constant Field Values
-
LEFT_OUTER_JOIN
public static final int LEFT_OUTER_JOIN
- See Also:
- Constant Field Values
-
RIGHT_OUTER_JOIN
public static final int RIGHT_OUTER_JOIN
- See Also:
- Constant Field Values
-
FULL_OUTER_JOIN
public static final int FULL_OUTER_JOIN
- See Also:
- Constant Field Values
-
-
Method Detail
-
prepare
public void prepare(DatabaseConnection connection)
Resolves the schema of tables in this joining set. This runs through each table in the joining set and if the schema has not been set for the table then it attempts to resolve it against the given DatabaseConnection object. This would typically be called in the preparation of a statement.
-
addTable
public void addTable(TableName table_name)
Adds a new table into the set being joined. The table name should be the unique name that distinguishes this table in the TableSet.
-
addPreviousJoin
public void addPreviousJoin(int type, Expression on_expression)Hack, add a joining type to the previous entry from the end. This is an artifact of how joins are parsed.
-
addJoin
public void addJoin(int type, Expression on_expression)Adds a joining type to the set, and an 'on' expression.
-
addJoin
public void addJoin(int type)
Adds a joining type to the set with no 'on' expression.
-
getTableCount
public int getTableCount()
Returns the number of tables that are in this set.
-
getFirstTable
public TableName getFirstTable()
Returns the first table in the join set.
-
getTable
public TableName getTable(int n)
Returns table 'n' in the result set where table 0 is the first table in the join set.
-
getJoinType
public int getJoinType(int n)
Returns the type of join after table 'n' in the set. An example of using this;String table1 = joins.getFirstTable(); for (int i = 0; i < joins.getTableCount() - 1; ++i) { int type = joins.getJoinType(i); String table2 = getTable(i + 1); // ... Join table1 and table2 ... table1 = table2; }
-
getOnExpression
public Expression getOnExpression(int n)
Returns the ON Expression for the type of join after table 'n' in the set.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionPerforms a deep clone on this object.- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-