|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectproper.core.ProperObject
proper.database.ConnectorObject
proper.database.ExecutorObject
proper.database.Joiner
public class Joiner
This class can perform different kinds of joins:
Field Summary | |
---|---|
static int |
BESTOUTER_JOIN
the best possible join (left outer or right outer) |
static java.lang.String |
JOIN_PREFIX
prefix (+ number from ID) for ambigious columns in a join |
static int |
LEFTOUTER_JOIN
the left outer join |
static int |
NATURAL_JOIN
the default join |
static int |
RIGHTOUTER_JOIN
the right outer join |
Fields inherited from interface proper.core.ProperInterface |
---|
VERSION |
Constructor Summary | |
---|---|
Joiner(Connector conn)
initializes the object |
Method Summary | |
---|---|
java.util.HashSet |
ambigiousColumns(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns)
fills a hashset with the names of ambigious columns (actually instances of the class Column, not just the names), i.e. |
java.lang.String |
createJoin(java.lang.String table1,
java.lang.String prefix1,
java.lang.String table2,
java.lang.String prefix2,
java.util.Vector joinColumns,
int type)
creates the join statement with the given values, if no prefixes are given then there's one added automatically for ambigious columns |
java.lang.String |
createJoin(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
int type)
creates the join statement with the given values |
java.lang.String |
createJoin(java.lang.String table1,
java.lang.String prefix1,
java.util.Vector cols1,
java.lang.String table2,
java.lang.String prefix2,
java.util.Vector cols2,
java.util.Vector joinColumns,
int type)
creates the join statement with the given values, if no prefixes are given then there's one added automatically for ambigious columns |
int |
determineBestJoin(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns)
determines the best join to perform over the two given tables and columns |
int |
determineBestJoin(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
java.lang.String classField)
determines the best join to perform over the two given tables and columns, where it takes into account not to loose any classes, if the class field is given |
java.util.Vector |
determineColumns(java.lang.String table1,
boolean onlyIndexes1,
java.lang.String table2,
boolean onlyIndexes2)
determines the columns to use in the join (the returned vector contains instances of "Join"). |
java.util.Vector |
determineColumns(java.lang.String table1,
java.lang.String table2)
determines the columns to use in the join over all fields, not just indexes (the returned vector contains instances of "Table") |
int |
getClassCount(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
java.lang.String classField,
int joinType)
returns the number of classes resulting from the given join |
java.lang.String |
getInsteadOfNull()
returns the values (commalist of the format "name=value") to be used instead of NULL in the columns of a OUTER JOIN where NULL was inserted |
int |
getJoinType()
returns the current join type |
int |
getRowsWithClassCount(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
java.lang.String classField,
int joinType)
returns the number of rows with a class label resulting from the given join |
java.lang.String |
getTableCreateFromSelect(java.lang.String table,
java.lang.String sql)
generates a CREATE TABLE statement from the given select statement. |
boolean |
getUseForeignKeys()
returns whether foreign keys are used for discovering relations between tables or only matching column names |
boolean |
join(java.lang.String table1,
java.lang.String table2,
java.lang.String resultTable)
joins the two tables over all common columns, not just indexes |
boolean |
join(java.lang.String table1,
java.lang.String prefix1,
java.lang.String table2,
java.lang.String prefix2,
java.util.Vector joinColumns,
java.lang.String resultTable)
joins the two tables over the given columns |
boolean |
join(java.lang.String table1,
java.lang.String prefix1,
java.lang.String table2,
java.lang.String prefix2,
java.util.Vector joinColumns,
java.lang.String resultTable,
java.lang.String classField)
joins the two tables over the given columns, prefixes have to be given for both tables, otherwise they are ignored |
boolean |
join(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
java.lang.String resultTable)
joins the two tables over the given columns |
boolean |
join(java.lang.String table1,
java.lang.String table2,
java.util.Vector joinColumns,
java.lang.String resultTable,
java.lang.String classField)
joins the two tables over the given columns |
boolean |
join(java.lang.String table1,
java.lang.String prefix1,
java.util.Vector cols1,
java.lang.String table2,
java.lang.String prefix2,
java.util.Vector cols2,
java.util.Vector joinColumns,
java.lang.String resultTable,
java.lang.String classField)
joins the two tables over the given columns, prefixes have to be given for both tables, otherwise they are ignored |
static int |
parseType(java.lang.String type)
parses the given string to get the type from, it also takes the short forms like 'leftouter', 'rightouter', 'bestouter' and 'natural'. |
void |
setInsteadOfNull(java.lang.String insteadOfNull)
sets the values (commalist of the format "name=value") to be used instead of NULL in the columns of a OUTER JOIN where NULL was inserted |
void |
setJoinType(int joinType)
sets the join type |
void |
setUseForeignKeys(boolean useForeignKeys)
whether to use foreign keys or matching column names for discovering table relations |
static java.lang.String |
typeToString(int joinType)
returns a string representation of the join type |
Methods inherited from class proper.database.ExecutorObject |
---|
getExecutor, getLastException, getLastStatement |
Methods inherited from class proper.database.ConnectorObject |
---|
getConnector |
Methods inherited from class proper.core.ProperObject |
---|
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NATURAL_JOIN
public static final int LEFTOUTER_JOIN
public static final int RIGHTOUTER_JOIN
public static final int BESTOUTER_JOIN
public static final java.lang.String JOIN_PREFIX
Constructor Detail |
---|
public Joiner(Connector conn)
Method Detail |
---|
public static java.lang.String typeToString(int joinType)
public static int parseType(java.lang.String type)
typeToString(int)
public void setJoinType(int joinType)
public int getJoinType()
public void setInsteadOfNull(java.lang.String insteadOfNull)
public java.lang.String getInsteadOfNull()
public void setUseForeignKeys(boolean useForeignKeys)
useForeignKeys
- whether to use foreign keys or matching
column namespublic boolean getUseForeignKeys()
public java.util.HashSet ambigiousColumns(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns)
table1
- the first table in the jointable2
- the second table in the joinjoinColumns
- the fields in the select statementColumn
public java.lang.String createJoin(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, int type)
table1
- the first table in the jointable2
- the second table in the joinjoinColumns
- the columns to do the join overtype
- the type of join to performpublic java.lang.String createJoin(java.lang.String table1, java.lang.String prefix1, java.lang.String table2, java.lang.String prefix2, java.util.Vector joinColumns, int type)
table1
- the first table in the joinprefix1
- the prefix for the the first tabletable2
- the second table in the joinprefix2
- the prefix for the the second tablejoinColumns
- the columns to do the join overtype
- the type of join to performpublic java.lang.String createJoin(java.lang.String table1, java.lang.String prefix1, java.util.Vector cols1, java.lang.String table2, java.lang.String prefix2, java.util.Vector cols2, java.util.Vector joinColumns, int type)
table1
- the first table in the joinprefix1
- the prefix for the the first tablecols1
- the columns of the first table to usetable2
- the second table in the joinprefix2
- the prefix for the the second tablecols2
- the columns of the second table to usejoinColumns
- the column pairs to do the join over (Join)type
- the type of join to performpublic java.lang.String getTableCreateFromSelect(java.lang.String table, java.lang.String sql) throws java.lang.Exception
table
- the name of the table to createsql
- the select statement to retrieve the column
definitions from
java.lang.Exception
- throws an exception if something with the
select-statement went wrongpublic boolean join(java.lang.String table1, java.lang.String table2, java.lang.String resultTable)
table1
- the first table in the jointable2
- the second table in the join
public boolean join(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, java.lang.String resultTable)
table1
- the first table in the jointable2
- the second table in the joinjoinColumns
- the column to use in the join
public boolean join(java.lang.String table1, java.lang.String prefix1, java.lang.String table2, java.lang.String prefix2, java.util.Vector joinColumns, java.lang.String resultTable)
table1
- the first table in the joinprefix1
- the prefix for the columns of the first tabletable2
- the second table in the joinprefix2
- the prefix for the columns of the second tablejoinColumns
- the column to use in the join
public boolean join(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, java.lang.String resultTable, java.lang.String classField)
table1
- the first table in the jointable2
- the second table in the joinjoinColumns
- the column to use in the joinclassField
- the column to check not to loose any instances
public boolean join(java.lang.String table1, java.lang.String prefix1, java.lang.String table2, java.lang.String prefix2, java.util.Vector joinColumns, java.lang.String resultTable, java.lang.String classField)
table1
- the first table in the joinprefix1
- the prefix for the columns of the first tabletable2
- the second table in the joinprefix2
- the prefix for the columns of the second tablejoinColumns
- the column to use in the joinclassField
- the column to check not to loose any instances
public boolean join(java.lang.String table1, java.lang.String prefix1, java.util.Vector cols1, java.lang.String table2, java.lang.String prefix2, java.util.Vector cols2, java.util.Vector joinColumns, java.lang.String resultTable, java.lang.String classField)
table1
- the first table in the joinprefix1
- the prefix for the columns of the first tablecols1
- the columns to use from the first tabletable2
- the second table in the joinprefix2
- the prefix for the columns of the second tablecols2
- the columns to use from the second tablejoinColumns
- the column to use in the joinclassField
- the column to check not to loose any instances
public int determineBestJoin(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns)
public int getClassCount(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, java.lang.String classField, int joinType)
public int getRowsWithClassCount(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, java.lang.String classField, int joinType)
public int determineBestJoin(java.lang.String table1, java.lang.String table2, java.util.Vector joinColumns, java.lang.String classField)
public java.util.Vector determineColumns(java.lang.String table1, java.lang.String table2)
table1
- the first table in the jointable2
- the second table in the join
Table
public java.util.Vector determineColumns(java.lang.String table1, boolean onlyIndexes1, java.lang.String table2, boolean onlyIndexes2)
table1
- the first table in the joinonlyIndexes1
- whether to use only the indexes from the 1. tabletable2
- the second table in the joinonlyIndexes2
- whether to use only the indexes from the 2. table
Table
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |