Search in sources :

Example 1 with BinaryOperatorType

use of org.geotoolkit.ogc.xml.v110.BinaryOperatorType in project geotoolkit by Geomatys.

the class OGC100Test method testExpAdd.

// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR EXPRESSION //////////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testExpAdd() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_ADD);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_ADD);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_ADD);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v100.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 2 with BinaryOperatorType

use of org.geotoolkit.ogc.xml.v110.BinaryOperatorType in project geotoolkit by Geomatys.

the class OGC100Test method testExpMul.

@Test
public void testExpMul() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_MUL);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_MUL);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_MUL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v100.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 3 with BinaryOperatorType

use of org.geotoolkit.ogc.xml.v110.BinaryOperatorType in project geotoolkit by Geomatys.

the class OGC100Test method testExpSub.

@Test
public void testExpSub() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_SUB);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    JAXBElement<BinaryOperatorType> pvt = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_SUB);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_SUB);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v100.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 4 with BinaryOperatorType

use of org.geotoolkit.ogc.xml.v110.BinaryOperatorType in project geotoolkit by Geomatys.

the class OGC110Test method testExpDiv.

@Test
public void testExpDiv() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_DIV);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_DIV);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_DIV);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v110.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Example 5 with BinaryOperatorType

use of org.geotoolkit.ogc.xml.v110.BinaryOperatorType in project geotoolkit by Geomatys.

the class OGC110Test method testExpAdd.

// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR EXPRESSION //////////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testExpAdd() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_ADD);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_ADD);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_ADD);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v110.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)8 Marshaller (javax.xml.bind.Marshaller)8 Unmarshaller (javax.xml.bind.Unmarshaller)8 Test (org.junit.Test)8 Expression (org.opengis.filter.Expression)8 Literal (org.opengis.filter.Literal)8 ValueReference (org.opengis.filter.ValueReference)8 BinaryOperatorType (org.geotoolkit.ogc.xml.v100.BinaryOperatorType)4 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)4 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)4 BinaryOperatorType (org.geotoolkit.ogc.xml.v110.BinaryOperatorType)4 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)4 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)4