Java Code Examples for com.martiansoftware.jsap.JSAPResult#getBoolean()
The following examples show how to use
com.martiansoftware.jsap.JSAPResult#getBoolean() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GZIPArchiveWriterTest.java From BUbiNG with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws IOException, JSAPException { SimpleJSAP jsap = new SimpleJSAP(GZIPArchiveReader.class.getName(), "Writes some random records on disk.", new Parameter[] { new Switch("fully", 'f', "fully", "Whether to read fully the record (and do a minimal cosnsistency check)."), new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The path to read from."), }); JSAPResult jsapResult = jsap.parse(args); if (jsap.messagePrinted()) System.exit(1); final boolean fully = jsapResult.getBoolean("fully"); GZIPArchiveReader gzar = new GZIPArchiveReader(new FileInputStream(jsapResult.getString("path"))); for (;;) { ReadEntry e = gzar.getEntry(); if (e == null) break; InputStream inflater = e.lazyInflater.get(); if (fully) ByteStreams.toByteArray(inflater); e.lazyInflater.consume(); System.out.println(e); } }
Example 2
Source File: FrontCodedStringList.java From database with GNU General Public License v2.0 | 5 votes |
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException { final SimpleJSAP jsap = new SimpleJSAP( FrontCodedStringList.class.getName(), "Builds a front-coded string list reading from standard input a newline-separated ordered list of terms.", new Parameter[] { new FlaggedOption( "bufferSize", IntSizeStringParser.getParser(), "64Ki", JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of the I/O buffer used to read terms." ), new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ), new FlaggedOption( "ratio", IntSizeStringParser.getParser(), "4", JSAP.NOT_REQUIRED, 'r', "ratio", "The compression ratio." ), new Switch( "utf8", 'u', "utf8", "Store the strings as UTF-8 byte arrays." ), new Switch( "zipped", 'z', "zipped", "The term list is compressed in gzip format." ), new UnflaggedOption( "frontCodedList", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised front-coded list." ) }); JSAPResult jsapResult = jsap.parse( arg ); if ( jsap.messagePrinted() ) return; final int bufferSize = jsapResult.getInt( "bufferSize" ); final int ratio = jsapResult.getInt( "ratio" ); final boolean utf8 = jsapResult.getBoolean( "utf8" ); final boolean zipped = jsapResult.getBoolean( "zipped" ); final String listName = jsapResult.getString( "frontCodedList" ); final Charset encoding = (Charset)jsapResult.getObject( "encoding" ); final ProgressLogger pl = new ProgressLogger(); pl.itemsName = "words"; pl.start( "Reading words..." ); final FrontCodedStringList frontCodedStringList = new FrontCodedStringList( new LineIterator( new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( System.in ) : System.in, encoding ), bufferSize ), pl ), ratio, utf8 ); pl.done(); System.err.print( "Writing to file..." ); BinIO.storeObject( frontCodedStringList, listName ); System.err.println( " done." ); }
Example 3
Source File: RandomReadWritesTest.java From BUbiNG with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws JSAPException, IOException, InterruptedException { final SimpleJSAP jsap = new SimpleJSAP(RandomReadWritesTest.class.getName(), "Writes some random records on disk.", new Parameter[] { new FlaggedOption("random", JSAP.INTEGER_PARSER, "100", JSAP.NOT_REQUIRED, 'r', "random", "The number of random record to sample from."), new FlaggedOption("body", JSAP.INTSIZE_PARSER, "4K", JSAP.NOT_REQUIRED, 'b', "body", "The maximum size of the random generated body (in bytes)."), new Switch("fully", 'f', "fully", "Whether to read fully the record (and do a minimal sequential cosnsistency check)."), new Switch("writeonly", 'w', "writeonly", "Whether to skip the read part (if present, 'fully' will be ignored."), new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The path to write to."), new UnflaggedOption("records", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The numer of records to write."), }); final JSAPResult jsapResult = jsap.parse(args); if (jsap.messagePrinted()) System.exit(1); final String path = jsapResult.getString("path"); final boolean compress = path.endsWith(".gz"); final boolean fully = jsapResult.getBoolean("fully"); final int parallel = compress ? 1 : 0; final int body = jsapResult.getInt("body"); final WarcRecord[] rnd = prepareRndRecords(jsapResult.getInt("random"), RESPONSE_PROBABILITY, MAX_NUMBER_OF_HEADERS, MAX_LENGTH_OF_HEADER, body); final int[] sequence = writeRecords(path, jsapResult.getInt("records"), rnd, parallel); if (! jsapResult.getBoolean("writeonly")) readRecords(path, sequence, body, fully, compress); }
Example 4
Source File: ShiftAddXorSignedStringMap.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public static void main( final String[] arg ) throws NoSuchMethodException, IOException, JSAPException, ClassNotFoundException { final SimpleJSAP jsap = new SimpleJSAP( ShiftAddXorSignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.", new Parameter[] { new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of the I/O buffer used to read strings." ), new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ), new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ), new FlaggedOption( "width", JSAP.INTEGER_PARSER, Integer.toString( Integer.SIZE ), JSAP.NOT_REQUIRED, 'w', "width", "The signature width in bits." ), new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ), new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting serialised signed string map." ), new UnflaggedOption( "stringFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "Read strings from this file instead of standard input." ), }); JSAPResult jsapResult = jsap.parse( arg ); if ( jsap.messagePrinted() ) return; final int bufferSize = jsapResult.getInt( "bufferSize" ); final String functionName = jsapResult.getString( "function" ); final String mapName = jsapResult.getString( "map" ); final String stringFile = jsapResult.getString( "stringFile" ); final Charset encoding = (Charset)jsapResult.getObject( "encoding" ); final int width = jsapResult.getInt( "width" ); final boolean zipped = jsapResult.getBoolean( "zipped" ); final InputStream inputStream = stringFile != null ? new FileInputStream( stringFile ) : System.in; final Iterator<MutableString> iterator = new LineIterator( new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( inputStream ) : inputStream, encoding ), bufferSize ) ); final Object2LongFunction<CharSequence> function = (Object2LongFunction<CharSequence>)BinIO.loadObject( functionName ); LOGGER.info( "Signing..." ); BinIO.storeObject( new ShiftAddXorSignedStringMap( iterator, function, width ), mapName ); LOGGER.info( "Completed." ); }
Example 5
Source File: PermutedFrontCodedStringList.java From database with GNU General Public License v2.0 | 5 votes |
public static void main( final String[] arg ) throws IOException, ClassNotFoundException, JSAPException { SimpleJSAP jsap = new SimpleJSAP( PermutedFrontCodedStringList.class.getName(), "Builds a permuted front-coded list of strings using a given front-coded string list and permutation", new Parameter[] { new Switch( "invert", 'i', "invert", "Invert permutation before creating the permuted list." ), new UnflaggedOption( "list", JSAP.STRING_PARSER, JSAP.REQUIRED, "A front-coded string list." ), new UnflaggedOption( "permutation", JSAP.STRING_PARSER, JSAP.REQUIRED, "A permutation for the indices of the list." ), new UnflaggedOption( "permutedList", JSAP.STRING_PARSER, JSAP.REQUIRED, "A the filename for the resulting permuted list." ), } ); JSAPResult jsapResult = jsap.parse( arg ); if ( jsap.messagePrinted() ) return; int[] basePermutation = BinIO.loadInts( jsapResult.getString( "permutation" ) ), permutation; if ( jsapResult.getBoolean( "invert" ) ) { int i = basePermutation.length; permutation = new int[ i ]; while( i-- != 0 ) permutation[ basePermutation[ i ] ] = i; } else permutation = basePermutation; basePermutation = null; BinIO.storeObject( new PermutedFrontCodedStringList( (FrontCodedStringList)BinIO.loadObject( jsapResult.getString( "list" ) ), permutation ), jsapResult.getString( "permutedList" ) ); }
Example 6
Source File: LiterallySignedStringMap.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public static void main( final String[] arg ) throws IOException, JSAPException, ClassNotFoundException, SecurityException, NoSuchMethodException { final SimpleJSAP jsap = new SimpleJSAP( LiterallySignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.", new Parameter[] { new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ), new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ), new Switch( "text", 't', "text", "The string list actually a text file, with one string per line." ), new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ), new UnflaggedOption( "list", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the serialised list of strings, or of a text file containing a list of strings, if -t is specified." ), new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting map." ), }); JSAPResult jsapResult = jsap.parse( arg ); if ( jsap.messagePrinted() ) return; final String functionName = jsapResult.getString( "function" ); final String listName = jsapResult.getString( "list" ); final String mapName = jsapResult.getString( "map" ); final Charset encoding = (Charset)jsapResult.getObject( "encoding" ); final boolean zipped = jsapResult.getBoolean( "zipped" ); final boolean text = jsapResult.getBoolean( "text" ); ObjectList<MutableString> list = text ? new FileLinesCollection( listName, encoding.toString(), zipped ).allLines() : (ObjectList)BinIO.loadObject( listName ); LOGGER.info( "Signing..." ); BinIO.storeObject( new LiterallySignedStringMap( (Object2LongFunction)BinIO.loadObject( functionName ), list ), mapName ); LOGGER.info( "Completed." ); }
Example 7
Source File: GitRepositoryLauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgGitRepositoryFirstCommit(JSAPResult arguments) { return arguments.getBoolean("gitRepositoryFirstCommit"); }
Example 8
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgHelp(JSAPResult arguments) { return arguments.getBoolean("help"); }
Example 9
Source File: GitRepositoryLauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgGitRepositoryMode(JSAPResult arguments) { return arguments.getBoolean("gitRepo"); }
Example 10
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgNotifyEndProcess(JSAPResult arguments) { return arguments.getBoolean("notifyEndProcess"); }
Example 11
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgCreatePR(JSAPResult arguments) { return arguments.getBoolean("createPR"); }
Example 12
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean gerArgCheckstyleMode(JSAPResult arguments) { return arguments.getBoolean("checkstyle"); }
Example 13
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean gerArgBearsMode(JSAPResult arguments) { return arguments.getBoolean("bears"); }
Example 14
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgSmtpTLS(JSAPResult arguments) { return arguments.getBoolean("smtpTLS"); }
Example 15
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgCreateOutputDir(JSAPResult arguments) { return arguments.getBoolean("createOutputDir"); }
Example 16
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static boolean getArgSkipDelete(JSAPResult arguments) { return arguments.getBoolean("skipDelete"); }
Example 17
Source File: GithubInitConfig.java From repairnator with MIT License | 4 votes |
@Override public void initConfigWithJSAP(JSAP jsap, String[] inputArgs) { JSAPResult arguments = jsap.parse(inputArgs); if (LauncherUtils.getArgDebug(arguments)) { getConfig().setDebug(true); } getConfig().setClean(true); getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (GitRepositoryLauncherUtils.getArgGitRepositoryMode(arguments)) { if (GitRepositoryLauncherUtils.getArgGitRepositoryFirstCommit(arguments)) { getConfig().setGitRepositoryFirstCommit(true); } } else { System.err.println("Error: Parameter 'gitrepo' is required in GIT_REPOSITORY launcher mode."); } if (LauncherUtils.getArgOutput(arguments) != null) { getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); } getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { getConfig().setPush(true); getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); } getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments)); // we fork if we need to create a PR or if we need to notify if ((getConfig().isCreatePR() || (getConfig().getSmtpServer() != null && !getConfig().getSmtpServer().isEmpty() && getConfig().getNotifyTo() != null && getConfig().getNotifyTo().length > 0)) && getConfig().getGithubToken() != null) { getConfig().setFork(true); } if (arguments.getString("gitRepositoryUrl") == null) { System.err.println("Error: Parameter 'gitrepourl' is required in GIT_REPOSITORY launcher mode."); } if (getConfig().isGitRepositoryFirstCommit() && arguments.getString("gitRepositoryIdCommit") != null) { System.err.println("Error: Parameters 'gitrepofirstcommit' and 'gitrepoidcommit' cannot be used at the same time."); } getConfig().setGitRepositoryUrl(arguments.getString("gitRepositoryUrl")); getConfig().setGitRepositoryBranch(arguments.getString("gitRepositoryBranch")); getConfig().setGitRepositoryIdCommit(arguments.getString("gitRepositoryIdCommit")); getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath()); getConfig().setWorkspacePath(arguments.getString("workspace")); if (arguments.getBoolean("tmpDirAsWorkSpace")) { tempDir = com.google.common.io.Files.createTempDir(); getConfig().setWorkspacePath(tempDir.getAbsolutePath()); getConfig().setOutputPath(tempDir.getAbsolutePath()); getConfig().setZ3solverPath(new File(tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath()); } getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); getConfig().setListenerMode(arguments.getString("listenermode")); getConfig().setActiveMQUrl(arguments.getString("activemqurl")); getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename")); getConfig().setGitUrl(arguments.getString("giturl")); getConfig().setGitBranch(arguments.getString("gitbranch")); getConfig().setGitCommitHash(arguments.getString("gitcommithash")); getConfig().setMavenHome(arguments.getString("MavenHome")); if (arguments.getFile("projectsToIgnore") != null) { getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath()); } getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools")))); // Make sure that it is a multiple of three in the list if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) { getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList")); } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) { LOGGER.warn("The experimental plugin repo list is not correctly formed." + " Please make sure you have provided id, name and url for all repos. " + "Repairnator will continue without these repos."); getConfig().setExperimentalPluginRepoList(null); } else { getConfig().setExperimentalPluginRepoList(null); } }
Example 18
Source File: LegacyLauncher.java From repairnator with MIT License | 4 votes |
protected void initConfig(JSAPResult arguments) { if (LauncherUtils.getArgDebug(arguments)) { this.getConfig().setDebug(true); } this.getConfig().setClean(true); this.getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); this.getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (LauncherUtils.gerArgBearsMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.BEARS); } else if (LauncherUtils.gerArgCheckstyleMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.CHECKSTYLE); } else { this.getConfig().setLauncherMode(LauncherMode.REPAIR); } if (LauncherUtils.getArgOutput(arguments) != null) { this.getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); } this.getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { this.getConfig().setPush(true); this.getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); } this.getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments)); // we fork if we need to create a PR or if we need to notify (but only when we have a git token) if (this.getConfig().isCreatePR() || (this.getConfig().getSmtpServer() != null && !this.getConfig().getSmtpServer().isEmpty() && this.getConfig().getNotifyTo() != null && this.getConfig().getNotifyTo().length > 0 && this.getConfig().getGithubToken() != null)) { this.getConfig().setFork(true); } this.getConfig().setBuildId(arguments.getInt("build")); if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { this.getConfig().setNextBuildId(arguments.getInt("nextBuild")); } this.getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath()); this.getConfig().setWorkspacePath(arguments.getString("workspace")); if (arguments.getBoolean("tmpDirAsWorkSpace")) { this.tempDir = com.google.common.io.Files.createTempDir(); this.getConfig().setWorkspacePath(this.tempDir.getAbsolutePath()); this.getConfig().setOutputPath(this.tempDir.getAbsolutePath()); this.getConfig().setZ3solverPath(new File(this.tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath()); } this.getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); this.getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); this.getConfig().setListenerMode(arguments.getString("listenermode")); this.getConfig().setActiveMQUrl(arguments.getString("activemqurl")); this.getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename")); this.getConfig().setActiveMQUsername(arguments.getString("activemqusername")); this.getConfig().setActiveMQPassword(arguments.getString("activemqpassword")); this.getConfig().setGitUrl(arguments.getString("giturl")); this.getConfig().setGitBranch(arguments.getString("gitbranch")); this.getConfig().setGitCommitHash(arguments.getString("gitcommithash")); this.getConfig().setMavenHome(arguments.getString("MavenHome")); this.getConfig().setNoTravisRepair(arguments.getBoolean("noTravisRepair")); if (arguments.getFile("projectsToIgnore") != null) { this.getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath()); } this.getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools")))); if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) { LOGGER.info("The following repair tools will be used: " + StringUtils.join(this.getConfig().getRepairTools(), ", ")); } // Make sure that it is a multiple of three in the list if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) { this.getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList")); } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) { LOGGER.warn("The experimental plugin repo list is not correctly formed." + " Please make sure you have provided id, name and url for all repos. " + "Repairnator will continue without these repos."); this.getConfig().setExperimentalPluginRepoList(null); } else { this.getConfig().setExperimentalPluginRepoList(null); } }
Example 19
Source File: ImmutableExternalPrefixMap.java From database with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unchecked") public static void main( final String[] arg ) throws ClassNotFoundException, IOException, JSAPException, SecurityException, NoSuchMethodException { final SimpleJSAP jsap = new SimpleJSAP( ImmutableExternalPrefixMap.class.getName(), "Builds an external map reading from standard input a newline-separated list of terms or a serialised term list. If the dump stream name is not specified, the map will be self-contained.", new Parameter[] { new FlaggedOption( "blockSize", JSAP.INTSIZE_PARSER, ( STD_BLOCK_SIZE / 1024 ) + "Ki", JSAP.NOT_REQUIRED, 'b', "block-size", "The size of a block in the dump stream." ), new Switch( "serialised", 's', "serialised", "The data source (file or standard input) provides a serialised java.util.List of terms." ), new Switch( "zipped", 'z', "zipped", "Standard input is compressed in gzip format." ), new FlaggedOption( "termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file instead of standard input." ), new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term list encoding." ), new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised map." ), new UnflaggedOption( "dump", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "An optional dump stream (the resulting map will not be self-contained)." ) } ); JSAPResult jsapResult = jsap.parse( arg ); if ( jsap.messagePrinted() ) return; Collection<? extends CharSequence> termList; final String termFile = jsapResult.getString( "termFile" ); final Charset encoding = (Charset)jsapResult.getObject( "encoding" ); final boolean zipped = jsapResult.getBoolean( "zipped" ); final boolean serialised = jsapResult.getBoolean( "serialised" ); if ( zipped && serialised ) throw new IllegalArgumentException( "The zipped and serialised options are incompatible" ); if ( serialised ) termList = (List<? extends CharSequence>) ( termFile != null ? BinIO.loadObject( termFile ) : BinIO.loadObject( System.in ) ); else { if ( termFile != null ) termList = new FileLinesCollection( termFile, encoding.name(), zipped ); else { final ObjectArrayList<MutableString> list = new ObjectArrayList<MutableString>(); termList = list; final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( System.in ) : System.in, encoding.name() ) ); final MutableString term = new MutableString(); while( terms.readLine( term ) != null ) list.add( term.copy() ); terms.close(); } } BinIO.storeObject( new ImmutableExternalPrefixMap( termList, jsapResult.getInt( "blockSize" ), jsapResult.getString( "dump" ) ), jsapResult.getString( "map" ) ); }
Example 20
Source File: CommandLine.java From ASTRAL with Apache License 2.0 | 4 votes |
private static boolean isGeneResamplign(JSAPResult config) { return config.getBoolean("gene-sampling") || config.getBoolean("gene-only") ; }