private boolean validateConvertCommand() { boolean ok = false; final String format = this.arguments.getOutputFormat(); if (format != null && !new ExporterFactoryLoader(null).isFormatSupported(format)) { this.error = "export format '" + format + "' is not supported."; } else { ok = true; } return ok; }
/** * Determines if the requested format is supported * * @param format * the requested exporter format * @return <code>true</code> if the format is supported */ public boolean isFormatSupported(final String format) { return !getMatchingFactories(format).isEmpty(); } }
public ExporterService() { this(new ExporterFactoryLoader(new ExporterContext())); }
/** * Export the given {@link LinkedSpecificationItem} in the given output * format to a file * * @param itemStream * {@link SpecificationItem} to export * @param outputFile * path to which the export is written * @param settings * exporter settings */ public void exportToPath(final Stream<SpecificationItem> itemStream, final Path outputFile, final ExportSettings settings) { final ExporterFactory factory = this.factoryLoader .getExporterFactory(settings.getOutputFormat()); factory.createExporter(outputFile, settings.getOutputFormat(), StandardCharsets.UTF_8, settings.getNewline(), itemStream).runExport(); } }
public ExporterService() { this(new ExporterFactoryLoader(new ExporterContext())); }
/** * Export the given {@link LinkedSpecificationItem} in the given output * format to a file * * @param itemStream * {@link SpecificationItem} to export * @param outputFile * path to which the export is written * @param settings * exporter settings */ public void exportToPath(final Stream<SpecificationItem> itemStream, final Path outputFile, final ExportSettings settings) { final ExporterFactory factory = this.factoryLoader .getExporterFactory(settings.getOutputFormat()); factory.createExporter(outputFile, settings.getOutputFormat(), StandardCharsets.UTF_8, settings.getNewline(), itemStream).runExport(); } }
private boolean validateConvertCommand() { boolean ok = false; final String format = this.arguments.getOutputFormat(); if (format != null && !new ExporterFactoryLoader(null).isFormatSupported(format)) { this.error = "export format '" + format + "' is not supported."; } else { ok = true; } return ok; }
/** * Determines if the requested format is supported * * @param format * the requested exporter format * @return <code>true</code> if the format is supported */ public boolean isFormatSupported(final String format) { return !getMatchingFactories(format).isEmpty(); } }
/** * 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 + "'"); } }