Package com.martiansoftware.jsap

Examples of com.martiansoftware.jsap.SimpleJSAP


    }
  }

  public static void main( final String[] arg ) throws IOException, JSAPException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    SimpleJSAP jsap = new SimpleJSAP(
        TRECDocumentCollection.class.getName(), "Saves a serialised TREC document collection based on a set of file names (which will be sorted lexicographically).",
        new Parameter[] {
            new FlaggedOption( "factory", MG4JClassParser.getParser(), IdentityDocumentFactory.class.getName(), JSAP.NOT_REQUIRED, 'f', "factory", "A document factory with a standard constructor." ),
            new FlaggedOption( "property", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'p', "property", "A 'key=value' specification, or the name of a property file" ).setAllowMultipleDeclarations( true ),
            new Switch( "gzipped", 'z', "gzipped", "The files are gzipped." ),
            new Switch( "unsorted", 'u', "unsorted", "Keep the file list unsorted." ),
            new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, DEFAULT_BUFFER_SIZE, JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of an I/O buffer." ),
            new UnflaggedOption( "collection", JSAP.STRING_PARSER, JSAP.REQUIRED, "The filename for the serialised collection." ),
            new UnflaggedOption( "file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.GREEDY, "A list of files that will be indexed. If missing, a list of files will be read from standard input." )
    } );

    JSAPResult jsapResult = jsap.parse( arg );
    if ( jsap.messagePrinted() ) return;

    final DocumentFactory userFactory = PropertyBasedDocumentFactory.getInstance( jsapResult.getClass( "factory" ), jsapResult.getStringArray( "property" ) );

    String[] file = jsapResult.getStringArray( "file" );
    if ( file.length == 0 ) {
View Full Code Here


    initBuffers();
 
 
  public static void main( final String[] arg ) throws IOException, JSAPException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    SimpleJSAP jsap = new SimpleJSAP( WikipediaDocumentCollection.class.getName(), "Saves a serialised document collection based on a set of files.",
        new Parameter[] {
          // Don't know what this was for...
          //new FlaggedOption( "uris", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'u', "uris", "A file containing a list of URIs in ASCII encoding, one per line, that will be associated to each file" ),
          new Switch( "sentence", 's', "sentence", "Index sentences rather than documents." ),
          new Switch( "gzipped", 'z', "gzipped", "The files are gzipped." ),
          new UnflaggedOption( "collection", JSAP.STRING_PARSER, JSAP.REQUIRED, "The filename for the serialised collection." ),
          new UnflaggedOption( "file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.GREEDY, "A list of files that will be indexed. If missing, a list of files will be read from standard input." )
        }
    );
   

    JSAPResult jsapResult = jsap.parse( arg );
    if ( jsap.messagePrinted() ) return;
   
    /*String uri[] = null;
    if ( jsapResult.getString( "uris" ) != null ) {
      Collection<MutableString> lines = new FileLinesCollection( jsapResult.getString( "uris" ), "ASCII" ).allLines();
      uri = new String[ lines.size() ];
View Full Code Here

 

 
  public static void main( final String[] arg ) throws JSAPException, IOException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException, IllegalArgumentException, SecurityException {

    SimpleJSAP jsap = new SimpleJSAP( ZipDocumentCollectionBuilder.class.getName(), "Produces a zip document collection from an existing document sequence.",
        new Parameter[] {
          new FlaggedOption( "sequence", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'S', "sequence", "A serialised document sequence that will be used instead of stdin." ),
          new FlaggedOption( "factory", MG4JClassParser.getParser(), IdentityDocumentFactory.class.getName(), JSAP.NOT_REQUIRED, 'f', "factory", "A document factory with a standard constructor." ),
          new FlaggedOption( "property", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'p', "property", "A 'key=value' specification, or the name of a property file" ).setAllowMultipleDeclarations( true ),
          new FlaggedOption( "delimiter", JSAP.INTEGER_PARSER, Integer.toString( Scan.DEFAULT_DELIMITER ), JSAP.NOT_REQUIRED, 'd', "delimiter", "The document delimiter." ),
          new Switch( "approximated", 'a', "approximated", "If specified, non-words will not be copied." ),
          new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
          new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename for the collection." ),
        }
    );
    JSAPResult jsapResult = jsap.parse( arg );
    if ( jsap.messagePrinted() ) return;

    DocumentSequence documentSequence = Scan.getSequence( jsapResult.getString( "sequence" ), jsapResult.getClass( "factory" ), jsapResult.getStringArray( "property" ), jsapResult.getInt( "delimiter" ), LOGGER );
    final ProgressLogger progressLogger = new ProgressLogger( LOGGER, "documents" );
    if ( documentSequence instanceof DocumentCollection ) progressLogger.expectedUpdates = ((DocumentCollection)documentSequence).size();
    final ZipDocumentCollectionBuilder zipDocumentCollectionBuilder = new ZipDocumentCollectionBuilder( jsapResult.getString( "basename" ), documentSequence.factory(), !jsapResult.getBoolean( "approximated") );
View Full Code Here

   * @throws InterruptedException
   * @throws JSAPException
   * @throws SAXException
   */
  public static void main(String[] args) throws JSAPException {
    SimpleJSAP jsap = new SimpleJSAP("InfinispanFluDemo", "Parse the Influenze data and store in cache ",
        new Parameter[] {
            new FlaggedOption("InfinispanCfg", JSAP.STRING_PARSER, null, JSAP.REQUIRED, 'c',
                JSAP.NO_LONGFLAG, "Location of Infinispan config file"),
            new FlaggedOption("ifile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'i', JSAP.NO_LONGFLAG,
                "Location of influenza.dat"),
            new FlaggedOption("pfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'p', JSAP.NO_LONGFLAG,
                "location of influenza_aa.dat."),
            new FlaggedOption("count", JSAP.INTEGER_PARSER, "-1", JSAP.NOT_REQUIRED, 'l', JSAP.NO_LONGFLAG,
                "Number of records to load from file"),
            new Switch("query", 'q', "true", "Enable query cli"),
            new Switch("randomquery", 'r', "randomquery",
                "Randomly query the influenza to test that the cache is fully populated"),
            new FlaggedOption("nfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'n', JSAP.NO_LONGFLAG,
                "Location of influenza_na.dat") });
    if (jsap.messagePrinted())
      System.exit(1);

    JSAPResult config = jsap.parse(args);
    InfluenzaDataLoader fluDemo = new InfluenzaDataLoader();
    try {
      fluDemo.createCache(config.getString("InfinispanCfg"));
      fluDemo.populateCache(config);
    } catch (SAXException e1) {
View Full Code Here

      isMaster = nodeType != null && nodeType.equals("master");
      cfgFile = commandLineOptions.getString("configFile");
   }

   protected JSAPResult parseParameters(String[] args) throws Exception {
      SimpleJSAP jsap = buildCommandLineOptions();

      JSAPResult config = jsap.parse(args);
      if (!config.success() || jsap.messagePrinted()) {
         Iterator<?> messageIterator = config.getErrorMessageIterator();
         while (messageIterator.hasNext()) System.err.println(messageIterator.next());
         System.err.println(jsap.getHelp());
         return null;
      }

      return config;
   }
View Full Code Here

      }
   }

   @Override
   protected SimpleJSAP buildCommandLineOptions() throws JSAPException {
      return new SimpleJSAP(
            "WordCountDemo",
            "Count words in Infinispan cache usin MapReduceTask ",
            new Parameter[]{
                  new FlaggedOption("configFile", JSAP.STRING_PARSER, "config-samples/distributed-udp.xml",
                                    JSAP.NOT_REQUIRED, 'c', "configFile",
View Full Code Here

      }
   }

   @Override
   protected SimpleJSAP buildCommandLineOptions() throws JSAPException {
      return new SimpleJSAP("PiApproximationDemo",
                            "Approximate Pi using Infinispan DistributedExecutorService ", new Parameter[]{
                  new FlaggedOption("configFile", JSAP.STRING_PARSER, "config-samples/distributed-udp.xml",
                                    JSAP.NOT_REQUIRED, 'c', "configFile",
                                    "Infinispan config file"),
                  new FlaggedOption("nodeType", JSAP.STRING_PARSER, "slave", JSAP.REQUIRED,
View Full Code Here

   * @throws InterruptedException
   * @throws JSAPException
   * @throws SAXException
   */
  public static void main(String[] args) throws JSAPException {
    SimpleJSAP jsap = new SimpleJSAP("InfinispanFluDemo", "Parse the Influenze data and store in cache ",
        new Parameter[] {
            new FlaggedOption("InfinispanCfg", JSAP.STRING_PARSER, null, JSAP.REQUIRED, 'c',
                JSAP.NO_LONGFLAG, "Location of Infinispan config file"),
            new FlaggedOption("ifile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'i', JSAP.NO_LONGFLAG,
                "Location of influenza.dat"),
            new FlaggedOption("pfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'p', JSAP.NO_LONGFLAG,
                "location of influenza_aa.dat."),
            new FlaggedOption("count", JSAP.INTEGER_PARSER, "-1", JSAP.NOT_REQUIRED, 'l', JSAP.NO_LONGFLAG,
                "Number of records to load from file"),
            new Switch("query", 'q', "true", "Enable query cli"),
            new Switch("randomquery", 'r', "randomquery",
                "Randomly query the influenza to test that the cache is fully populated"),
            new FlaggedOption("nfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'n', JSAP.NO_LONGFLAG,
                "Location of influenza_na.dat") });
    if (jsap.messagePrinted())
      System.exit(1);

    JSAPResult config = jsap.parse(args);
    InfluenzaDataLoader fluDemo = new InfluenzaDataLoader();
    try {
      fluDemo.createCache(config.getString("InfinispanCfg"));
      fluDemo.populateCache(config);
    } catch (SAXException e1) {
View Full Code Here

   * @param args the command line.
   * @throws Exception for reasons made clear later in the manual.
   */
  // @@snip:Manual_HelloWorld_Simple@@
  public static void main(String[] args) throws Exception {
    SimpleJSAP jsap = new SimpleJSAP(
      "MyProgram",
      "Repeats \"Hello, world!\" multiple times",
      new Parameter[] {
        new FlaggedOption( "count", JSAP.INTEGER_PARSER, "1", JSAP.REQUIRED, 'n', JSAP.NO_LONGFLAG,
          "The number of times to say hello." ),
        new QualifiedSwitch( "verbose", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'v', "verbose",
          "Requests verbose output." ).setList( true ).setListSeparator( ',' ),
        new UnflaggedOption( "name", JSAP.STRING_PARSER, "World", JSAP.REQUIRED, JSAP.GREEDY,
          "One or more names of people you would like to greet." )
      }
    );
   
    JSAPResult config = jsap.parse(args)
    if ( jsap.messagePrinted() ) System.exit( 1 );
       
    String[] names = config.getStringArray("name");
    String[] languages = config.getStringArray("verbose");
    for (int i = 0; i < languages.length; ++i) {
      System.out.println("language=" + languages[i]);
View Full Code Here

   * @throws InterruptedException
   * @throws JSAPException
   * @throws SAXException
   */
  public static void main(String[] args) throws JSAPException {
    SimpleJSAP jsap = new SimpleJSAP("InfinispanFluDemo", "Parse the Influenze data and store in cache ",
        new Parameter[] {
            new FlaggedOption("InfinispanCfg", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'c',
                JSAP.NO_LONGFLAG, "Location of Infinispan config file"),
            new FlaggedOption("ifile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'i', JSAP.NO_LONGFLAG,
                "Location of influenza.dat"),
            new FlaggedOption("pfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'p', JSAP.NO_LONGFLAG,
                "location of influenza_aa.dat."),
            new FlaggedOption("count", JSAP.INTEGER_PARSER, "-1", JSAP.NOT_REQUIRED, 'l', JSAP.NO_LONGFLAG,
                "Number of records to load from file"),
            new Switch("query", 'q', "true", "Enable query cli"),
            new Switch("randomquery", 'r', "randomquery",
                "Randomly query the influenza to test that the cache is fully populated"),
            new FlaggedOption("nfile", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'n', JSAP.NO_LONGFLAG,
                "Location of influenza_na.dat") });
    if (jsap.messagePrinted())
      System.exit(1);

    JSAPResult config = jsap.parse(args);
    InfluenzaDataLoader fluDemo = new InfluenzaDataLoader();
    try {
      fluDemo.createCache(config.getString("InfinispanCfg"));
      fluDemo.populateCache(config);
    } catch (SAXException e1) {
View Full Code Here

TOP

Related Classes of com.martiansoftware.jsap.SimpleJSAP

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.