Path path = pathFinder.findPath(null, START_X, START_Y, GOAL_X, GOAL_Y); int length = path.getLength(); System.out.println("Found path of length: " + length + ".");
public Context(Path path) { super(); this.path = path; length = path.getLength(); isMatch = false; pos = 0; }
public Context(Path path) { super(); this.path = path; length = path.getLength(); isMatch = false; pos = 0; }
MatchResult(Path path, int pos, int length) { super(); if (!path.isNormalized()) { throw new IllegalArgumentException("Path not normalized"); } this.path = path; this.matchPos = pos; this.matchLength = length; this.pathLength = path.getLength(); }
MatchResult(Path path, int pos, int length) { super(); if (!path.isNormalized()) { throw new IllegalArgumentException("Path not normalized"); } this.path = path; this.matchPos = pos; this.matchLength = length; this.pathLength = path.getLength(); }
/** * Checks whether this element has the specified path. Introduced to * avoid catching a <code>MalformedPathException</code> for simple * path comparisons. * @param path path to compare to * @return <code>true</code> if this child has the path * <code>path</code>, <code>false</code> otherwise */ public boolean hasPath(Path path) { return hasPath(path.getElements(), path.getLength()); }
/** * Checks whether this element has the specified path. Introduced to * avoid catching a <code>MalformedPathException</code> for simple * path comparisons. * @param path path to compare to * @return <code>true</code> if this child has the path * <code>path</code>, <code>false</code> otherwise */ public boolean hasPath(Path path) { return hasPath(path.getElements(), path.getLength()); }
/** * Checks whether this element has the specified path. Introduced to * avoid catching a <code>MalformedPathException</code> for simple * path comparisons. * @param path path to compare to * @return <code>true</code> if this child has the path * <code>path</code>, <code>false</code> otherwise */ public boolean hasPath(Path path) { return hasPath(path.getElements(), path.getLength()); }
/** * Applies {@link #tmpRelPath} to <code>node</code> and reset the path to * <code>null</code>. * * @param node a relation query node. */ private void applyRelativePath(RelationQueryNode node) { Path relPath = getRelativePath(); if (relPath != null) { for (int i = 0; i < relPath.getLength(); i++) { node.addPathElement(relPath.getElements()[i]); } } }
/** * Applies {@link #tmpRelPath} to <code>node</code> and reset the path to * <code>null</code>. * * @param node a relation query node. */ private void applyRelativePath(RelationQueryNode node) { Path relPath = getRelativePath(); if (relPath != null) { for (int i = 0; i < relPath.getLength(); i++) { node.addPathElement(relPath.getElements()[i]); } } }
/** * @inheritDoc */ @Override public NodeIterator findNodes(Path relPath, String value, int authorizableType, boolean exact, long maxSize) throws RepositoryException { String sr = getSearchRoot(authorizableType); if (getSession().nodeExists(sr)) { try { String path = getNamePathResolver().getJCRPath(relPath); AuthorizableTypePredicate pred = getAuthorizableTypePredicate(authorizableType, relPath.getLength() > 1); Node root = getSession().getNode(sr); Map<String, Node> matchingNodes = new HashMap<String, Node>(); collectNodes(value, path, pred, root.getNodes(), matchingNodes, exact, maxSize); return new NodeIteratorAdapter(matchingNodes.values()); } catch (PathNotFoundException e) { // should not get here log.warn("Error while retrieving node " + sr); } } // else: searchRoot does not exist yet -> omit the search return NodeIteratorAdapter.EMPTY; }
/** * @param relativePath * @return normalized absolute path calculated from the given relative * path and the path of this node. * @throws RepositoryException */ private Path getPath(Path relativePath) throws RepositoryException { // shortcut if (relativePath.getLength() == 1 && relativePath.denotesCurrent()) { return getQPath(); } return session.getPathFactory().create(getQPath(), relativePath, true); }
protected RelativePath(Path parent) { this.parent = parent; if (parent != null) { this.absolute = parent.isAbsolute(); this.identifier = parent.isIdentifierBased(); this.depth = parent.getDepth() + getDepthModifier(); this.length = parent.getLength() + 1; } else { this.absolute = false; this.identifier = false; this.depth = getDepthModifier(); this.length = 1; } }
/** * @param relativePath * @return normalized absolute path calculated from the given relative * path and the path of this node. * @throws RepositoryException */ private Path getPath(Path relativePath) throws RepositoryException { // shortcut if (relativePath.getLength() == 1 && relativePath.denotesCurrent()) { return getQPath(); } return session.getPathFactory().create(getQPath(), relativePath, true); }
/** * * @param relativePath * @return * @throws RepositoryException */ private Path getReorderPath(String relativePath) throws RepositoryException { try { Path p = session.getPathResolver().getQPath(relativePath); if (p.isAbsolute() || p.getLength() != 1 || p.getDepth() != 1) { throw new RepositoryException("Invalid relative path: " + relativePath); } return p; } catch (NameException e) { String msg = "Invalid relative path: " + relativePath; log.debug(msg); throw new RepositoryException(msg, e); } }
protected RelativePath(Path parent) { this.parent = parent; if (parent != null) { this.absolute = parent.isAbsolute(); this.identifier = parent.isIdentifierBased(); this.depth = parent.getDepth() + getDepthModifier(); this.length = parent.getLength() + 1; } else { this.absolute = false; this.identifier = false; this.depth = getDepthModifier(); this.length = 1; } }
@Override public NodeIterator findNodes(Path relPath, String value, int authorizableType, boolean exact, long maxSize) throws RepositoryException { Query query; if (relPath.getLength() == 1) { Set<Name> names = Collections.singleton(relPath.getName()); // search without nt-restriction in order not to limit the query to the // authorizable nodes and filter non-matching results later. query = buildQuery(value, names, null, exact, maxSize, getSearchRoot(authorizableType)); } else { query = buildQuery(value, relPath, exact, maxSize, getSearchRoot(authorizableType)); } return new ResultFilteringNodeIterator(query.execute().getNodes(), getAuthorizableTypePredicate(authorizableType, false)); }
@Override public NodeIterator findNodes(Path relPath, String value, int authorizableType, boolean exact, long maxSize) throws RepositoryException { Query query; if (relPath.getLength() == 1) { Set<Name> names = Collections.singleton(relPath.getName()); // search without nt-restriction in order not to limit the query to the // authorizable nodes and filter non-matching results later. query = buildQuery(value, names, null, exact, maxSize, getSearchRoot(authorizableType)); } else { query = buildQuery(value, relPath, exact, maxSize, getSearchRoot(authorizableType)); } return new ResultFilteringNodeIterator(query.execute().getNodes(), getAuthorizableTypePredicate(authorizableType, false)); }
public final Path resolve(Path relative) { if (relative.isAbsolute()) { return relative; } else if (relative.getLength() > 1) { Path first = relative.getFirstElements(); Path last = relative.getLastElement(); return resolve(first).resolve(last); } else if (relative.denotesCurrent()) { return new CurrentPath(this); } else if (relative.denotesParent()) { return new ParentPath(this); } else if (relative.denotesName()) { return new NamePath(this, relative.getName(), relative.getIndex()); } else { throw new IllegalArgumentException( "Unknown path type: " + relative); } }
public final Path resolve(Path relative) { if (relative.isAbsolute()) { return relative; } else if (relative.getLength() > 1) { Path first = relative.getFirstElements(); Path last = relative.getLastElement(); return resolve(first).resolve(last); } else if (relative.denotesCurrent()) { return new CurrentPath(this); } else if (relative.denotesParent()) { return new ParentPath(this); } else if (relative.denotesName()) { return new NamePath(this, relative.getName(), relative.getIndex()); } else { throw new IllegalArgumentException( "Unknown path type: " + relative); } }