Cursors { public static Cursor newIntersectionCursor(Cursor a, Cursor b, QueryLimits settings) { return new IntersectionCursor(a, b, settings); } private  Cursors(); static void checkMemoryLimit(long count, QueryLimits settings); static void checkReadLimit(long count, QueryLimits settings); static Cursor newIntersectionCursor(Cursor a, Cursor b, QueryLimits settings); static Cursor newConcatCursor(List<Cursor> cursors, QueryLimits settings); static Cursor newPathCursor(Iterable<String> paths, QueryLimits settings); static Cursor newPathCursorDistinct(Iterable<String> paths, QueryLimits settings); static Cursor newTraversingCursor(Filter filter,
                                             NodeState rootState); static Cursor newAncestorCursor(Cursor c, int level, QueryLimits settings);  }
@Test public void intersectionCursor() { QueryEngineSettings s = new QueryEngineSettings(); Cursor a = new SimpleCursor("1:", "/b", "/c", "/e", "/e", "/c"); Cursor b = new SimpleCursor("2:", "/a", "/c", "/d", "/b", "/c"); Cursor c = Cursors.newIntersectionCursor(a, b, s); assertEquals("1:/b, 1:/c", list(c)); assertFalse(c.hasNext()); }
@Test public void intersectionCursorExceptions() { QueryEngineSettings s = new QueryEngineSettings(); Cursor a = new SimpleCursor("1:", "/x", "/b", "/c", "/e", "/e", "/c"); Cursor b = new SimpleCursor("2:", "/a", "/c", "/d", "/b", "/c"); Cursor c = Cursors.newIntersectionCursor(a, b, s); c.next(); c.next(); try { c.remove(); fail(); } catch (UnsupportedOperationException e) { } try { c.next(); fail(); } catch (IllegalStateException e) { } }