@Nullable private static String getQueryPath(@NotNull String relPath) { if (relPath.indexOf('/') == -1) { // just a single segment -> don't include the path in the query return null; } else { // compute the relative path excluding the trailing property name String[] segments = Text.explode(relPath, '/', false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < segments.length - 1; i++) { if (!PathUtils.denotesCurrent(segments[i])) { if (i > 0) { sb.append('/'); } sb.append(segments[i]); } } return Strings.emptyToNull(sb.toString()); } }
@CheckForNull private static String getQueryPath(@Nonnull String relPath) { if (relPath.indexOf('/') == -1) { // just a single segment -> don't include the path in the query return null; } else { // compute the relative path excluding the trailing property name String[] segments = Text.explode(relPath, '/', false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < segments.length - 1; i++) { if (!PathUtils.denotesCurrent(segments[i])) { if (i > 0) { sb.append('/'); } sb.append(segments[i]); } } return Strings.emptyToNull(sb.toString()); } }
@Nullable private static String getQueryPath(@NotNull String relPath) { if (relPath.indexOf('/') == -1) { // just a single segment -> don't include the path in the query return null; } else { // compute the relative path excluding the trailing property name String[] segments = Text.explode(relPath, '/', false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < segments.length - 1; i++) { if (!PathUtils.denotesCurrent(segments[i])) { if (i > 0) { sb.append('/'); } sb.append(segments[i]); } } return Strings.emptyToNull(sb.toString()); } }
@NotNull private static TreeLocation getLocation(@NotNull Tree tree, @NotNull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }
@NotNull private static TreeLocation getLocation(@NotNull Tree tree, @NotNull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }
@Nonnull private static TreeLocation getLocation(@Nonnull Tree tree, @Nonnull String relativePath) { TreeLocation loc = TreeLocation.create(tree); for (String element : Text.explode(relativePath, '/', false)) { if (PathUtils.denotesParent(element)) { loc = loc.getParent(); } else if (!PathUtils.denotesCurrent(element)) { loc = loc.getChild(element); } // else . -> skip to next element } return loc; }
/** * Return the possibly non existing tree located at the passed {@code path} from * the location of the start {@code tree} or {@code null} if {@code path} results * in a parent of the root. * * @param tree start tree * @param path path from the start tree * @return tree located at {@code path} from {@code start} or {@code null} */ @Nullable public static Tree getTree(@NotNull Tree tree, @NotNull String path) { for (String element : PathUtils.elements(path)) { if (PathUtils.denotesParent(element)) { if (tree.isRoot()) { return null; } else { tree = tree.getParent(); } } else if (!PathUtils.denotesCurrent(element)) { tree = tree.getChild(element); } // else . -> skip to next element } return tree; }
/** * Return the possibly non existing tree located at the passed {@code path} from * the location of the start {@code tree} or {@code null} if {@code path} results * in a parent of the root. * * @param tree start tree * @param path path from the start tree * @return tree located at {@code path} from {@code start} or {@code null} */ @CheckForNull public static Tree getTree(@Nonnull Tree tree, @Nonnull String path) { for (String element : PathUtils.elements(path)) { if (PathUtils.denotesParent(element)) { if (tree.isRoot()) { return null; } else { tree = tree.getParent(); } } else if (!PathUtils.denotesCurrent(element)) { tree = tree.getChild(element); } // else . -> skip to next element } return tree; }
if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { } else if (target.hasChild(segment)) { target = target.getChild(segment); } else if (!PathUtils.denotesCurrent(segment)) { target = TreeUtil.addChild(target, segment, primaryTypeName);
if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { } else if (target.hasChild(segment)) { target = target.getChild(segment); } else if (!PathUtils.denotesCurrent(segment)) { target = TreeUtil.addChild(target, segment, primaryTypeName);
if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { } else if (target.hasChild(segment)) { target = target.getChild(segment); } else if (!PathUtils.denotesCurrent(segment)) { target = TreeUtil.addChild(target, segment, primaryTypeName);
if (PathUtils.denotesCurrent(relativePath)) { return this; } else if (PathUtils.denotesParent(relativePath)) { } else if (target.hasChild(segment)) { target = target.getChild(segment); } else if (!PathUtils.denotesCurrent(segment)) { target = target.addChild(segment, primaryTypeName);