You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IndexCursor.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Copyright (c) 2013 James Ahlborn
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.healthmarketscience.jackcess;
  14. import java.io.IOException;
  15. import com.healthmarketscience.jackcess.util.EntryIterableBuilder;
  16. /**
  17. * Cursor backed by an {@link Index} with extended traversal options. Table
  18. * traversal will be in the order defined by the backing index. Lookups which
  19. * utilize the columns of the index will be fast.
  20. *
  21. * @author James Ahlborn
  22. * @usage _general_class_
  23. */
  24. public interface IndexCursor extends Cursor
  25. {
  26. public Index getIndex();
  27. /**
  28. * Finds the first row (as defined by the cursor) where the index entries
  29. * match the given values. If a match is not found (or an exception is
  30. * thrown), the cursor is restored to its previous state.
  31. *
  32. * @param entryValues the column values for the index's columns.
  33. * @return the matching row or {@code null} if a match could not be found.
  34. */
  35. public Row findRowByEntry(Object... entryValues)
  36. throws IOException;
  37. /**
  38. * Moves to the first row (as defined by the cursor) where the index entries
  39. * match the given values. If a match is not found (or an exception is
  40. * thrown), the cursor is restored to its previous state.
  41. * <p>
  42. * Warning, this method <i>always</i> starts searching from the beginning of
  43. * the Table (you cannot use it to find successive matches).
  44. *
  45. * @param entryValues the column values for the index's columns.
  46. * @return {@code true} if a valid row was found with the given values,
  47. * {@code false} if no row was found
  48. */
  49. public boolean findFirstRowByEntry(Object... entryValues)
  50. throws IOException;
  51. /**
  52. * Moves to the first row (as defined by the cursor) where the index entries
  53. * are &gt;= the given values. If a an exception is thrown, the cursor is
  54. * restored to its previous state.
  55. *
  56. * @param entryValues the column values for the index's columns.
  57. */
  58. public void findClosestRowByEntry(Object... entryValues)
  59. throws IOException;
  60. /**
  61. * Returns {@code true} if the current row matches the given index entries.
  62. *
  63. * @param entryValues the column values for the index's columns.
  64. */
  65. public boolean currentRowMatchesEntry(Object... entryValues)
  66. throws IOException;
  67. /**
  68. * Convenience method for constructing a new EntryIterableBuilder for this
  69. * cursor. An EntryIterableBuilder provides a variety of options for more
  70. * flexible iteration based on a specific index entry.
  71. *
  72. * @param entryValues the column values for the index's columns.
  73. */
  74. public EntryIterableBuilder newEntryIterable(Object... entryValues);
  75. }