Преглед на файлове

convenience method for using case insensitive matcher

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/a97_indexes@1305 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/jackcess-3.5.0
James Ahlborn преди 4 години
родител
ревизия
ff9e16462e
променени са 1 файла, в които са добавени 30 реда и са изтрити 22 реда
  1. 30
    22
      src/main/java/com/healthmarketscience/jackcess/CursorBuilder.java

+ 30
- 22
src/main/java/com/healthmarketscience/jackcess/CursorBuilder.java Целия файл

import com.healthmarketscience.jackcess.impl.IndexData; import com.healthmarketscience.jackcess.impl.IndexData;
import com.healthmarketscience.jackcess.impl.IndexImpl; import com.healthmarketscience.jackcess.impl.IndexImpl;
import com.healthmarketscience.jackcess.impl.TableImpl; import com.healthmarketscience.jackcess.impl.TableImpl;
import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
import com.healthmarketscience.jackcess.util.ColumnMatcher; import com.healthmarketscience.jackcess.util.ColumnMatcher;




_beforeFirst = true; _beforeFirst = true;
return this; return this;
} }
/** /**
* Sets the cursor so that it will start at the end (unless a savepoint is * Sets the cursor so that it will start at the end (unless a savepoint is
* given). * given).
setEndRow(specificRow); setEndRow(specificRow);
return this; return this;
} }
/** /**
* Sets the starting and ending row for a range based index cursor to the * Sets the starting and ending row for a range based index cursor to the
* given entry (where the given values correspond to the index's columns). * given entry (where the given values correspond to the index's columns).
return this; return this;
} }


/** /**
* Sets the starting row for a range based index cursor. * Sets the starting row for a range based index cursor.
* <p> * <p>
_startRow = startRow; _startRow = startRow;
return this; return this;
} }
/** /**
* Sets the starting row for a range based index cursor to the given entry * Sets the starting row for a range based index cursor to the given entry
* (where the given values correspond to the index's columns). * (where the given values correspond to the index's columns).
_endRow = endRow; _endRow = endRow;
return this; return this;
} }
/** /**
* Sets the ending row for a range based index cursor to the given entry * Sets the ending row for a range based index cursor to the given entry
* (where the given values correspond to the index's columns). * (where the given values correspond to the index's columns).
return this; return this;
} }


/**
* Sets the ColumnMatcher to an instance of CaseInsensitiveColumnMatcher
*/
public CursorBuilder setCaseInsensitive() {
return setColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE);
}

/** /**
* Returns a new cursor for the table, constructed to the given * Returns a new cursor for the table, constructed to the given
* specifications. * specifications.
} }
return cursor; return cursor;
} }
/** /**
* Returns a new index cursor for the table, constructed to the given * Returns a new index cursor for the table, constructed to the given
* specifications. * specifications.
* Note, index based table traversal may not include all rows, as certain * Note, index based table traversal may not include all rows, as certain
* types of indexes do not include all entries (namely, some indexes ignore * types of indexes do not include all entries (namely, some indexes ignore
* null entries, see {@link Index#shouldIgnoreNulls}). * null entries, see {@link Index#shouldIgnoreNulls}).
*
*
* @param index index for the table which will define traversal order as * @param index index for the table which will define traversal order as
* well as enhance certain lookups * well as enhance certain lookups
*/ */
{ {
return createCursor(table.getPrimaryKeyIndex()); return createCursor(table.getPrimaryKeyIndex());
} }
/** /**
* Creates an indexed cursor for the given table, narrowed to the given * Creates an indexed cursor for the given table, narrowed to the given
* range. * range.
* Note, index based table traversal may not include all rows, as certain * Note, index based table traversal may not include all rows, as certain
* types of indexes do not include all entries (namely, some indexes ignore * types of indexes do not include all entries (namely, some indexes ignore
* null entries, see {@link Index#shouldIgnoreNulls}). * null entries, see {@link Index#shouldIgnoreNulls}).
*
*
* @param index index for the table which will define traversal order as * @param index index for the table which will define traversal order as
* well as enhance certain lookups * well as enhance certain lookups
* @param startRow the first row of data for the cursor (inclusive), or * @param startRow the first row of data for the cursor (inclusive), or
.setEndRow(endRow) .setEndRow(endRow)
.toIndexCursor(); .toIndexCursor();
} }
/** /**
* Creates an indexed cursor for the given table, narrowed to the given * Creates an indexed cursor for the given table, narrowed to the given
* range. * range.
* Note, index based table traversal may not include all rows, as certain * Note, index based table traversal may not include all rows, as certain
* types of indexes do not include all entries (namely, some indexes ignore * types of indexes do not include all entries (namely, some indexes ignore
* null entries, see {@link Index#shouldIgnoreNulls}). * null entries, see {@link Index#shouldIgnoreNulls}).
*
*
* @param index index for the table which will define traversal order as * @param index index for the table which will define traversal order as
* well as enhance certain lookups * well as enhance certain lookups
* @param startRow the first row of data for the cursor, or {@code null} for * @param startRow the first row of data for the cursor, or {@code null} for
* <p> * <p>
* Warning, this method <i>always</i> starts searching from the beginning of * Warning, this method <i>always</i> starts searching from the beginning of
* the Table (you cannot use it to find successive matches). * the Table (you cannot use it to find successive matches).
*
*
* @param table the table to search * @param table the table to search
* @param rowPattern pattern to be used to find the row * @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found. * @return the matching row or {@code null} if a match could not be found.
} }
return null; return null;
} }
/** /**
* Convenience method for finding a specific row (as defined by the cursor) * Convenience method for finding a specific row (as defined by the cursor)
* where the index entries match the given values. See {@link * where the index entries match the given values. See {@link
* IndexCursor#findRowByEntry(Object...)} for details on the entryValues. * IndexCursor#findRowByEntry(Object...)} for details on the entryValues.
*
*
* @param index the index to search * @param index the index to search
* @param entryValues the column values for the index's columns. * @param entryValues the column values for the index's columns.
* @return the matching row or {@code null} if a match could not be found. * @return the matching row or {@code null} if a match could not be found.
{ {
return createCursor(index).findRowByEntry(entryValues); return createCursor(index).findRowByEntry(entryValues);
} }
/** /**
* Convenience method for finding a specific row by the primary key of the * Convenience method for finding a specific row by the primary key of the
* table. See {@link IndexCursor#findRowByEntry(Object...)} for details on * table. See {@link IndexCursor#findRowByEntry(Object...)} for details on
* the entryValues. * the entryValues.
*
*
* @param table the table to search * @param table the table to search
* @param entryValues the column values for the table's primary key columns. * @param entryValues the column values for the table's primary key columns.
* @return the matching row or {@code null} if a match could not be found. * @return the matching row or {@code null} if a match could not be found.
{ {
return findRowByEntry(table.getPrimaryKeyIndex(), entryValues); return findRowByEntry(table.getPrimaryKeyIndex(), entryValues);
} }
/** /**
* Convenience method for finding a specific row in a table which matches a * Convenience method for finding a specific row in a table which matches a
* given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for * given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for
* match or a matching row with {@code null} for the desired value. If * match or a matching row with {@code null} for the desired value. If
* distinguishing this situation is important, you will need to use a Cursor * distinguishing this situation is important, you will need to use a Cursor
* directly instead of this convenience method. * directly instead of this convenience method.
*
*
* @param table the table to search * @param table the table to search
* @param column column whose value should be returned * @param column column whose value should be returned
* @param columnPattern column being matched by the valuePattern * @param columnPattern column being matched by the valuePattern
} }
return null; return null;
} }
/** /**
* Convenience method for finding a specific row in an indexed table which * Convenience method for finding a specific row in an indexed table which
* matches a given row "pattern". See {@link Cursor#findFirstRow(Map)} for * matches a given row "pattern". See {@link Cursor#findFirstRow(Map)} for
* <p> * <p>
* Warning, this method <i>always</i> starts searching from the beginning of * Warning, this method <i>always</i> starts searching from the beginning of
* the Table (you cannot use it to find successive matches). * the Table (you cannot use it to find successive matches).
*
*
* @param index index to assist the search * @param index index to assist the search
* @param rowPattern pattern to be used to find the row * @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found. * @return the matching row or {@code null} if a match could not be found.
} }
return null; return null;
} }
/** /**
* Convenience method for finding a specific row in a table which matches a * Convenience method for finding a specific row in a table which matches a
* given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for * given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for
* match or a matching row with {@code null} for the desired value. If * match or a matching row with {@code null} for the desired value. If
* distinguishing this situation is important, you will need to use a Cursor * distinguishing this situation is important, you will need to use a Cursor
* directly instead of this convenience method. * directly instead of this convenience method.
*
*
* @param index index to assist the search * @param index index to assist the search
* @param column column whose value should be returned * @param column column whose value should be returned
* @param columnPattern column being matched by the valuePattern * @param columnPattern column being matched by the valuePattern

Loading…
Отказ
Запис