protected Filter intersection(Filter a, Filter b) { if (a == null) return b; if (b == null) return a; if (a == Filter.INCLUDE && b == Filter.INCLUDE) { return Filter.INCLUDE; } else if (a == Filter.EXCLUDE || b == Filter.EXCLUDE) { return Filter.EXCLUDE; } else { return factory.and(a, b); } }
private <T> Predicate<T> toPredicate(Filter filter) { if (filter != null && filter != Filter.INCLUDE) { return o -> filter.evaluate(o); } else { return CatalogInfoLookup.TRUE; } }
/** * Returns a predicate that checks a CatalogInfo object's property for inequality with the * provided property value. * * <p>The <tt>property</tt> parameter may be specified as a "path" of the form "prop1.prop2". If * any of the resulting properties along the path result in null this method will return null. * * <p>Indexed access to nested list and array properties is supported through the syntax {@code * "prop1[M].prop2.prop3[N]"}, where {@code prop1} and {@code prop3} are list or array * properties, {@code M} is the index of the {@code prop2} element to retrieve from {@code * prop1}, and {@code N} is the index of array or list property {@code prop3} to retrieve. * Indexed access to {{java.util.Set}} properties is <b>not</b> supported. * * <p>Evaluation of nested properties for <b>any</b> member of a collection property is at the * moment not supported * * <p> * * @param property the qualified property name of the predicate's input object to evaluate * @param expected the value to check the input object's property against * @see PropertyIsEqualTo */ public static Filter notEqual(final String property, final Object expected) { return factory.notEqual(factory.property(property), factory.literal(expected)); } }
/** * Retypes a filter making sure the fids are using the internal typename prefix * * @param filter * @param typeMap */ Filter retypeFilter(Filter filter, FeatureTypeMap typeMap) { FidTransformeVisitor visitor = new FidTransformeVisitor(typeMap); return (Filter) filter.accept(visitor, null); }
/** * Returns a filter that will check if the object passed to it can be accessed by the user * * @param resourceAccesssManager * @param user */ public static Filter buildUserAccessFilter( ResourceAccessManager resourceAccesssManager, Authentication user) { org.opengis.filter.expression.Function visible = new InMemorySecurityFilter(resourceAccesssManager, user); FilterFactory factory = Predicates.factory; // create a filter combined with the security credentials check Filter filter = factory.equals(factory.literal(Boolean.TRUE), visible); return filter; }
/** * Returns a predicate that evaluates to {@code true} if each of its components evaluates to * {@code true}. * * <p>The components are evaluated in order, and evaluation will be "short-circuited" as soon as * a false predicate is found. */ public static Filter and(Filter op1, Filter op2) { List<Filter> children = new ArrayList<Filter>(); if (op1 instanceof And) { children.addAll(((And) op1).getChildren()); } else { children.add(op1); } if (op2 instanceof And) { children.addAll(((And) op2).getChildren()); } else { children.add(op2); } return factory.and(children); }
/** * @return a predicate that evaluates whether the given String {@code property} contains the * required character string, in a <b>case insensitive</b> manner. */ public static Filter contains(final String property, final String subsequence) { PropertyName propertyName = factory.property(property); return contains(propertyName, subsequence); }
/** * Returns a predicate that evaluates to {@code true} if each of its components evaluates to * {@code true}. * * <p>The components are evaluated in order, and evaluation will be "short-circuited" as soon as * a false predicate is found. */ public static Filter and(Filter... operands) { List<Filter> anded = Lists.newArrayList(operands); return factory.and(anded); }
/** * Returns a predicate that evaluates to {@code true} if either of its components evaluates to * {@code true}. * * <p>The components are evaluated in order, and evaluation will be "short-circuited" as soon as * a true predicate is found. */ public static Filter or(Filter op1, Filter op2) { List<Filter> children = new ArrayList<Filter>(); if (op1 instanceof Or) { children.addAll(((Or) op1).getChildren()); } else { children.add(op1); } if (op2 instanceof Or) { children.addAll(((Or) op2).getChildren()); } else { children.add(op2); } return factory.or(children); }
public static Filter or(Filter... operands) { List<Filter> ored = Lists.newArrayList(operands); return factory.or(ored); }
public static SortBy sortBy(final String propertyName, final boolean ascending) { return factory.sort(propertyName, ascending ? SortOrder.ASCENDING : SortOrder.DESCENDING); }
public static Filter contains(final PropertyName propertyName, final String subsequence) { String pattern = "*" + fixSpecials(subsequence) + "*"; String wildcard = "*"; String singleChar = "?"; String escape = "\\"; boolean matchCase = false; return factory.like(propertyName, pattern, wildcard, singleChar, escape, matchCase); }
static Filter unmapIdentifiers(Filter filter, String viewName) { GranuleStoreViewFilterVisitor visitor = new GranuleStoreViewFilterVisitor(viewName); return (Filter) filter.accept(visitor, null); }
public void remove() { if (writeFilter.evaluate(current)) { delegate.remove(); } else { throw unsupportedOperation(); } }
/** * Returns a predicate that evaluates to {@code true} if each of its components evaluates to * {@code true}. * * <p>The components are evaluated in order, and evaluation will be "short-circuited" as soon as * a false predicate is found. */ public static Filter and(List<Filter> operands) { if (operands.size() == 0) { return Filter.INCLUDE; } else if (operands.size() == 1) { return operands.get(0); } else { return factory.and(operands); } }
public static Filter or(List<Filter> operands) { if (operands.size() == 0) { return Filter.EXCLUDE; } else if (operands.size() == 1) { return operands.get(0); } else { return factory.or(operands); } }
/** Parses a token of the form 'Field1 {A|D}' into an instnace of {@link SortBy}. */ protected Object parseToken(String token) throws Exception { String[] nameOrder = token.trim().split(" "); String propertyName = nameOrder[0]; SortOrder order = SortOrder.ASCENDING; if (nameOrder.length > 1) { if ("D".equalsIgnoreCase(nameOrder[1]) || "DESC".equalsIgnoreCase(nameOrder[1])) { order = SortOrder.DESCENDING; } } return filterFactory.sort(propertyName, order); } }