use of org.n52.svalbard.write.InspireXmlStreamWriter in project arctic-sea by 52North.
the class InspireXmlEncoder method encodeObject.
private XmlObject encodeObject(InspireObject objectToEncode, EncodingContext ctx) throws EncodingException {
try {
checkIfSupported(objectToEncode);
ByteArrayOutputStream out = new ByteArrayOutputStream();
EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()).with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions);
new InspireXmlStreamWriter(context, out, objectToEncode).write();
String s = out.toString("UTF8");
return XmlObject.Factory.parse(s);
} catch (XMLStreamException | DateTimeFormatException | XmlException | UnsupportedEncodingException ex) {
throw new EncodingException("Error encoding Inspire extended capabilities!", ex);
}
}
Aggregations