public int size() { if (isRoot()) { return 0; } int size = 0; int pos = 0; while (pos >= 0) { size++; pos = path.indexOf(SEPARATOR, pos + 1); } return size; }
public String rewriteStaticRelativeUrl(String url, String contextPrefix) { if (prefix.isRoot()) { return contextPrefix + url; } else { return contextPrefix + prefix.toRelative(Path.ROOT) + "/" + url; } } }
public Path parent() { if (isRoot()) { return null; } else { return new Path(path + "/.."); } }
if (!isRoot() && path.endsWith("/")) { return false;
/** * {@inheritDoc} */ public Path getUriPathForNode(Path nodePath, Brix brix) { Path uriPath = prefix; if (!nodePath.isRoot()) { // nodePath is not root, we have to append it to prefix uriPath = prefix.append(nodePath.toRelative(Path.ROOT)); } if(nodePath.toString().endsWith(SitePlugin.BRIX_INDEX_PAGE)) { final String orgUrl = nodePath.toString(); String url = orgUrl.substring(0, orgUrl.length() - SitePlugin.BRIX_INDEX_PAGE.length()); uriPath = new Path(url); } return uriPath; }
public Path toRelative(Path ancestor) { if (isRoot()) { throw new IllegalStateException("Cannot make root path relative"); } if (!isDescendantOf(ancestor)) { throw new IllegalArgumentException("Cannot create relative path because this path: " + this + " is not descendant of ancestor argument: " + ancestor); } Path fragment = new Path(path.substring(ancestor.path.length()), false); if (fragment.isAbsolute()) { fragment = fragment.toRelative(new Path("/")); } return fragment; } }
public String toRealWebNodePath(String nodePath) { Path prefix = new Path(getSiteRootPath()); Path path = new Path(nodePath); if (path.isRoot()) { path = new Path("."); } else if (path.isAbsolute()) { path = path.toRelative(new Path("/")); } return prefix.append(path).toString(); }