@Override public Object accept(ExpressionVisitor visitor, Object extraData) { return visitor.visit(this, extraData); }
private void writeProperties(List<PropertyName> attributes, ObjectOutputStream oos) throws IOException { if (attributes == null) { oos.writeInt(-1); } else { oos.writeInt(attributes.size()); for (PropertyName property : attributes) { oos.writeObject(property.getPropertyName()); // TODO: write out the namespace support as well } } }
@Override public <T> T evaluate(Object object, Class<T> context) { // Selection of the first expression Expression clazzExpression = parameters.get(0); // Getting the defined class Class clazz = clazzExpression.evaluate(object, Class.class); // Checking the result boolean result = false; // If the input class is Object, the function always returns true if (clazz != null) { if (clazz == Object.class) { result = true; } else { // Otherwise the function checks if the class is an instance of the // input class result = clazz.isAssignableFrom(object.getClass()); } } // Finally the result is converted to the defined context class return Converters.convert(result, context); }
public Object visit(Function expression, Object data) { if (expression.getParameters() != null) { for (Expression parameter : expression.getParameters()) { data = parameter.accept(this, data); } } return data; }
public Object visit(Add expression, Object data) { data = expression.getExpression1().accept(this, data); data = expression.getExpression2().accept(this, data); return data; }
public Object visit(Subtract expression, Object data) { expression.getExpression1().accept(this, data); if (found) return found; expression.getExpression2().accept(this, data); return found; }
/** * Turns a list of {@link PropertyName} into a list of {@link String} * * @param names */ List<String> flattenNames(List<PropertyName> names) { if (names == null) { return null; } List<String> result = new ArrayList<String>(names.size()); for (PropertyName name : names) { result.add(name.getPropertyName()); } return result; }
/** Visit each parameter and check if they are static */ public Boolean visit(Function expression, Object data) { boolean isStatic = true; if (expression.getParameters() != null) { for (Expression parameter : expression.getParameters()) { isStatic = (Boolean) parameter.accept(this, data); if (isStatic == false) break; } } return isStatic; } /**
/** visit each expression and check that they are static */ public Boolean visit(Add expression, Object data) { boolean isStatic; isStatic = (Boolean) expression.getExpression1().accept(this, data); if (isStatic == false) return false; isStatic = (Boolean) expression.getExpression2().accept(this, data); return isStatic; } /** visit each expression and check that they are static */
@Override public void visit(Mark mark) { final Expression wellKnownName = mark.getWellKnownName(); if (wellKnownName instanceof Literal) { final String name = wellKnownName.evaluate(null, String.class); if (name.startsWith("resource:/")) { try { Resource r = resourceLoader.fromURL(name); if (r != null && r.getType() != Type.UNDEFINED) { resources.add(r); } } catch (IllegalArgumentException e) { GeoServerConfigPersister.LOGGER.log( Level.WARNING, "Error attemping to process SLD resource", e); } } } }
/** * @param input the object to extract the (possibly nested,indexed, or collection) property from * @param propertyName the property to extract from {@code input} * @return the evaluated value of the given property, or {@code null} if a prior nested property * in the path is null; * @throws IllegalArgumentException if no such property exists for the given object */ public Object getProperty(final Object input, final String propertyName) throws IllegalArgumentException { if (input instanceof Info && Predicates.ANY_TEXT.getPropertyName().equals(propertyName)) { return getAnyText((Info) input); } String[] propertyNames = propertyName.split("\\."); return getProperty(input, propertyNames, 0); }
public Object visit(Function expression, Object data) { for (Expression parameter : expression.getParameters()) { data = parameter.accept(this, data); } return found; }
public Object visit(Add expression, Object data) { data = expression.getExpression1().accept(this, data); data = expression.getExpression2().accept(this, data); return data; }
@Override public int compare(Object o1, Object o2) { Object v1 = OwsUtils.get(o1, sortOrder.getPropertyName().getPropertyName()); Object v2 = OwsUtils.get(o2, sortOrder.getPropertyName().getPropertyName()); if (v1 == null) { if (v2 == null) { return 0; } else { return -1; } } else if (v2 == null) { return 1; } Comparable c1 = (Comparable) v1; Comparable c2 = (Comparable) v2; return c1.compareTo(c2); } };
public Object visit(Add expression, Object data) { expression.getExpression1().accept(this, data); if (found) return found; expression.getExpression2().accept(this, data); return found; }
@Override public <T extends CatalogInfo> CloseableIterator<T> list( final Class<T> of, final Filter filter, @Nullable Integer offset, @Nullable Integer count, @Nullable SortBy... sortOrder) { if (sortOrder != null) { for (SortBy so : sortOrder) { if (sortOrder != null && !canSort(of, so.getPropertyName().getPropertyName())) { throw new IllegalArgumentException( "Can't sort objects of type " + of.getName() + " by " + so.getPropertyName()); } } } Iterable<T> iterable = iterable(of, filter, sortOrder); if (offset != null && offset.intValue() > 0) { iterable = Iterables.skip(iterable, offset.intValue()); } if (count != null && count.intValue() >= 0) { iterable = Iterables.limit(iterable, count.intValue()); } Iterator<T> iterator = iterable.iterator(); return new CloseableIteratorAdapter<T>(iterator); }
SecuredSimpleFeatureCollection( FeatureCollection<SimpleFeatureType, SimpleFeature> delegate, WrapperPolicy policy) { super(delegate, policy); if (policy.getLimits() instanceof VectorAccessLimits) { List<PropertyName> properties = ((VectorAccessLimits) policy.getLimits()).getReadAttributes(); if (properties == null) { this.readSchema = getSchema(); } else { List<String> names = new ArrayList<String>(); for (PropertyName property : properties) { names.add(property.getPropertyName()); } String[] nameArray = (String[]) names.toArray(new String[names.size()]); try { this.readSchema = DataUtilities.createSubType(getSchema(), nameArray); } catch (SchemaException e) { // should just not happen throw new RuntimeException(e); } } } else { this.readSchema = getSchema(); } }
@Override public <T extends CatalogInfo> CloseableIterator<T> list( final Class<T> of, final Filter filter, Integer offset, Integer count, SortBy sortOrder) { CatalogFacade facade = getFacade(); if (sortOrder != null && !facade.canSort(of, sortOrder.getPropertyName().getPropertyName())) { // TODO: use GeoTools' merge-sort code to provide sorting anyways throw new UnsupportedOperationException( "Catalog backend can't sort on property " + sortOrder.getPropertyName() + " in-process sorting is pending implementation"); } return facade.list(of, filter, offset, count, sortOrder); }
private <T extends CatalogInfo> void testOrderBy( Class<T> clazz, Filter filter, Integer offset, Integer limit, SortBy sortOrder, List<T> expected) { CatalogPropertyAccessor pe = new CatalogPropertyAccessor(); List<Object> props = new ArrayList<Object>(); List<Object> actual = new ArrayList<Object>(); String sortProperty = sortOrder.getPropertyName().getPropertyName(); for (T info : expected) { Object pval = pe.getProperty(info, sortProperty); props.add(pval); } CloseableIterator<T> it = catalog.list(clazz, filter, offset, limit, sortOrder); try { while (it.hasNext()) { Object property = pe.getProperty(it.next(), sortProperty); actual.add(property); } } finally { it.close(); } assertEquals(props, actual); }
if (!securityProperties.contains(pn)) { throw new SecurityException( "Attribute " + pn.getPropertyName() + " is not available");