use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldText.
@Test
public void should_encode_simpleDatarecord_with_fieldText() throws EncodingException {
final String field1Name = "field-1";
final String field1Value = "field-1-value";
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetText(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getText().getValue(), is(field1Value));
}
use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDataRecord_with_field_with_null_element.
@Test
public void should_encode_simpleDataRecord_with_field_with_null_element() throws EncodingException {
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField("field-name", null)));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
final AnyScalarPropertyType field = xbSimpleDataRecord.getFieldArray(0);
assertThat(field.getName(), is("field-name"));
assertThat(field.getQuantity() == null, is(true));
}
use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCount.
@Test
public void should_encode_simpleDatarecord_with_fieldCount() throws EncodingException {
final String name = "field-1";
final int value = 42;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCount().setValue(value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.getName(), is(name));
assertThat(field1.isSetCount(), is(TRUE));
assertThat(field1.getCount().getValue().intValue(), is(value));
}
use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType 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 AbstractEncodingType) {
SweAbstractEncoding absEncoding = parseEncoding((AbstractEncodingType) element);
TextEncodingDocument absEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
absEncoding.setXml(absEncodingDoc.xmlText(getXmlOptions()));
return absEncoding;
} 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);
}
}
use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createSimpleDataRecord.
private SimpleDataRecordType createSimpleDataRecord(SweSimpleDataRecord simpleDataRecord) throws EncodingException {
SimpleDataRecordType xbSimpleDataRecord = SimpleDataRecordType.Factory.newInstance(getXmlOptions());
if (simpleDataRecord.isSetDefinition()) {
xbSimpleDataRecord.setDefinition(simpleDataRecord.getDefinition());
}
if (simpleDataRecord.isSetDescription()) {
StringOrRefType xbSoR = StringOrRefType.Factory.newInstance();
xbSoR.setStringValue(simpleDataRecord.getDefinition());
xbSimpleDataRecord.setDescription(xbSoR);
}
if (simpleDataRecord.isSetFields()) {
AnyScalarPropertyType[] xbFields = new AnyScalarPropertyType[simpleDataRecord.getFields().size()];
int xbFieldIndex = 0;
for (SweField sweField : simpleDataRecord.getFields()) {
AnyScalarPropertyType xbField = createFieldForSimpleDataRecord(sweField);
xbFields[xbFieldIndex] = xbField;
xbFieldIndex++;
}
xbSimpleDataRecord.setFieldArray(xbFields);
}
return xbSimpleDataRecord;
}
Aggregations