/** * Validate the (local) ouput from an {@link InOutToolOptions} and return * the corresponding file. * * @param tool * the tool from which to get settings * @return the output file location, deleted if it is allowed to be deleted * @throws IOException * if the file exists, but can't be deleted */ public static File validateLocalOutput(InOutToolOptions tool) throws IOException { return validateLocalOutput(tool.output, tool.isForce(), tool.contin); }
/** * Construct with arguments string * * @param args * the arguments * @throws CmdLineException */ public OutputWorker(String[] args) throws CmdLineException { options = new ReferencesToolOpts(args); options.validate(); }
/** * @return the force option, whether the output should be overwritten if it * exists */ public boolean overwriteOutput() { return this.isForce(); }
/** * Validate the (local) ouput from an String and return the corresponding * file. * * @param out * where the file will go * @param overwrite * whether to overwrite existing files * @return the output file location, deleted if it is allowed to be deleted * @throws IOException * if the file exists, but can't be deleted */ public static File validateLocalOutput(String out, boolean overwrite) throws IOException { return validateLocalOutput(out, overwrite, false); }
@Override public void validate(AbstractTwitterPreprocessingToolOptions twitterPreprocessingModes) { super.validate(twitterPreprocessingModes); InOutToolOptions.prepareMultivaluedArgument(twitterExtras, "id","created_at"); }
/** * Test whether the input is the stdin * * @param tool * @return true if input should be stdin, false otherwise. */ public static boolean isStdin(InOutToolOptions tool) { if (tool.getInput() == null && tool.getInputFile() == null) return true; return tool.getInput() != null && tool.getInput().equals("-"); }
/** * Get the input paths from an {@link InOutToolOptions}. This will resolve the input path * and return either a {@link Path} object representing the string * or, if the path string is a directory, a list of {@link Path}s * representing all the "part" files. * @param options the {@link InOutToolOptions}. * @return the input path * @throws IOException */ public static Path[] getInputPaths(InOutToolOptions options) throws IOException { return SequenceFileUtility.getFilePaths(options.getAllInputs(), "part"); }
/** * Load the options from the arguments string * * @param args * the arguments string * * @throws CmdLineException * if an error occurs */ public ReferencesToolOpts(String[] args) throws CmdLineException { parser = new ExtendedCmdLineParser(this); parser.parseArgument(args); }
@Override public void run() { if (options.printBibtex) printReferences(StandardFormatters.BIBTEX); if (options.printHTML) printReferences(StandardFormatters.HTML); if (options.printText) printReferences(StandardFormatters.STRING); if (options.bibtexFile != null) writeReferences(options.bibtexFile, StandardFormatters.BIBTEX); if (options.htmlFile != null) writeReferences(options.htmlFile, StandardFormatters.HTML); if (options.textFile != null) writeReferences(options.textFile, StandardFormatters.STRING); } }
/** * Validate the (local) ouput from an {@link InOutToolOptions} and return * the corresponding file. * * @param tool * the tool from which to get settings * @return the output file location, deleted if it is allowed to be deleted * @throws IOException * if the file exists, but can't be deleted */ public static File validateLocalOutput(InOutToolOptions tool) throws IOException { return validateLocalOutput(tool.output, tool.isForce(), tool.contin); }
/** * Validate the (local) ouput from an String and return the corresponding * file. * * @param out * where the file will go * @param overwrite * whether to overwrite existing files * @return the output file location, deleted if it is allowed to be deleted * @throws IOException * if the file exists, but can't be deleted */ public static File validateLocalOutput(String out, boolean overwrite) throws IOException { return validateLocalOutput(out, overwrite, false); }
@Override public void validate(AbstractTwitterPreprocessingToolOptions twitterPreprocessingModes) { super.validate(twitterPreprocessingModes); InOutToolOptions.prepareMultivaluedArgument(twitterExtras, "id","created_at"); }
/** * Test whether the input is the stdin * * @param tool * @return true if input should be stdin, false otherwise. */ public static boolean isStdin(InOutToolOptions tool) { if (tool.getInput() == null && tool.getInputFile() == null) return true; return tool.getInput() != null && tool.getInput().equals("-"); }
/** * Get the input paths from an {@link InOutToolOptions}. This will resolve the input path * and return either a {@link Path} object representing the string * or, if the path string is a directory, a list of {@link Path}s * representing all the "part" files. * @param options the {@link InOutToolOptions}. * @return the input path * @throws IOException */ public static Path[] getInputPaths(InOutToolOptions options) throws IOException { return SequenceFileUtility.getFilePaths(options.getAllInputs(), "part"); }
/** * @return the force option, whether the output should be overwritten if it * exists */ public boolean overwriteOutput() { return this.isForce(); }
private static Connection prepareDBSQLite(String location) throws SQLException, ClassNotFoundException, IOException { // load the sqlite-JDBC driver using the current class loader Class.forName("org.sqlite.JDBC"); FileToolsUtil.validateLocalOutput(location, true, false); Connection connection = null; connection = DriverManager.getConnection("jdbc:sqlite:" + location); return connection; }
/** * Get the output path from an {@link InOutToolOptions}. * @param options the {@link InOutToolOptions}. * @return the output path. */ public static Path getOutputPath(InOutToolOptions options) { return new Path(options.getOutput()); }
/** * Get the output path from an {@link InOutToolOptions}. * @param options the {@link InOutToolOptions}. * @return the output path. */ public static Path getOutputPath(InOutToolOptions options) { return new Path(options.getOutput()); }