Class Joiner
- java.lang.Object
-
- com.healthmarketscience.jackcess.util.Joiner
-
public class Joiner extends Object
Utility for finding rows based on pre-defined, foreign-key table relationships.- Author:
- James Ahlborn
- Usage:
- General: This class is general use.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Joinercreate(Index fromIndex)Creates a new Joiner based on the given index which backs a foreign-key relationship.static Joinercreate(Table fromTable, Table toTable)Creates a new Joiner based on the foreign-key relationship between the given "from"" table and the given "to"" table.JoinercreateReverse()Creates a new Joiner that is the reverse of this Joiner (the "from" and "to" tables are swapped).booleandeleteRows(Object[] fromRow)Deletes any rows in the "to" table based on the given columns in the "from" table.booleandeleteRows(Map<String,?> fromRow)Deletes any rows in the "to" table based on the given columns in the "from" table.RowfindFirstRow(Map<String,?> fromRow)Returns the first row in the "to" table based on the given columns in the "from" table if any,nullif there is no matching row.RowfindFirstRow(Map<String,?> fromRow, Collection<String> columnNames)Returns selected columns from the first row in the "to" table based on the given columns in the "from" table if any,nullif there is no matching row.EntryIterableBuilderfindRows(Object[] fromRow)Returns an Iterator with the selected columns over all the rows in the "to" table based on the given columns in the "from" table.EntryIterableBuilderfindRows(Map<String,?> fromRow)Returns an Iterator over all the rows in the "to" table based on the given columns in the "from" table.List<? extends Index.Column>getColumns()IndexgetFromIndex()TablegetFromTable()IndexCursorgetToCursor()IndexgetToIndex()TablegetToTable()booleanhasRows(Object[] fromRow)Returnstrueif the "to" table has any rows based on the given columns in the "from" table,falseotherwise.booleanhasRows(Map<String,?> fromRow)Returnstrueif the "to" table has any rows based on the given columns in the "from" table,falseotherwise.StringtoFKString()Returns a pretty string describing the foreign key relationship backing this Joiner.
-
-
-
Method Detail
-
create
public static Joiner create(Table fromTable, Table toTable) throws IOException
Creates a new Joiner based on the foreign-key relationship between the given "from"" table and the given "to"" table.- Parameters:
fromTable- the "from" side of the relationshiptoTable- the "to" side of the relationship- Throws:
IllegalArgumentException- if there is no relationship between the given tablesIOException
-
create
public static Joiner create(Index fromIndex) throws IOException
Creates a new Joiner based on the given index which backs a foreign-key relationship. The table of the given index will be the "from" table and the table on the other end of the relationship will be the "to" table.- Parameters:
fromIndex- the index backing one side of a foreign-key relationship- Throws:
IOException
-
createReverse
public Joiner createReverse() throws IOException
Creates a new Joiner that is the reverse of this Joiner (the "from" and "to" tables are swapped).- Throws:
IOException
-
getFromTable
public Table getFromTable()
-
getFromIndex
public Index getFromIndex()
-
getToTable
public Table getToTable()
-
getToIndex
public Index getToIndex()
-
getToCursor
public IndexCursor getToCursor()
-
getColumns
public List<? extends Index.Column> getColumns()
-
hasRows
public boolean hasRows(Map<String,?> fromRow) throws IOException
Returnstrueif the "to" table has any rows based on the given columns in the "from" table,falseotherwise.- Throws:
IOException
-
hasRows
public boolean hasRows(Object[] fromRow) throws IOException
Returnstrueif the "to" table has any rows based on the given columns in the "from" table,falseotherwise.- Throws:
IOException- Usage:
- Intermediate: This method requires moderate API knowledge.
-
findFirstRow
public Row findFirstRow(Map<String,?> fromRow) throws IOException
Returns the first row in the "to" table based on the given columns in the "from" table if any,nullif there is no matching row.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)- Throws:
IOException
-
findFirstRow
public Row findFirstRow(Map<String,?> fromRow, Collection<String> columnNames) throws IOException
Returns selected columns from the first row in the "to" table based on the given columns in the "from" table if any,nullif there is no matching row.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)columnNames- desired columns in the from table row- Throws:
IOException
-
findRows
public EntryIterableBuilder findRows(Map<String,?> fromRow)
Returns an Iterator over all the rows in the "to" table based on the given columns in the "from" table.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)
-
findRows
public EntryIterableBuilder findRows(Object[] fromRow)
Returns an Iterator with the selected columns over all the rows in the "to" table based on the given columns in the "from" table.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)
-
deleteRows
public boolean deleteRows(Map<String,?> fromRow)
Deletes any rows in the "to" table based on the given columns in the "from" table.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)- Returns:
trueif any "to" rows were deleted,falseotherwise
-
deleteRows
public boolean deleteRows(Object[] fromRow)
Deletes any rows in the "to" table based on the given columns in the "from" table.- Parameters:
fromRow- row from the "from" table (which must include the relevant columns for this join relationship)- Returns:
trueif any "to" rows were deleted,falseotherwise- Usage:
- Intermediate: This method requires moderate API knowledge.
-
toFKString
public String toFKString()
Returns a pretty string describing the foreign key relationship backing this Joiner.
-
-