/** * @param featurePath path o a feature node (e.g. {@code 'roads/road1'} * @return {@code true} if {@code featurePath} is a child of, or equals to, one of the path * filters. */ public boolean featureApplies(final String parent, final String node) { List<String> path = toPath(parent, node); boolean applies = pathFilter.applies(path); return applies; } }
/** * Tests whether the given tree path applies to one of the path filters. * <p> * Given a path filer {@code roads/highway}, the following {@code treePaths}: * <ul> * <li>{@code roads]} applies * <li>{@code roads/highway]} applies * <li>{@code roads/secondary} does not apply * <li>{@code roads/highway/principal} applies * <li>{@code buildings[/**]} does not apply * </ul> * * @param treePath * @return {@code true} if {@code treePath} is a parent of, or equals to, one of the path * filters */ public boolean treeApplies(final String treePath) { boolean applies = pathFilter.applies(toPath(treePath, null)); return applies; }
/** * If this method is called then {@link #treeApplies(String)} returned {@code true} for the pair * of trees the buckets belong to, meaning that {@code treePath} either matches exactly one of * the filters, or is a filter children. If the former, all tree buckets apply. If the later, * only the ones whose simple name * <ul> * <li>a filter refers to exactly the same tree than {@code treePath}, in which case all buckets * apply * <li>a filter is a child of {@code treePath}, in which case the bucket applies * </ul> * * @param treePath the path of the tree the bucket belong to * @param bucketIndex * @return */ public boolean bucketApplies(final String treePath, final BucketIndex bucketIndex) { // if we got here, then tree applies final PathFilter treeFilter = this.pathFilter.find(toPath(treePath, null)); if (treeFilter.children == null) { return true; } Map<String, PathFilter> childFilters = treeFilter.children; for (PathFilter childFilter : childFilters.values()) { if (childFilter.bucketApplies(bucketIndex)) { return true; } } return false; }