/** * Construct an object from a byte stream * (similar semantically to previous method, we are deciding * which one to support) */ @Override public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { if (!mimeType.equals("application/fastinfoset")) { throw new IOException("Invalid content type \"" + mimeType + "\" for FastInfosetDCH"); } try { InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream( (Source) obj); int n; byte[] buffer = new byte[4096]; while ((n = is.read(buffer)) != -1) { os.write(buffer, 0, n); } } catch (Exception ex) { throw new IOException( "Error copying FI source to output stream " + ex.getMessage()); } } }
/** * Return the DataFlavors for this <code>DataContentHandler</code> * @return The DataFlavors. */ @Override public DataFlavor[] getTransferDataFlavors() { // throws Exception; DataFlavor flavors[] = new DataFlavor[1]; flavors[0] = new ActivationDataFlavor( FastInfosetReflection.getFastInfosetSource_class(), "application/fastinfoset", "Fast Infoset"); return flavors; }
else if (FastInfosetReflection.isFastInfosetSource(source) && (result instanceof DOMResult)) m_fiDOMDocumentParser = FastInfosetReflection.DOMDocumentParser_new(); FastInfosetReflection.DOMDocumentParser_parse( m_fiDOMDocumentParser, (Document) ((DOMResult) result).getNode(), FastInfosetReflection.FastInfosetSource_getInputStream(source)); && FastInfosetReflection.isFastInfosetResult(result)) m_fiDOMDocumentSerializer = FastInfosetReflection.DOMDocumentSerializer_new(); FastInfosetReflection.DOMDocumentSerializer_setOutputStream( m_fiDOMDocumentSerializer, FastInfosetReflection.FastInfosetResult_getOutputStream(result)); FastInfosetReflection.DOMDocumentSerializer_serialize( m_fiDOMDocumentSerializer, ((DOMSource) source).getNode());
FastInfosetReflection.FastInfosetSource_setInputStream( source, bout.newInputStream()); } finally {
FastInfosetReflection.FastInfosetResult_new(out));