Search in sources :

Example 1 with TextEncodingType

use of net.opengis.swe.x20.TextEncodingType in project arctic-sea by 52North.

the class SweCommonDecoderV20 method decode.

@Override
public Object decode(Object element) throws DecodingException {
    if (element instanceof DataArrayPropertyType) {
        final DataArrayPropertyType dataArrayPropertyType = (DataArrayPropertyType) element;
        return parseAbstractDataComponent(dataArrayPropertyType.getDataArray1());
    } else if (element instanceof DataRecordPropertyType) {
        final DataRecordPropertyType dataRecordPropertyType = (DataRecordPropertyType) element;
        return parseAbstractDataComponent(dataRecordPropertyType.getDataRecord());
    } else if (element instanceof AbstractDataComponentDocument) {
        return parseAbstractDataComponentDocument((AbstractDataComponentDocument) element);
    } else if (element instanceof AbstractDataComponentType) {
        return parseAbstractDataComponent((AbstractDataComponentType) element);
    } else if (element instanceof Coordinate[]) {
        return parseCoordinates((Coordinate[]) element);
    } else if (element instanceof AnyScalarPropertyType[]) {
        return parseAnyScalarPropertyTypeArray((AnyScalarPropertyType[]) element);
    } else if (element instanceof TextEncodingDocument) {
        final TextEncodingDocument textEncodingDoc = (TextEncodingDocument) element;
        final SweTextEncoding sosTextEncoding = parseTextEncoding(textEncodingDoc.getTextEncoding());
        sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
        return sosTextEncoding;
    } else if (element instanceof TextEncodingType) {
        TextEncodingDocument textEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
        TextEncodingType textEncoding = (TextEncodingType) element;
        textEncodingDoc.setTextEncoding(textEncoding);
        SweTextEncoding sosTextEncoding = parseTextEncoding(textEncoding);
        sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
        return sosTextEncoding;
    } else if (element instanceof TextPropertyType) {
        return parseAbstractDataComponent(((TextPropertyType) element).getText());
    } else if (element instanceof CountPropertyType) {
        return parseAbstractDataComponent(((CountPropertyType) element).getCount());
    } else if (element instanceof BooleanPropertyType) {
        return parseAbstractDataComponent(((BooleanPropertyType) element).getBoolean());
    } else if (element instanceof CategoryPropertyType) {
        return parseAbstractDataComponent(((CategoryPropertyType) element).getCategory());
    } else if (element instanceof QuantityPropertyType) {
        return parseAbstractDataComponent(((QuantityPropertyType) element).getQuantity());
    } else if (element instanceof DataStreamPropertyType) {
        return parseDataStream(((DataStreamPropertyType) element).getDataStream());
    } else if (element instanceof DataStreamType) {
        return parseDataStream((DataStreamType) element);
    } else if (element instanceof DataStreamDocument) {
        return parseDataStream(((DataStreamDocument) element).getDataStream());
    } else if (element instanceof XmlObject) {
        throw new UnsupportedDecoderXmlInputException(this, (XmlObject) element);
    } else {
        throw new UnsupportedDecoderInputException(this, element);
    }
}
Also used : TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) DataStreamDocument(net.opengis.swe.x20.DataStreamDocument) AnyScalarPropertyType(net.opengis.swe.x20.AnyScalarPropertyType) DataRecordPropertyType(net.opengis.swe.x20.DataRecordPropertyType) DataArrayPropertyType(net.opengis.swe.x20.DataArrayPropertyType) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) TextEncodingType(net.opengis.swe.x20.TextEncodingType) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Coordinate(net.opengis.swe.x20.VectorType.Coordinate) CountPropertyType(net.opengis.swe.x20.CountPropertyType) DataStreamType(net.opengis.swe.x20.DataStreamType) DataStreamPropertyType(net.opengis.swe.x20.DataStreamPropertyType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) QuantityPropertyType(net.opengis.swe.x20.QuantityPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) TextPropertyType(net.opengis.swe.x20.TextPropertyType) AbstractDataComponentDocument(net.opengis.swe.x20.AbstractDataComponentDocument) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) CategoryPropertyType(net.opengis.swe.x20.CategoryPropertyType)

Example 2 with TextEncodingType

use of net.opengis.swe.x20.TextEncodingType in project arctic-sea by 52North.

the class InsertResultTemplateRequestEncoderTest method shouldEncodeResultEncoding.

@Test
public void shouldEncodeResultEncoding() throws EncodingException, DecodingException {
    ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
    XmlHelper.validateDocument(template);
    Assert.assertThat(template.getResultEncoding(), Matchers.notNullValue());
    Assert.assertThat(template.getResultEncoding().getAbstractEncoding(), Matchers.notNullValue());
    AbstractEncodingType resultEncoding = template.getResultEncoding().getAbstractEncoding();
    Assert.assertThat(resultEncoding, Matchers.instanceOf(TextEncodingType.class));
    TextEncodingType xbTextEncoding = (TextEncodingType) resultEncoding;
    Assert.assertThat(xbTextEncoding.getBlockSeparator(), Is.is(blockSeparator));
    Assert.assertThat(xbTextEncoding.getTokenSeparator(), Is.is(tokenSeparator));
}
Also used : TextEncodingType(net.opengis.swe.x20.TextEncodingType) AbstractEncodingType(net.opengis.swe.x20.AbstractEncodingType) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test)

Example 3 with TextEncodingType

use of net.opengis.swe.x20.TextEncodingType in project arctic-sea by 52North.

the class SweCommonEncoderv20Test method shouldEncodeTextEncoding.

@Test
public void shouldEncodeTextEncoding() throws EncodingException {
    String tokenSeparator = "@";
    String blockSeparator = ";";
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setBlockSeparator(blockSeparator);
    textEncoding.setTokenSeparator(tokenSeparator);
    XmlObject encodedEncoding = sweCommonEncoderv20.encode(textEncoding);
    Assert.assertThat(encodedEncoding, Matchers.instanceOf(TextEncodingType.class));
    TextEncodingType xbTextEncoding = (TextEncodingType) encodedEncoding;
    Assert.assertThat(xbTextEncoding.getBlockSeparator(), Is.is(blockSeparator));
    Assert.assertThat(xbTextEncoding.getTokenSeparator(), Is.is(tokenSeparator));
}
Also used : TextEncodingType(net.opengis.swe.x20.TextEncodingType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Aggregations

TextEncodingType (net.opengis.swe.x20.TextEncodingType)3 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 SweTextEncoding (org.n52.shetland.ogc.swe.encoding.SweTextEncoding)2 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)1 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)1 AbstractDataComponentDocument (net.opengis.swe.x20.AbstractDataComponentDocument)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AbstractEncodingType (net.opengis.swe.x20.AbstractEncodingType)1 AnyScalarPropertyType (net.opengis.swe.x20.AnyScalarPropertyType)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)1 CountPropertyType (net.opengis.swe.x20.CountPropertyType)1 DataArrayPropertyType (net.opengis.swe.x20.DataArrayPropertyType)1 DataRecordPropertyType (net.opengis.swe.x20.DataRecordPropertyType)1 DataStreamDocument (net.opengis.swe.x20.DataStreamDocument)1 DataStreamPropertyType (net.opengis.swe.x20.DataStreamPropertyType)1 DataStreamType (net.opengis.swe.x20.DataStreamType)1 QuantityPropertyType (net.opengis.swe.x20.QuantityPropertyType)1