use of org.n52.shetland.exi.EXIObject in project arctic-sea by 52North.
the class ExiEncoder method encode.
@Override
public EXIObject<XmlObject> encode(T response) throws EncodingException {
Encoder<Object, T> encoder = getEncoder(response);
Object encode = encoder.encode(response);
if (encode != null && encode instanceof XmlObject) {
return new EXIObject<XmlObject>((XmlObject) encode);
} else {
throw new UnsupportedEncoderInputException(encoder, response);
}
}
use of org.n52.shetland.exi.EXIObject in project arctic-sea by 52North.
the class EXIResponseWriter method write.
@Override
public void write(EXIObject<XmlObject> exiObject, OutputStream out, ResponseProxy responseProxy) throws IOException, EncodingException {
byte[] bytes = getBytes(exiObject);
try (InputStream is = new ByteArrayInputStream(bytes)) {
EXIResult result = new EXIResult(this.exiFactory.get());
result.setOutputStream(out);
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(result.getHandler());
xmlReader.parse(new InputSource(is));
} catch (EXIException | SAXException e) {
throw new EncodingException(e);
}
}
Aggregations