Search in sources :

Example 1 with EXIObject

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);
    }
}
Also used : EXIObject(org.n52.shetland.exi.EXIObject) EXIObject(org.n52.shetland.exi.EXIObject) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 2 with EXIObject

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);
    }
}
Also used : EXIResult(com.siemens.ct.exi.api.sax.EXIResult) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) EncodingException(org.n52.svalbard.encode.exception.EncodingException) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EXIException(com.siemens.ct.exi.exceptions.EXIException) XMLReader(org.xml.sax.XMLReader) SAXException(org.xml.sax.SAXException)

Aggregations

EXIResult (com.siemens.ct.exi.api.sax.EXIResult)1 EXIException (com.siemens.ct.exi.exceptions.EXIException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 XmlObject (org.apache.xmlbeans.XmlObject)1 EXIObject (org.n52.shetland.exi.EXIObject)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1 XMLReader (org.xml.sax.XMLReader)1