/** * @param i The number of assets to skip. */ public void skip(long i) { it.skip(i); }
/** * @see javax.jcr.RangeIterator#skip(long) */ public void skip(long l) { nodeIterator.skip(l); }
/** * @see javax.jcr.RangeIterator#skip(long) */ public void skip(long l) { nodeIterator.skip(l); }
@Override public void skip(long skipNum) { iterator.skip(skipNum); }
/** * @param i The number of assets to skip. */ public void skip(long i) { it.skip(i); }
public void skip(int skipNum) { nodeIterator.skip(skipNum); }
public void skip(int skipNum) { nodeIterator.skip(skipNum); }
public void skip(int skipNum) { nodeIterator.skip((long)skipNum); }
public void skip(long l) { this.nodeIterator.skip(l); }
public void skip(long skipNum) { getDelegate().skip(skipNum); }
public static void reorderNode(final Session session, final String nodePath, final int index) throws RepositoryException { final Node node = session.getNode(nodePath); final String srcChildRelPath = node.getName() + "[" + node.getIndex() + "]"; final Node parent = node.getParent(); final NodeIterator nodes = parent.getNodes(); nodes.skip(index); if (nodes.hasNext()) { final Node destChild = nodes.nextNode(); String destChildRelPath = destChild.getName() + "[" + destChild.getIndex() + "]"; if (!srcChildRelPath.equals(destChildRelPath)) { parent.orderBefore(srcChildRelPath, destChildRelPath); } } }
public PagedResult page(long skip, long maxResult) throws RepositoryException { long endPosition = skip + maxResult; final List<Node> res = new ArrayList<Node>(); final NodeIterator nodeIterator = queryResult.getNodes(); final long total = nodeIterator.getSize(); nodeIterator.skip(skip); while (nodeIterator.hasNext()) { final Node node = nodeIterator.nextNode(); res.add(node); if (nodeIterator.getPosition() >= endPosition) { break; } } return new PagedResult(res, total); } }
@Override public List<T> findAll(String rootPath, NodeFilter nodeFilter, long startIndex, long resultSize) { try { NodeIterator nodeIterator = getNode(rootPath).getNodes(); nodeIterator.skip(startIndex); return toList(nodeIterator, nodeFilter, resultSize); } catch (RepositoryException e) { throw new JcrMappingException("Could not find nodes", e); } }
private Node traverse(final Node node) throws RepositoryException { if (node.hasNodes() && random.nextGaussian() < .5) { final NodeIterator nodes = node.getNodes(); final int size = (int)nodes.getSize(); if (size > 0) { int index = random.nextInt(size); if (index > 0) { nodes.skip(index-1); } Node child = nodes.nextNode(); if (child.isNodeType("hippo:handle")) { child = child.getNode(child.getName()); return child; } return traverse(child); } } return node; }
@Override public List<T> getAll(String path, NodeFilter nodeFilter, long startIndex, long resultSize) { try { NodeIterator nodeIterator = getNodes(path); nodeIterator.skip(startIndex); return toList(nodeIterator, nodeFilter, resultSize); } catch (RepositoryException e) { throw new JcrMappingException("Could not get nodes", e); } }
@Override public void run( Session session ) throws RepositoryException { Node parentNode = session.getNode(parentPath); NodeIterator childIter = parentNode.getNodes(); // Get the first iterator that starts at the 'nth' child (each thread starts at a different child) ... long numChildren = childIter.getSize(); long offset = getOffset(numChildren); childIter.skip(offset); // Modify a set of children ... int childrenToUpdate = Math.min(this.childrenToUpdate, (int)numChildren); for (int i = 0; i != childrenToUpdate; ++i) { childIter = validateIterator(childIter, parentNode); Node child = childIter.nextNode(); child.setProperty(propertyName, "change" + propertyValueCounter.getAndIncrement()); } // Save the changes ... session.save(); }
/** * Find JCR nodes that match the xpath supplied, and map to objects. * * @param xpath the XPath for finding the nodes * @param nodeFilter the NodeFilter to apply when updating child nodes and references * @param startIndex the zero based index of the first item to return * @param resultSize the number of items to return * @return a list of all objects found */ protected List<T> findByXPath(String xpath, NodeFilter nodeFilter, long startIndex, long resultSize) { try { QueryManager queryManager = getSession().getWorkspace().getQueryManager(); Query query = queryManager.createQuery(xpath, Query.XPATH); QueryResult result = query.execute(); NodeIterator nodeIterator = result.getNodes(); nodeIterator.skip(startIndex); return toList(nodeIterator, nodeFilter, resultSize); } catch (RepositoryException e) { throw new JcrMappingException("Could not find nodes by XPath", e); } }
/** * Find JCR nodes that match the SQL supplied, and map to objects. * * @param sql the SQL for finding the nodes * @param nodeFilter the NodeFilter to apply when updating child nodes and references * @param startIndex the zero based index of the first item to return * @param resultSize the number of items to return * @return a list of all objects found */ protected List<T> findBySql(String sql, NodeFilter nodeFilter, long startIndex, long resultSize) { try { QueryManager queryManager = getSession().getWorkspace().getQueryManager(); Query query = queryManager.createQuery(sql, Query.JCR_SQL2); QueryResult result = query.execute(); NodeIterator nodeIterator = result.getNodes(); nodeIterator.skip(startIndex); return toList(nodeIterator, nodeFilter, resultSize); } catch (RepositoryException e) { throw new JcrMappingException("Could not find nodes by SQL", e); } }
public void testOffsetAndSkip() throws Exception { query.setOffset(1); QueryResult result = query.execute(); NodeIterator nodes = result.getNodes(); nodes.skip(1); assertTrue(node3.isSame(nodes.nextNode())); }
public void testSkipOrderByProperty() throws RepositoryException { QueryManager qm = superuser.getWorkspace().getQueryManager(); for (int i = 0; i < 10; i++) { String stmt = testPath + "/*[@" + propertyName1 + " < 1000] order by @" + propertyName1; QueryResult result = qm.createQuery(stmt, Query.XPATH).execute(); for (int j = 0; j < INITIAL_NODE_NUM - i; j++) { // skip to each node in the result NodeIterator it = result.getNodes(); it.skip(j); long propValue = it.nextNode().getProperty(propertyName1).getLong(); // expected = number of skipped nodes + number of deleted nodes long expected = j + i; assertEquals("Wrong node after skip()", expected, propValue); } try { NodeIterator it = result.getNodes(); it.skip(it.getSize() + 1); fail("must throw NoSuchElementException"); } catch (NoSuchElementException e) { // correct } // remove node for the next iteration testRootNode.getNode("node" + i).remove(); testRootNode.save(); } }