public PropertyName property(String name) { return new AttributeExpressionImpl(name); }
public PropertyName property(Name name) { return new AttributeExpressionImpl(name); }
public PropertyName property(String name) { AttributeExpressionImpl att = new AttributeExpressionImpl(name); att.setLenient(false); return att; } }
public PropertyName property(String name, NamespaceSupport namespaceContext) { if (namespaceContext == null) { return property(name); } return new AttributeExpressionImpl(name, namespaceContext); }
public void setPropertyName(String propertyName) { setExpression1(new AttributeExpressionImpl(propertyName)); }
public static PropertyName unrollIndex(PropertyName expression, FeatureTypeMapping mapping) { String targetXPath = expression.getPropertyName(); AttributeMapping attMp = getIndexedAttribute(mapping, targetXPath); if (attMp != null) { return new AttributeExpressionImpl(attMp.getIndexField()); } return new AttributeExpressionImpl((String) null); }
public Object evaluate(Object object) { String path = (String) this.params.get(0).evaluate(object); if (object == null) { return new AttributeExpressionImpl(new NameImpl(path)); } return MongoComplexUtilities.getValues(object, path); }
public void testExpressionAttribute() throws IllegalFilterException, SchemaException { SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.add("testBoolean", Boolean.class); ftb.add("testString", String.class); ftb.setName("test2"); SimpleFeatureType testSchema2 = ftb.buildFeatureType(); // FeatureType testSchema2 = feaTypeFactory.getFeatureType(); testExp1 = new AttributeExpressionImpl(testSchema, "testBoolean"); testExp2 = new AttributeExpressionImpl(testSchema, "testBoolean"); assertTrue(testExp1.equals(testExp2)); testExp3 = new AttributeExpressionImpl(testSchema, "testString"); assertTrue(!testExp1.equals(testExp3)); testExp4 = new AttributeExpressionImpl(testSchema2, "testBoolean"); assertTrue(!testExp1.equals(testExp4)); testExp1 = new AttributeExpressionImpl(testSchema2, "testBoolean"); assertTrue(testExp1.equals(testExp4)); }
/** * Tests the attribute expression. * * @throws IllegalFilterException if filters mess up. */ public void testAttribute() throws IllegalFilterException { // Test integer attribute Expression testAttribute = new AttributeExpressionImpl(testSchema, "testInteger"); LOGGER.fine("integer attribute expression equals: " + testAttribute.evaluate(testFeature)); assertEquals(Integer.valueOf(1002), testAttribute.evaluate(testFeature)); // Test string attribute testAttribute = new AttributeExpressionImpl(testSchema, "testString"); LOGGER.fine("string attribute expression equals: " + testAttribute.evaluate(testFeature)); assertEquals("test string data", testAttribute.evaluate(testFeature)); }
/** * Tests the attribute expression over an object other than Feature. * * @throws IllegalFilterException if filters mess up. */ public void testAttributeObject() throws IllegalFilterException { MockDataObject testFeature = new MockDataObject(10, "diez"); // Test integer attribute org.opengis.filter.expression.Expression testAttribute = new AttributeExpressionImpl("intVal"); assertEquals(Integer.valueOf(10), testAttribute.evaluate(testFeature)); // Test string attribute testAttribute = new AttributeExpressionImpl("stringVal"); assertEquals("diez", testAttribute.evaluate(testFeature)); }
/** * Tests the max function expression. * * @throws IllegalFilterException if filter problems */ public void testMaxFunction() throws IllegalFilterException { org.opengis.filter.expression.Expression a, b; a = new AttributeExpressionImpl(testSchema, "testInteger"); b = new LiteralExpressionImpl(new Double(1004)); Function max = ff.function("max", a, b); assertEquals(1004d, ((Double) max.evaluate(testFeature)).doubleValue(), 0); b = new LiteralExpressionImpl(new Double(-100.001)); max = ff.function("max", a, b); assertEquals(1002d, ((Double) max.evaluate(testFeature)).doubleValue(), 0); }
public void testCompareFilter() throws IllegalFilterException { testExp1 = new LiteralExpressionImpl(Integer.valueOf(45)); testExp2 = new LiteralExpressionImpl(Integer.valueOf(45)); testExp3 = new AttributeExpressionImpl(testSchema, "testInteger"); testExp4 = new AttributeExpressionImpl(testSchema, "testInteger"); PropertyIsEqualTo cFilter1 = ff.equals(testExp1, testExp3); PropertyIsEqualTo cFilter2 = ff.equals(testExp1, testExp3); assertTrue(cFilter1.equals(cFilter2)); cFilter2 = ff.equals(testExp2, testExp4); assertTrue(cFilter1.equals(cFilter2)); // see if converters make this work cFilter2 = ff.equals(ff.literal(new Double(45.0)), testExp3); assertTrue(cFilter1.equals(cFilter2)); tFilter1 = ff.between(testExp1, testExp2, testExp3); assertTrue(!cFilter1.equals(tFilter1)); }
/** * Tests the min function expression. * * @throws IllegalFilterException if filter problems */ public void testMinFunctionOld() throws IllegalFilterException { org.opengis.filter.expression.Expression a, b; a = new AttributeExpressionImpl(testSchema, "testInteger"); b = new LiteralExpressionImpl(new Double(1004)); Function min = ff.function("min", a, b); Object value = min.evaluate(testFeature); assertEquals(1002d, ((Double) value).doubleValue(), 0); b = ff.literal(new Double(-100.001)); min = ff.function("min", a, b); value = min.evaluate(testFeature); assertEquals(-100.001, ((Double) value).doubleValue(), 0); }
public void testSetupAndExtraction() throws Exception { // this should move out to a more configurable system run from scripts // but we can start with a set of hard coded tests SimpleFeature[] f = sampleFeatures(); AttributeExpressionImpl e1 = new AttributeExpressionImpl(schema, "value"); AttributeExpressionImpl e2 = new AttributeExpressionImpl(schema, "name"); assertEquals(12d, ((Integer) e1.evaluate(f[0])).doubleValue(), 0); assertEquals(3d, ((Integer) e1.evaluate(f[1])).doubleValue(), 0); assertEquals(15d, ((Integer) e1.evaluate(f[2])).doubleValue(), 0); assertEquals("first", (String) e2.evaluate(f[0])); assertEquals("second", (String) e2.evaluate(f[1])); } }
public void testSetupAndExtraction() throws Exception { // this should move out to a more configurable system run from scripts // but we can start with a set of hard coded tests SimpleFeature[] f = sampleFeatures(); AttributeExpressionImpl e1 = new AttributeExpressionImpl(schema, "value"); AttributeExpressionImpl e2 = new AttributeExpressionImpl(schema, "name"); assertEquals(12d, ((Integer) e1.evaluate(f[0])).doubleValue(), 0); assertEquals(3d, ((Integer) e1.evaluate(f[1])).doubleValue(), 0); assertEquals(15d, ((Integer) e1.evaluate(f[2])).doubleValue(), 0); assertEquals("first", (String) e2.evaluate(f[0])); assertEquals("second", (String) e2.evaluate(f[1])); } }
public void testSimpleFeature() { SimpleFeature f = featureCollection.features().next(); AttributeExpressionImpl foo = new AttributeExpressionImpl("foo"); assertEquals(1, ff.function("attributeCount", foo).evaluate(f)); AttributeExpressionImpl att1 = new AttributeExpressionImpl("att1"); assertEquals(0, ff.function("attributeCount", att1).evaluate(f)); } }
public void testNullFilter() throws IllegalFilterException { testExp1 = new AttributeExpressionImpl(testSchema, "testDouble"); testExp2 = new AttributeExpressionImpl(testSchema, "testDouble"); testExp3 = new AttributeExpressionImpl(testSchema, "testBoolean"); NullFilterImpl nullFilter1 = new NullFilterImpl(); NullFilterImpl nullFilter2 = new NullFilterImpl(); nullFilter1.setExpression(testExp1); nullFilter2.setExpression(testExp2); assertTrue(nullFilter1.equals(nullFilter2)); nullFilter1.setExpression(testExp3); assertTrue(!nullFilter1.equals(nullFilter2)); assertTrue(!nullFilter1.equals(new BetweenFilterImpl())); }
public void testFeature() { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("test"); typeBuilder.setNamespaceURI("http://www.geotools.org/test"); typeBuilder.add("foo", Integer.class); typeBuilder.add("bar", Double.class); SimpleFeatureType type = typeBuilder.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); builder.add(Integer.valueOf(1)); builder.add(new Double(2.0)); SimpleFeature feature = builder.buildFeature("fid"); AttributeExpressionImpl ex = new AttributeExpressionImpl("foo"); assertEquals(Integer.valueOf(1), ex.evaluate(feature)); ex = new AttributeExpressionImpl("@id"); assertEquals("fid", ex.evaluate(feature)); } }
/** * Test the null operator. * * @throws IllegalFilterException If the constructed filter is not valid. */ public void testNull() throws IllegalFilterException { // Test for false positive. PropertyName testAttribute = new AttributeExpressionImpl(testSchema, "testString"); PropertyIsNull filter = fac.isNull(org.opengis.filter.expression.Expression.NIL); assertTrue(filter.evaluate(testFeature)); filter = fac.isNull(testAttribute); assertFalse(filter.evaluate(testFeature)); }
public void testBetweenStrings() throws IllegalFilterException { // Set up the integer Literal testLiteralLower = new LiteralExpressionImpl("blorg"); PropertyName testAttribute = new AttributeExpressionImpl(testSchema, "testString"); Literal testLiteralUpper = new LiteralExpressionImpl("tron"); // String tests PropertyIsBetween filter = fac.between(testAttribute, testLiteralLower, testLiteralUpper); assertTrue(filter.evaluate(testFeature)); // Test for false positive. testLiteralLower = new LiteralExpressionImpl("zebra"); testLiteralUpper = new LiteralExpressionImpl("zikes"); filter = fac.between(testAttribute, testLiteralLower, testLiteralUpper); assertFalse(filter.evaluate(testFeature)); }