private BaseNavigationFormat findFormat(String formatName) { List<NavigationFormat> formats = NavigationFormats.getWriteFormats(); for (NavigationFormat format : formats) if (formatName.equals(format.getClass().getSimpleName())) return (BaseNavigationFormat) format; return null; }
private void convert(File source, NavigationFormat format, File target) throws IOException { NavigationFileParser parser = new NavigationFileParser(); if (!parser.read(source)) { log.severe("Could not read source '" + source.getAbsolutePath() + "'"); logFormatNames(NavigationFormats.getReadFormatsSortedByName()); System.exit(20); } if (format.isSupportsMultipleRoutes()) { parser.write(parser.getAllRoutes(), (MultipleRoutesFormat) format, target); } else { int fileCount = NavigationFileParser.getNumberOfFilesToWriteFor(parser.getTheRoute(), format, false); File[] targets = Files.createTargetFiles( target, fileCount, format.getExtension(), format.getMaximumFileNameLength()); for (File t : targets) { if (t.exists()) { log.severe("Target '" + t.getAbsolutePath() + "' already exists; stopping."); System.exit(13); } } parser.write(parser.getTheRoute(), format, false, false, targets); } }
private void logFormatNames(List<NavigationFormat> formats) { log.info("Supported formats:"); for (NavigationFormat format : formats) log.info(format.getClass().getSimpleName() + " for " + format.getName()); }