Search in sources :

Example 1 with DefaultPropertyName

use of org.geotoolkit.filter.DefaultPropertyName in project geotoolkit by Geomatys.

the class XmlFeatureTest method testWriteSimpleFeaturePrimitiveWithAtts.

@Test
public void testWriteSimpleFeaturePrimitiveWithAtts() throws JAXBException, IOException, XMLStreamException, DataStoreException, ParserConfigurationException, SAXException {
    final File temp = File.createTempFile("gml", ".xml");
    temp.deleteOnExit();
    final XmlFeatureWriter writer = new JAXPStreamFeatureWriter("3.2.1", "1.1.0", null);
    writer.write(featureEmpty, temp);
    writer.dispose();
    String result = IOUtilities.toString(new FileInputStream(temp));
    String expResult = IOUtilities.toString(XmlFeatureTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/SimpleFeatureEmpty.xml"));
    expResult = expResult.replace("EPSG_VERSION", EPSG_VERSION);
    expResult = expResult.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    result = result.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    final Expression exp = new DefaultPropertyName("/identifier/_value");
    Object v = exp.apply(featureEmpty);
    DomCompare.compare(expResult, result);
}
Also used : Expression(org.opengis.filter.Expression) JAXPStreamFeatureWriter(org.geotoolkit.feature.xml.jaxp.JAXPStreamFeatureWriter) File(java.io.File) DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName) FileInputStream(java.io.FileInputStream)

Example 2 with DefaultPropertyName

use of org.geotoolkit.filter.DefaultPropertyName in project geotoolkit by Geomatys.

the class JavaScriptFunction method prepare.

private static Expression[] prepare(final Expression jsFunction) {
    final String str = jsFunction.apply(null).toString();
    final List<Expression> properties = new ArrayList<Expression>();
    properties.add(jsFunction);
    String current = null;
    for (int i = 0, n = str.length(); i < n; i++) {
        char c = str.charAt(i);
        if (current != null) {
            if (END_CHARACTERS.contains(c)) {
                if (!current.isEmpty()) {
                    properties.add(new DefaultPropertyName(current));
                }
                current = null;
            } else {
                current += c;
            }
        } else {
            if (c == VAR_CHARACTER) {
                current = "";
            }
        }
    }
    if (current != null && !current.isEmpty()) {
        properties.add(new DefaultPropertyName(current));
    }
    return properties.toArray(new Expression[properties.size()]);
}
Also used : Expression(org.opengis.filter.Expression) ArrayList(java.util.ArrayList) DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName)

Example 3 with DefaultPropertyName

use of org.geotoolkit.filter.DefaultPropertyName in project geotoolkit by Geomatys.

the class XPathBindingTest method testStarXPath.

@Test
public void testStarXPath() {
    final String exp = "*[10]";
    final ValueReference pn = new DefaultPropertyName(exp);
    final Object result = pn.apply(FilterTestConstants.FEATURE_1);
    assertEquals("test string data", result);
}
Also used : DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName) ValueReference(org.opengis.filter.ValueReference) Test(org.junit.Test)

Example 4 with DefaultPropertyName

use of org.geotoolkit.filter.DefaultPropertyName in project geotoolkit by Geomatys.

the class XPathBindingTest method testDoubleSlashXPath.

@Test
public void testDoubleSlashXPath() {
    final String exp = "//gml:testString";
    final ValueReference pn = new DefaultPropertyName(exp);
    final Object result = pn.apply(FilterTestConstants.FEATURE_1);
    assertEquals("test string data", result);
}
Also used : DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName) ValueReference(org.opengis.filter.ValueReference) Test(org.junit.Test)

Example 5 with DefaultPropertyName

use of org.geotoolkit.filter.DefaultPropertyName in project geotoolkit by Geomatys.

the class GroovyFunction method prepare.

/**
 * Map groovy parameters to PropertyNames.
 * @param gvFunction
 * @return Expression[]
 */
private static Expression[] prepare(final Expression gvFunction) {
    final String str = gvFunction.apply(null).toString();
    final List<Expression> properties = new ArrayList<Expression>();
    properties.add(gvFunction);
    String current = null;
    for (int i = 0, n = str.length(); i < n; i++) {
        char c = str.charAt(i);
        if (current != null) {
            if (END_CHARACTERS.contains(c)) {
                if (!current.isEmpty()) {
                    properties.add(new DefaultPropertyName(current));
                }
                current = null;
            } else {
                current += c;
            }
        } else {
            if (c == VAR_CHARACTER) {
                current = "";
            }
        }
    }
    if (current != null && !current.isEmpty()) {
        properties.add(new DefaultPropertyName(current));
    }
    return properties.toArray(new Expression[properties.size()]);
}
Also used : Expression(org.opengis.filter.Expression) ArrayList(java.util.ArrayList) DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName)

Aggregations

DefaultPropertyName (org.geotoolkit.filter.DefaultPropertyName)6 Expression (org.opengis.filter.Expression)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)2 ValueReference (org.opengis.filter.ValueReference)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 JAXPStreamFeatureWriter (org.geotoolkit.feature.xml.jaxp.JAXPStreamFeatureWriter)1