congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
AttributeExpressionImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
AttributeExpressionImpl
in
org.geotools.filter

Best Java code snippets using org.geotools.filter.AttributeExpressionImpl (Showing top 20 results out of 315)

origin: geotools/geotools

public PropertyName property(String name) {
  return new AttributeExpressionImpl(name);
}
origin: geotools/geotools

  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]));
  }
}
origin: geotools/geotools

+ isEqual
+ "; in:"
+ expAttr.getPropertyName()
+ "; out:"
+ this.attPath);
origin: geotools/geotools

  public PropertyName property(String name) {
    AttributeExpressionImpl att = new AttributeExpressionImpl(name);
    att.setLenient(false);
    return att;
  }
}
origin: geotools/geotools

    new AttributeExpressionImpl(
        "eg:simpleAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(simpleAttribute, ex.evaluate(feature));
    new AttributeExpressionImpl(
        "eg:complexAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(complexAttribute, ex.evaluate(feature));
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
Object o = ex.evaluate(feature);
assertTrue(o instanceof List);
assertEquals(3, ((List) o).size());
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute/eg:singleLeafAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
o = ex.evaluate(feature);
assertTrue(o instanceof List);
assertEquals(3, ((List) o).size());
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute[1]",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
origin: geotools/geotools

/**
 * Gets the value of this property from the passed object.
 *
 * @param obj Object from which we need to extract a property value.
 */
public Object evaluate(Object obj) {
  return evaluate(obj, null);
}
origin: org.geotools/gt2-main

AttributeExpressionImpl expAttr = (AttributeExpressionImpl) obj;
boolean isEqual = (expAttr.getType() == this.expressionType);
if(LOGGER.isLoggable(Level.FINEST))
  LOGGER.finest("expression type match:" + isEqual + "; in:"
  + expAttr.getType() + "; out:" + this.expressionType);
isEqual = (expAttr.attPath != null)
  ? (isEqual && expAttr.attPath.equals(this.attPath))
if(LOGGER.isLoggable(Level.FINEST))
  LOGGER.finest("attribute match:" + isEqual + "; in:"
  + expAttr.getAttributePath() + "; out:" + this.attPath);
isEqual = (expAttr.schema != null)
  ? (isEqual && expAttr.schema.equals(this.schema))
origin: org.geotools/gt-main

/**
 * Constructor with schema and path to the attribute.
 *
 * @param schema The initial (required) sub filter.
 * @param attPath the xpath to the attribute.
 *
 * @throws IllegalFilterException If the attribute path is not in the
 *         schema.
 */
protected AttributeExpressionImpl(SimpleFeatureType schema, String attPath)
  throws IllegalFilterException {
  this.schema = schema;
  this.expressionType = ATTRIBUTE;
  setAttributePath(attPath);
}
origin: org.geotools/gt-app-schema

AttributeExpressionImpl ex = new AttributeExpressionImpl("eg:simpleAttribute", new Hints(
    FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(simpleAttribute, ex.evaluate(feature));
ex = new AttributeExpressionImpl("eg:complexAttribute", new Hints(
    FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(complexAttribute, ex.evaluate(feature));
ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute", new Hints(
    FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
Object o = ex.evaluate(feature);
assertTrue( o instanceof List );        
assertEquals(3,  ((List) o).size());
ex = new AttributeExpressionImpl("eg:complexAttribute/eg:rootAttribute/eg:singleLeafAttribute", new Hints(
    FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
o = ex.evaluate(feature);
assertTrue( o instanceof List );     
assertEquals(3,  ((List) o).size());
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));
origin: org.geotools/gt-app-schema

public PropertyName property(String name) {
  AttributeExpressionImpl att = new AttributeExpressionImpl(name);
  att.setLenient(false);
  return att;
}
origin: org.geotools/gt-main

/**
 * Gets the value of this attribute from the passed feature.
 *
 * @param feature Feature from which to extract attribute value.
 */
public Object evaluate(SimpleFeature feature) {
  //NC - is exact copy of code anyway, don't need to keep changing both
  //this method can probably be removed all together
  return evaluate((Object) feature, null); 
  }
origin: org.geotools/gt-main

AttributeExpressionImpl expAttr = (AttributeExpressionImpl) obj;
boolean isEqual = (expAttr.getType() == this.expressionType);
if(LOGGER.isLoggable(Level.FINEST))
  LOGGER.finest("expression type match:" + isEqual + "; in:"
  + expAttr.getType() + "; out:" + this.expressionType);
isEqual = (expAttr.attPath != null)
  ? (isEqual && expAttr.attPath.equals(this.attPath))
if(LOGGER.isLoggable(Level.FINEST))
  LOGGER.finest("attribute match:" + isEqual + "; in:"
  + expAttr.getAttributePath() + "; out:" + this.attPath);
isEqual = (expAttr.schema != null)
  ? (isEqual && expAttr.schema.equals(this.schema))
origin: org.geotools/gt2-main

/**
 * Constructor with schema and path to the attribute.
 *
 * @param schema The initial (required) sub filter.
 * @param attPath the xpath to the attribute.
 *
 * @throws IllegalFilterException If the attribute path is not in the
 *         schema.
 */
protected AttributeExpressionImpl(FeatureType schema, String attPath)
  throws IllegalFilterException {
  this.schema = schema;
  this.expressionType = ATTRIBUTE;
  setAttributePath(attPath);
}
origin: geotools/geotools

public PropertyName property(Name name) {
  return new AttributeExpressionImpl(name);
}
origin: geotools/geotools

  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]));
  }
}
origin: org.geotools/gt-complex

    new AttributeExpressionImpl(
        "eg:simpleAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(simpleAttribute, ex.evaluate(feature));
    new AttributeExpressionImpl(
        "eg:complexAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
assertEquals(complexAttribute, ex.evaluate(feature));
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
Object o = ex.evaluate(feature);
assertTrue(o instanceof List);
assertEquals(3, ((List) o).size());
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute/eg:singleLeafAttribute",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
o = ex.evaluate(feature);
assertTrue(o instanceof List);
assertEquals(3, ((List) o).size());
    new AttributeExpressionImpl(
        "eg:complexAttribute/eg:rootAttribute[1]",
        new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, NAMESPACES));
origin: geotools/geotools

protected Object getValues(
    boolean isMultiValued, Expression expression, Object sourceFeatureInput) {
  if (isMultiValued
      && sourceFeatureInput instanceof FeatureImpl
      && expression instanceof AttributeExpressionImpl) {
    // RA: Feature Chaining
    // complex features can have multiple nodes of the same attribute.. and if they are used
    // as input to an app-schema data access to be nested inside another feature type of a
    // different XML type, it has to be mapped like this:
    // <AttributeMapping>
    // <targetAttribute>
    // gsml:composition
    // </targetAttribute>
    // <sourceExpression>
    // <inputAttribute>mo:composition</inputAttribute>
    // <linkElement>gsml:CompositionPart</linkElement>
    // <linkField>gml:name</linkField>
    // </sourceExpression>
    // <isMultiple>true</isMultiple>
    // </AttributeMapping>
    // As there can be multiple nodes of mo:composition in this case, we need to retrieve
    // all of them
    AttributeExpressionImpl attribExpression = ((AttributeExpressionImpl) expression);
    String xpath = attribExpression.getPropertyName();
    ComplexAttribute sourceFeature = (ComplexAttribute) sourceFeatureInput;
    StepList xpathSteps = XPath.steps(sourceFeature.getDescriptor(), xpath, namespaces);
    return getProperties(sourceFeature, xpathSteps);
  }
  return expression.evaluate(sourceFeatureInput);
}
origin: org.geotools/gt2-main

/**
 * Gets the value of this property from the passed object.
 *
 * @param obj Object from which we need to extract a property value.
 */
public Object evaluate(Object obj) {
  return evaluate(obj, null);
}
origin: geotools/geotools

public PropertyName property(String name, NamespaceSupport namespaceContext) {
  if (namespaceContext == null) {
    return property(name);
  }
  return new AttributeExpressionImpl(name, namespaceContext);
}
origin: geotools/geotools

public void testTypeMissmatch() throws Exception {
  SimpleFeature[] f = sampleFeatures();
  // the following are intentionaly backwards
  AttributeExpressionImpl e1 = new AttributeExpressionImpl(schema, "value");
  AttributeExpressionImpl e2 = new AttributeExpressionImpl(schema, "name");
  boolean pass = false;
  Object value = null;
  value = e1.evaluate(f[0]);
  if (value instanceof Integer) {
    pass = true;
  }
  assertTrue("String expresion returned an Integer", pass);
  pass = false;
  value = e2.evaluate(f[0]);
  if (value instanceof String) {
    pass = true;
  }
  assertTrue("Integer expresion returned a String", pass);
}
org.geotools.filterAttributeExpressionImpl

Javadoc

Defines a complex filter (could also be called logical filter). This filter holds one or more filters together and relates them logically in an internally defined manner.

Most used methods

  • <init>
    Constructor with full attribute name.
  • evaluate
    Gets the value of this attribute from the passed feature.
  • getPropertyName
    Gets the path to the attribute to be evaluated by this expression. org.opengis.filter.expression.Pro
  • setLenient
    Sets lenient property.
  • getAttributePath
    This method calls #getPropertyName().
  • getType
  • setAttributePath
    Constructor with minimum dataset for a valid expression.
  • setPropertyName
  • equals
    Compares this filter to the specified object. Returns true if the passed in object is the same as th
  • getLastPropertyAccessor
  • getPropertyAccessor
  • hashCode
    Override of hashCode method.
  • getPropertyAccessor,
  • hashCode,
  • setLastPropertyAccessor,
  • tryAccessor

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • compareTo (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now