@Override public final String exportAsString() throws DescriptorExportException { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.exportTo(baos); return baos.toString("UTF-8"); } catch (final UnsupportedEncodingException e) { throw new DescriptorExportException("Inconsistent encoding used during export", e); } }
@Override public final String exportAsString() throws DescriptorExportException { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.exportTo(baos); return baos.toString("UTF-8"); } catch (final UnsupportedEncodingException e) { throw new DescriptorExportException("Inconsistent encoding used during export", e); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.descriptor.api.Descriptor#exportAsString() */ @Override public String exportAsString() throws DescriptorExportException { // Export as bytes final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.exportTo(baos); // Make a String out of the bytes final String content; try { content = baos.toString(Charset.UTF8.name()); } catch (final UnsupportedEncodingException e) { throw new DescriptorExportException("Inconsistent encoding used during export", e); } // Return return content; }
@Override public String exportAsString() throws DescriptorExportException { // Export as bytes final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.exportTo(baos); // Make a String out of the bytes final String content; try { content = baos.toString(Charset.UTF8.name()); } catch (final UnsupportedEncodingException e) { throw new DescriptorExportException("Inconsistent encoding used during export", e); } // Return return content; }
@Override public void exportTo(OutputStream output) throws DescriptorExportException, IllegalArgumentException { if (output == null) { throw new IllegalArgumentException("Can not export to null stream"); } try { getManifestModel().write(output); } catch (IOException e) { throw new DescriptorExportException(e.getMessage(), e); } }
@Override public void exportTo(OutputStream output) throws DescriptorExportException, IllegalArgumentException { if (output == null) { throw new IllegalArgumentException("Can not export to null stream"); } try { getManifestModel().write(output); } catch (IOException e) { throw new DescriptorExportException(e.getMessage(), e); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.descriptor.api.Descriptor#exportAsString() */ @Override public String exportAsString() throws DescriptorExportException { // Export as bytes final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.exportTo(baos); // Make a String out of the bytes final String content; try { content = baos.toString(Charset.UTF8.name()); } catch (final UnsupportedEncodingException e) { throw new DescriptorExportException("Inconsistent encoding used during export", e); } // Return return content; }
throw new DescriptorExportException("Error during exportAsString: " + ioe.getMessage(), ioe);
@Override public void to(Node node, OutputStream out) throws DescriptorExportException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document root = builder.newDocument(); writeRecursive(root, node); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = new StreamResult(out); transformer.transform(new DOMSource(root), result); } catch (Exception e) { throw new DescriptorExportException("Could not export Node strcuture to XML", e); } }
throw new DescriptorExportException("Error during exportAsString: " + ioe.getMessage(), ioe);
throw new DescriptorExportException("Error during exportTo: " + ioe.getMessage(), ioe);
throw new DescriptorExportException("Error during exportTo: " + ioe.getMessage(), ioe);
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl#to(org.jboss.shrinkwrap.descriptor.spi.node.Node, * java.io.OutputStream) */ @Override public void to(final Node node, final OutputStream out) throws DescriptorExportException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document root = builder.newDocument(); root.setXmlStandalone(true); writeRecursive(root, node); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); StreamResult result = new StreamResult(out); transformer.transform(new DOMSource(root), result); } catch (Exception e) { throw new DescriptorExportException("Could not export Node structure to XML", e); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl#to(org.jboss.shrinkwrap.descriptor.spi.node.Node, * java.io.OutputStream) */ @Override public void to(final Node node, final OutputStream out) throws DescriptorExportException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document root = builder.newDocument(); root.setXmlStandalone(true); writeRecursive(root, node); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); StreamResult result = new StreamResult(out); transformer.transform(new DOMSource(root), result); } catch (Exception e) { throw new DescriptorExportException("Could not export Node structure to XML", e); } }