Package org.geotools.filter

Examples of org.geotools.filter.AttributeExpressionImpl


    super(hints);
  }

  @Override
  public AttributeExpression createAttributeExpression(String xpath) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.createAttributeExpression(xpath);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here


    return expression;
  }

  @Override
  public AttributeExpression createAttributeExpression(SimpleFeatureType schema) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.createAttributeExpression(schema);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

    return expression;
  }

  @Override
  public AttributeExpression createAttributeExpression(SimpleFeatureType schema, String path) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.createAttributeExpression(schema, path);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

    return expression;
  }

  @Override
  public AttributeExpression createAttributeExpression(AttributeDescriptor at) throws IllegalFilterException {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.createAttributeExpression(at);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

    return expression;
  }

  @Override
  public PropertyName property(String name) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.property(name);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

    return expression;
  }

  @Override
  public PropertyName property(Name name) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.property(name);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

    return expression;
  }

  @Override
  public PropertyName property(String name, NamespaceSupport namespaceContext) {
    AttributeExpressionImpl expression = (AttributeExpressionImpl) super.property(name, namespaceContext);
    expression.setLenient(false);
    return expression;
  }
View Full Code Here

            validateConfiguredNamespaces(targetXPathSteps);

            final boolean isMultiValued = attDto.isMultiple();
           
            final Expression idExpression = (idXpath == null) ? parseOgcCqlExpression(idExpr)
                    : new AttributeExpressionImpl(idXpath, new Hints(
                            FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, this.namespaces));
            // if the data source is a data access, the input XPath expression is the source
            // expression
            final Expression sourceExpression;

            sourceExpression = (inputXPath == null) ? parseOgcCqlExpression(sourceExpr)
                    : new AttributeExpressionImpl(inputXPath, new Hints(
                            FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, this.namespaces));

            final AttributeType expectedInstanceOf;

            final Map clientProperties = getClientProperties(attDto);
View Full Code Here

            Name typeName = Types.typeName(GSMLNS, "MappedFeatureType");      
            ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName);
            assertNotNull(mf);
            assertTrue(mf instanceof FeatureType);
           
            AttributeExpressionImpl ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:preferredAge/gsml:GeologicEvent/gsml:eventAge/gsml:CGI_TermRange/gsml:upper/gsml:CGI_TermValue/gsml:value",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            Object o = ex.evaluate(mf);
            assertNotNull(o);
            assertTrue(o instanceof PropertyDescriptor);
           
            ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:composition/gsml:CompositionPart/gsml:lithology/@xlink:href",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            o = ex.evaluate(mf);
            assertNotNull(o);
            assertTrue(o.equals (Types.typeName(XLINKNS, "href")));
           
            ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:composition/gsml:CompositionPart/gsml:lithology/@foo:bar",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            o = ex.evaluate(mf);
            assertNull(o);
        }
        finally {       
            typeRegistry.disposeSchemaIndexes();
        }
View Full Code Here

        /**
         * Test evaluating complex feature
         */
        // test evaluating simple property
        AttributeExpressionImpl ex = new AttributeExpressionImpl("eg:simpleAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(simpleAttribute, ex.evaluate(feature));

        // test evaluating complex property
        ex = new AttributeExpressionImpl("eg:complexAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(complexAttribute, ex.evaluate(feature));

        // test multi-valued nested properties
        ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        // no index would return array of all features
        Object o = ex.evaluate(feature);
        assertTrue( o instanceof List );       
        assertEquals(3((List) o).size());
        assertEquals(rootOne,  ((List) o).get(0));
        assertEquals(rootTwo,  ((List) o).get(1));
        assertEquals(rootThree,  ((List) o).get(2));
       
        //test nested on multi-valued attributes
        ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute/eg:singleLeafAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        // no index would return array of all features
        o = ex.evaluate(feature);
        assertTrue( o instanceof List );    
        assertEquals(3((List) o).size());
        assertEquals(singleLeaf,  ((List) o).get(0));
        assertEquals(singleLeaf,  ((List) o).get(1));
        assertEquals(singleLeaf,  ((List) o).get(2));
       
        // index specified
        ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute[1]", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
         assertEquals(rootOne, ex.evaluate(feature));
        ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute[2]", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(rootTwo, ex.evaluate(feature));
      
        // single valued nested property
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute[3]/eg:singleLeafAttribute", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(singleLeaf, ex.evaluate(feature));
       
        // null values
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute[3]/eg:multiLeafAttribute", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(null, ex.evaluate(feature));
       
        // deeper nesting
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute[2]/eg:multiLeafAttribute", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(leafOne, ex.evaluate(feature));
       
        // property index doesn't exist
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute[2]/eg:multiLeafAttribute[2]", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(null, ex.evaluate(feature));
              
        // expect an exception when object supplied is not a complex attribute
        boolean exceptionThrown = false;
        try {
            ex.setLenient(false); //NC -added, only exception if lenient off
            assertEquals(null, ex.evaluate(singleLeaf));
        } catch (Exception e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            fail("Expecting Exception since object passed in is not a complex attribute.");
        }

        // invalid property
        ex = new AttributeExpressionImpl("randomAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(null, ex.evaluate(feature));
        assertEquals(null, ex.evaluate(fType));
               
        // NC - test xml attribute
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute[3]/eg:singleLeafAttribute/@eg:att", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals("test attribute", ex.evaluate(feature));
       
        // NC - test descriptor functionality
       
        ex = new AttributeExpressionImpl("eg:simpleAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));       
        assertEquals( simpleAttributeDesc, ex.evaluate(fType));
       
        ex = new AttributeExpressionImpl("eg:complexAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));       
        assertEquals( complexDesc, ex.evaluate(fType));
       
        // test nested properties
        ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute", new Hints(
                FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals( rootDesc, ex.evaluate(fType));
       
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute/eg:singleLeafAttribute", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(singleLeafDesc, ex.evaluate(fType));
       
        ex = new AttributeExpressionImpl(
                "eg:complexAttribute/eg:rootAttribute/eg:multiLeafAttribute", new Hints(
                        FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
        assertEquals(multiLeafDesc, ex.evaluate(fType));
                      
    }
View Full Code Here

TOP

Related Classes of org.geotools.filter.AttributeExpressionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.