use of net.opengis.swe.x20.CategoryDocument in project arctic-sea by 52North.
the class SweCommonEncoderv20 method asDocument.
private XmlObject asDocument(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
if (type instanceof BooleanType) {
BooleanDocument document = BooleanDocument.Factory.newInstance();
document.setBoolean((BooleanType) type);
return document;
} else if (type instanceof CountType) {
CountDocument document = CountDocument.Factory.newInstance();
document.setCount((CountType) type);
return document;
} else if (type instanceof CountRangeType) {
CountRangeDocument document = CountRangeDocument.Factory.newInstance();
document.setCountRange((CountRangeType) type);
return document;
} else if (type instanceof QuantityType) {
QuantityDocument document = QuantityDocument.Factory.newInstance();
document.setQuantity((QuantityType) type);
return document;
} else if (type instanceof QuantityRangeType) {
QuantityRangeDocument document = QuantityRangeDocument.Factory.newInstance();
document.setQuantityRange((QuantityRangeType) type);
return document;
} else if (type instanceof TimeType) {
TimeDocument document = TimeDocument.Factory.newInstance();
document.setTime((TimeType) type);
return document;
} else if (type instanceof TimeRangeType) {
TimeRangeDocument document = TimeRangeDocument.Factory.newInstance();
document.setTimeRange((TimeRangeType) type);
return document;
} else if (type instanceof CategoryType) {
CategoryDocument document = CategoryDocument.Factory.newInstance();
document.setCategory((CategoryType) type);
return document;
} else if (type instanceof CategoryRangeType) {
CategoryRangeDocument document = CategoryRangeDocument.Factory.newInstance();
document.setCategoryRange((CategoryRangeType) type);
return document;
} else if (type instanceof MatrixType) {
MatrixDocument document = MatrixDocument.Factory.newInstance();
document.setMatrix((MatrixType) type);
return document;
} else if (type instanceof DataArrayType) {
DataArrayDocument document = DataArrayDocument.Factory.newInstance();
document.setDataArray1((DataArrayType) type);
return document;
} else if (type instanceof DataChoiceType) {
DataChoiceDocument document = DataChoiceDocument.Factory.newInstance();
document.setDataChoice((DataChoiceType) type);
return document;
} else if (type instanceof DataRecordType) {
DataRecordDocument document = DataRecordDocument.Factory.newInstance();
document.setDataRecord((DataRecordType) type);
return document;
} else if (type instanceof TextType) {
TextDocument document = TextDocument.Factory.newInstance();
document.setText((TextType) type);
return document;
} else if (type instanceof VectorType) {
VectorDocument document = VectorDocument.Factory.newInstance();
document.setVector((VectorType) type);
return document;
} else {
throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
}
}
use of net.opengis.swe.x20.CategoryDocument in project arctic-sea by 52North.
the class SweCommonDecoderV101Test method should_decode_Category_with_Quality_QuantityRange.
@Test
public void should_decode_Category_with_Quality_QuantityRange() throws DecodingException {
final CategoryDocument xbQuantity = CategoryDocument.Factory.newInstance();
final BigDecimal rangeStart = BigDecimal.valueOf(1.0);
final BigDecimal rangeEnd = BigDecimal.valueOf(2.0);
final ArrayList<BigDecimal> categoryValue = Lists.newArrayList(rangeStart, rangeEnd);
xbQuantity.addNewCategory().addNewQuality().addNewQuantityRange().setValue(categoryValue);
final Object decodedObject = new SweCommonDecoderV101().decode(xbQuantity);
assertThat(decodedObject, is(instanceOf(SweCategory.class)));
final SweCategory sweCategory = (SweCategory) decodedObject;
assertThat(sweCategory.isSetQuality(), is(true));
assertThat(sweCategory.getQuality().size(), is(1));
assertThat(sweCategory.getQuality().iterator().next(), is(instanceOf(SweQuantityRange.class)));
assertThat(((SweQuantityRange) sweCategory.getQuality().iterator().next()).getValue(), is(new RangeValue<BigDecimal>(rangeStart, rangeEnd)));
}
Aggregations