private Writer createFileWriter(final Path file, final Charset charset) { try { return Files.newBufferedWriter(file, charset); } catch (final IOException e) { throw new ExporterException("Error creating writer for file " + file, e); } }
private Writer createFileWriter(final Path file, final Charset charset) { try { return Files.newBufferedWriter(file, charset); } catch (final IOException e) { throw new ExporterException("Error creating writer for file " + file, e); } }
private XMLStreamWriter createXmlWriter(final Writer writer) { XMLStreamWriter xmlWriter; try { xmlWriter = this.xmlOutputFactory.createXMLStreamWriter(writer); } catch (final XMLStreamException e) { throw new ExporterException("Error creating xml stream writer for writer " + writer, e); } return xmlWriter; } }
private XMLStreamWriter createXmlWriter(final Writer writer) { XMLStreamWriter xmlWriter; try { xmlWriter = this.xmlOutputFactory.createXMLStreamWriter(writer); } catch (final XMLStreamException e) { throw new ExporterException("Error creating xml stream writer for writer " + writer, e); } return xmlWriter; } }
private static PrintStream createPrintStream(final OutputStream stream, final Charset charset) { try { return new PrintStream(stream, false, charset.name()); } catch (final UnsupportedEncodingException e) { throw new ExporterException("Error creating print stream for charset " + charset, e); } }
private static PrintStream createPrintStream(final OutputStream stream, final Charset charset) { try { return new PrintStream(stream, false, charset.name()); } catch (final UnsupportedEncodingException e) { throw new ExporterException("Error creating print stream for charset " + charset, e); } }
private void closeXmlWriter() { try { LOG.finest(() -> "Closing xml writer"); this.writer.close(); this.originalWriter.close(); } catch (final XMLStreamException | IOException e) { throw new ExporterException("Error closing writer", e); } }
private void closeXmlWriter() { try { LOG.finest(() -> "Closing xml writer"); this.writer.close(); this.originalWriter.close(); } catch (final XMLStreamException | IOException e) { throw new ExporterException("Error closing writer", e); } }
/** * Finds a matching {@link ExporterFactory} that can handle the given output * format. If no or more than one {@link ExporterFactory} is found, this * throws an {@link ExporterException}. * * @param outputFormat * the output format for which to get a {@link ExporterFactory}. * @return a matching {@link ExporterFactory} that can handle the given * output format * @throws ExporterException * when no or more than one {@link ExporterFactory} is found. */ public ExporterFactory getExporterFactory(final String outputFormat) { final List<ExporterFactory> matchingExporters = getMatchingFactories(outputFormat); switch (matchingExporters.size()) { case 0: throw new ExporterException( "Found no matching exporter for output format '" + outputFormat + "'"); case 1: return matchingExporters.get(0); default: throw new ExporterException("Found more than one matching exporter for output format '" + outputFormat + "'"); } }
/** * Finds a matching {@link ExporterFactory} that can handle the given output * format. If no or more than one {@link ExporterFactory} is found, this * throws an {@link ExporterException}. * * @param outputFormat * the output format for which to get a {@link ExporterFactory}. * @return a matching {@link ExporterFactory} that can handle the given * output format * @throws ExporterException * when no or more than one {@link ExporterFactory} is found. */ public ExporterFactory getExporterFactory(final String outputFormat) { final List<ExporterFactory> matchingExporters = getMatchingFactories(outputFormat); switch (matchingExporters.size()) { case 0: throw new ExporterException( "Found no matching exporter for output format '" + outputFormat + "'"); case 1: return matchingExporters.get(0); default: throw new ExporterException("Found more than one matching exporter for output format '" + outputFormat + "'"); } }
@Override // [impl->dsn~conversion.reqm2-export~1] public void runExport() { try { writeOutput(); } catch (final XMLStreamException e) { throw new ExporterException("Error exporting to specobject format", e); } finally { closeXmlWriter(); } }
@Override // [impl->dsn~conversion.reqm2-export~1] public void runExport() { try { writeOutput(); } catch (final XMLStreamException e) { throw new ExporterException("Error exporting to specobject format", e); } finally { closeXmlWriter(); } }
/** * Create an exporter that is able to export the given output format. * * @param file * the file to which specification items are written * @param format * the output format * @param charset * the character set used for exporting * @param newline * the newline format * @param itemStream * the items to export * @return an exporter instance */ public Exporter createExporter(final Path file, final String format, final Charset charset, final Newline newline, final Stream<SpecificationItem> itemStream) { if (!supportsFormat(format)) { throw new ExporterException("Output format '" + format + "' not supported for export"); } final Writer writer = createWriter(file, charset); return createExporter(writer, itemStream, newline); }
/** * Create an exporter that is able to export the given output format. * * @param file * the file to which specification items are written * @param format * the output format * @param charset * the character set used for exporting * @param newline * the newline format * @param itemStream * the items to export * @return an exporter instance */ public Exporter createExporter(final Path file, final String format, final Charset charset, final Newline newline, final Stream<SpecificationItem> itemStream) { if (!supportsFormat(format)) { throw new ExporterException("Output format '" + format + "' not supported for export"); } final Writer writer = createWriter(file, charset); return createExporter(writer, itemStream, newline); }