Search in sources :

Example 1 with RangeIterator

use of javax.jcr.RangeIterator in project jackrabbit by apache.

the class FilteredRangeIteratorTest method testSkip.

public void testSkip() {
    RangeIterator iterator = new FilteredRangeIterator(LIST.iterator());
    assertEquals(3, iterator.getSize());
    assertEquals(0, iterator.getPosition());
    assertTrue(iterator.hasNext());
    assertEquals("x", iterator.next());
    iterator.skip(1);
    assertEquals(2, iterator.getPosition());
    assertTrue(iterator.hasNext());
    assertEquals("z", iterator.next());
    assertEquals(3, iterator.getPosition());
    assertFalse(iterator.hasNext());
}
Also used : RangeIterator(javax.jcr.RangeIterator)

Example 2 with RangeIterator

use of javax.jcr.RangeIterator in project jackrabbit by apache.

the class FilteredRangeIteratorTest method testMatchNone.

public void testMatchNone() {
    RangeIterator iterator = new FilteredRangeIterator(LIST.iterator(), Predicate.FALSE);
    assertEquals(0, iterator.getSize());
    assertEquals(0, iterator.getPosition());
    assertFalse(iterator.hasNext());
}
Also used : RangeIterator(javax.jcr.RangeIterator)

Example 3 with RangeIterator

use of javax.jcr.RangeIterator in project jackrabbit by apache.

the class LazyItemIteratorTest method testSizeOfEmptyIteratorIsZero.

public void testSizeOfEmptyIteratorIsZero() throws RepositoryException {
    int i = 0;
    String nameHint = "noExisting";
    String name = nameHint;
    while (testRootNode.hasProperty(name)) {
        name = name + i;
        i++;
    }
    // retrieve PropertyIterator for a name that does not exist as Property
    RangeIterator it = testRootNode.getProperties(name);
    assertTrue(it.getSize() == 0);
    name = nameHint;
    while (testRootNode.hasNode(name)) {
        name = name + i;
        i++;
    }
    // retrieve NodeIterator for a name that does not exist as Node
    it = testRootNode.getNodes(name);
    assertTrue(it.getSize() == 0);
}
Also used : RangeIterator(javax.jcr.RangeIterator)

Example 4 with RangeIterator

use of javax.jcr.RangeIterator in project jackrabbit by apache.

the class LazyItemIteratorTest method testSizeGreaterMinusOne.

public void testSizeGreaterMinusOne() throws RepositoryException {
    RangeIterator it = testRootNode.getProperties();
    // a node always has at least a single property
    assertTrue(it.getSize() > 0);
    if (testRootNode.hasNodes()) {
        it = testRootNode.getNodes();
        // a node always has at least a single property
        assertTrue(it.getSize() > 0);
    }
}
Also used : RangeIterator(javax.jcr.RangeIterator)

Example 5 with RangeIterator

use of javax.jcr.RangeIterator in project sling by apache.

the class MockNode method getProperties.

@Override
public PropertyIterator getProperties(final String namePattern) throws RepositoryException {
    final Pattern pattern = Pattern.compile(namePattern);
    RangeIterator items = getMockedSession().listChildren(getPath(), new ItemFilter() {

        @Override
        public boolean accept(final ItemData item) throws RepositoryException {
            return item.isProperty() && pattern.matcher(item.getName()).matches();
        }
    });
    return new PropertyIteratorAdapter(items, items.getSize());
}
Also used : Pattern(java.util.regex.Pattern) RangeIterator(javax.jcr.RangeIterator) PropertyIteratorAdapter(org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter) RepositoryException(javax.jcr.RepositoryException)

Aggregations

RangeIterator (javax.jcr.RangeIterator)9 RepositoryException (javax.jcr.RepositoryException)3 Pattern (java.util.regex.Pattern)2 Node (javax.jcr.Node)1 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)1 Group (org.apache.jackrabbit.api.security.user.Group)1 NodeIteratorAdapter (org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter)1 PropertyIteratorAdapter (org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1