use of org.n52.svalbard.encode.EncodingContext in project arctic-sea by 52North.
the class SensorMLEncoderv20 method encode.
@Override
public XmlObject encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
try {
if (objectToEncode instanceof AbstractSensorML) {
AbstractSensorML description = (AbstractSensorML) objectToEncode;
if (description.isSetXml()) {
encodedObject = XmlObject.Factory.parse(((AbstractSensorML) objectToEncode).getXml());
addValuesToXmlObject(encodedObject, (AbstractSensorML) objectToEncode);
encodedObject = checkForAdditionalValues(encodedObject, additionalValues);
} else {
encodedObject = encodeDescription(description, additionalValues);
}
} else {
throw new UnsupportedEncoderInputException(this, objectToEncode);
}
} catch (XmlException xmle) {
throw new EncodingException(xmle);
}
// check if all gml:id are unique
XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
Aggregations