示例#1
0
  private void createOptions() {
    options = new Options();
    options.addOption("h", "help", false, "prints this message");
    options.addOption(
        "v", "validate", false, "parses xml input file for validation (without simulation)");
    options.addOption(
        "w",
        "write xsd",
        false,
        "writes xsd file to output (for convenience/lookup schema definitions)");
    options.addOption(
        "l",
        "log",
        false,
        "writes the file \"log4j.properties\" to file to adjust the logging properties on an individual level");

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    ProjectMetaData.getInstance();
    OptionBuilder.withDescription(
        "movsim main configuration file (ending \""
            + ProjectMetaData.getMovsimConfigFileEnding()
            + "\" will be added automatically if not provided.");
    final Option xmlSimFile = OptionBuilder.create("f");
    options.addOption(xmlSimFile);

    OptionBuilder.withArgName("directory");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("argument is the output path relative to calling directory");
    final Option outputPathOption = OptionBuilder.create("o");
    options.addOption(outputPathOption);
  }
    /** Set up the command line options. */
    protected void setupOptions(Options opts) {
      // boolean options
      opts.addOption("a", "verify", false, "verify generated signatures>");

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("dir");
      OptionBuilder.withLongOpt("key-directory");
      OptionBuilder.withDescription("directory to find key files (default '.').");
      opts.addOption(OptionBuilder.create('D'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("time/offset");
      OptionBuilder.withLongOpt("start-time");
      OptionBuilder.withDescription("signature starting time (default is now - 1 hour)");
      opts.addOption(OptionBuilder.create('s'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("time/offset");
      OptionBuilder.withLongOpt("expire-time");
      OptionBuilder.withDescription("signature expiration time (default is start-time + 30 days).");
      opts.addOption(OptionBuilder.create('e'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("outfile");
      OptionBuilder.withDescription("file the signed rrset is written to.");
      opts.addOption(OptionBuilder.create('f'));
    }
 private static Option createOptionDepthOption() {
   OptionBuilder.withLongOpt("depth");
   OptionBuilder.withDescription("Number of options on either side of the strike price");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(OPTION_DEPTH_OPT);
 }
 private static Option createNumContractsOption() {
   OptionBuilder.withLongOpt("contracts");
   OptionBuilder.withDescription("Number of contracts for each option");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_CONTRACTS_OPT);
 }
 private static Option createNumMembersOption() {
   OptionBuilder.withLongOpt("members");
   OptionBuilder.withDescription("Number underlyers from index to include");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_INDEX_MEMBERS_OPT);
 }
 private static Option createPortfolioNameOption() {
   OptionBuilder.withLongOpt("portfolio");
   OptionBuilder.withDescription("The name of the portfolio to create/update");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(PORTFOLIO_NAME_OPT);
 }
  /** Build command line options object. */
  private static Options buildOptions() {

    Options opts = new Options();

    String helpMsg = "Print this message.";
    Option help = new Option(HELP_OPTION, helpMsg);
    opts.addOption(help);

    String consumerKeyMsg = "You API Consumer Key.";
    OptionBuilder.withArgName("consumerKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION);
    opts.addOption(consumerKey);

    String consumerSecretMsg = "You API Consumer Secret.";
    OptionBuilder.withArgName("consumerSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerSecretMsg);
    Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION);
    opts.addOption(consumerSecret);

    String accessTokenMsg = "You OAuth Access Token.";
    OptionBuilder.withArgName("accessToken");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(accessTokenMsg);
    Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION);
    opts.addOption(accessToken);

    String tokenSecretMsg = "You OAuth Access Token Secret.";
    OptionBuilder.withArgName("accessTokenSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(tokenSecretMsg);
    Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION);
    opts.addOption(accessTokenSecret);

    String idMsg = "ID of the user whose profile is to be fetched.";
    OptionBuilder.withArgName("id");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(ID_OPTION);
    opts.addOption(id);

    return opts;
  }
示例#8
0
  private static Options createOptions() {
    Options options = new Options();

    OptionBuilder.withDescription("Show this help");
    options.addOption(OptionBuilder.create(CMD_HELP));

    OptionBuilder.withArgName("port");
    OptionBuilder.hasOptionalArg();
    OptionBuilder.withDescription("The port to run the Nutch Server. Default port 8081");
    options.addOption(OptionBuilder.create(CMD_PORT));

    OptionBuilder.withArgName("host");
    OptionBuilder.hasOptionalArg();
    OptionBuilder.withDescription("The host to bind the Nutch Server to. Default is localhost.");
    options.addOption(OptionBuilder.create(CMD_PORT));

    return options;
  }
  @Override
  public Options createOptions() {

    Option useSpring = OptionBuilder.create("spring");

    Options options = new Options();
    options.addOption(useSpring);

    return options;
  }
  /**
   * Build command-line options and descriptions
   *
   * @return command line options
   */
  public static Options buildOptions() {
    Options options = new Options();

    // Build in/output file arguments, which are required, but there is no
    // addOption method that can specify this
    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("outputFilename");
    options.addOption(OptionBuilder.create("o"));

    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("inputFilename");
    options.addOption(OptionBuilder.create("i"));

    options.addOption("p", "processor", true, "");
    options.addOption("v", "verbose", false, "");
    options.addOption("h", "help", false, "");

    return options;
  }
 private void addOptions(
     boolean required, Options options, Set<Entry<String, ArgumentDescriptor>> entrySet) {
   for (Entry<String, ArgumentDescriptor> e : entrySet) {
     String argumentName = e.getKey();
     ArgumentDescriptor argumentDescriptor = e.getValue();
     Option option = OptionBuilder.create(argumentName);
     option.setRequired(required);
     String description = argumentDescriptor.getDescription();
     option.setDescription(createDescription(description, required));
     option.setArgs(1);
     options.addOption(option);
   }
 }
  /**
   * Builds the options.
   *
   * @return the options
   */
  private static Options buildOptions() {

    Options opts = new Options();

    String helpMsg = "Print this message.";
    Option help = new Option(HELP_OPTION, helpMsg);
    opts.addOption(help);

    String applicationKeyMsg = "You Application ID.";
    OptionBuilder.withArgName("appid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(applicationKeyMsg);
    Option applicationKey = OptionBuilder.create(APPLICATION_KEY_OPTION);
    opts.addOption(applicationKey);

    String queryMsg = "Search Query.";
    OptionBuilder.withArgName("query");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(queryMsg);
    Option query = OptionBuilder.create(QUERY_OPTION);
    opts.addOption(query);

    return opts;
  }
  /** Initializes {@link #options} with all information the options parser needs. */
  public OptionsConfiguration() {
    super();
    // w/ argument
    OptionBuilder.withDescription(OptionDescriptor.PATH_PREFIX.getDescription());
    OptionBuilder.withArgName("PATH");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.PATH_PREFIX.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.PATH_PREFIX.getShortOption()));
    OptionBuilder.withDescription(OptionDescriptor.INPUT_ENCODING.getDescription());
    OptionBuilder.withArgName("ENCODING");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.INPUT_ENCODING.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.INPUT_ENCODING.getShortOption()));
    OptionBuilder.withDescription(OptionDescriptor.OUTPUT_ENCODING.getDescription());
    OptionBuilder.withArgName("ENCODING");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.OUTPUT_ENCODING.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.OUTPUT_ENCODING.getShortOption()));

    // w/o argument
    options.addOption(
        OptionDescriptor.DEBUG.getShortOption(),
        OptionDescriptor.DEBUG.getLongOption(),
        false,
        OptionDescriptor.DEBUG.getDescription());
    options.addOption(
        OptionDescriptor.HELP.getShortOption(),
        OptionDescriptor.HELP.getLongOption(),
        false,
        OptionDescriptor.HELP.getDescription());
    options.addOption(
        OptionDescriptor.VERSION.getShortOption(),
        OptionDescriptor.VERSION.getLongOption(),
        false,
        OptionDescriptor.VERSION.getDescription());
  }
  /** Build command line options object. */
  private static Options buildOptions() {

    Options opts = new Options();

    String helpMsg = "Print this message.";
    Option help = new Option(HELP_OPTION, helpMsg);
    opts.addOption(help);

    String consumerKeyMsg = "You API Consumer Key.";
    OptionBuilder.withArgName("consumerKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION);
    opts.addOption(consumerKey);

    String consumerSecretMsg = "You API Consumer Secret.";
    OptionBuilder.withArgName("consumerSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerSecretMsg);
    Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION);
    opts.addOption(consumerSecret);

    String accessTokenMsg = "You OAuth Access Token.";
    OptionBuilder.withArgName("accessToken");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(accessTokenMsg);
    Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION);
    opts.addOption(accessToken);

    String tokenSecretMsg = "You OAuth Access Token Secret.";
    OptionBuilder.withArgName("accessTokenSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(tokenSecretMsg);
    Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION);
    opts.addOption(accessTokenSecret);

    String subjectMsg = "Subject of the invitation.";
    OptionBuilder.withArgName("subject");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(subjectMsg);
    Option subject = OptionBuilder.create(SUBJECT_OPTION);
    opts.addOption(subject);

    String messageMsg = "Content of the invitation.";
    OptionBuilder.withArgName("message");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(messageMsg);
    Option message = OptionBuilder.create(MESSAGE_OPTION);
    opts.addOption(message);

    String idMsg = "ID of the user to whom invitation has to be sent.";
    OptionBuilder.withArgName("id");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(ID_OPTION);
    opts.addOption(id);

    String emailMsg = "Email of the user to whom invitation has to be sent.";
    OptionBuilder.withArgName("email");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(emailMsg);
    Option email = OptionBuilder.create(EMAIL_OPTION);
    opts.addOption(email);

    String firstNameMsg = "First name of the user to whom invitation has to be sent.";
    OptionBuilder.withArgName("firstName");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(firstNameMsg);
    Option firstName = OptionBuilder.create(FIRST_NAME_OPTION);
    opts.addOption(firstName);

    String lastNameMsg = "Last name of the user to whom invitation has to be sent.";
    OptionBuilder.withArgName("lastName");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(lastNameMsg);
    Option lastName = OptionBuilder.create(LAST_NAME_OPTION);
    opts.addOption(lastName);

    String authHeaderMsg = "Auth Header of the user to whom invitation has to be sent.";
    OptionBuilder.withArgName("authHeader");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(authHeaderMsg);
    Option authHeader = OptionBuilder.create(AUTH_HEADER_OPTION);
    opts.addOption(authHeader);

    return opts;
  }
示例#15
0
 public static void main(String[] arguments) {
   final CommandLineParser parser = new PosixParser();
   final Options opts = new Options();
   CommandLine cmd = null;
   Pipeline.addLogHelpAndInputOptions(opts);
   Pipeline.addTikaOptions(opts);
   Pipeline.addOutputOptions(opts);
   Pipeline.addJdbcResourceOptions(
       opts, DEFAULT_JDBC_DRIVER, DEFAULT_DB_PROVIDER, DEFAULT_DATABASE);
   // entity annotator options setup
   opts.addOption("Q", "query-file", true, "file with SQL SELECT queries");
   OptionBuilder.withLongOpt("query");
   OptionBuilder.withArgName("SELECT");
   OptionBuilder.hasArgs();
   OptionBuilder.withDescription("one or more SQL SELECT queries");
   opts.addOption(OptionBuilder.create('q'));
   opts.addOption(
       "m", "entity-map", true, "name of the entity map file [" + DEFAULT_MAPPING_FILE + "]");
   opts.addOption(
       "n", "namespace", true, "namespace of the entity annotations [" + DEFAULT_NAMESPACE + "]");
   try {
     cmd = parser.parse(opts, arguments);
   } catch (final ParseException e) {
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == exit ==
   }
   final Logger l =
       Pipeline.loggingSetup(cmd, opts, "txtfnnl entities [options] <directory|files...>\n");
   // output options
   XmiWriter.Builder writer =
       Pipeline.configureWriter(cmd, XmiWriter.configure(Pipeline.ensureOutputDirectory(cmd)));
   // DB resource
   ExternalResourceDescription jdbcResource = null;
   try {
     jdbcResource =
         Pipeline.getJdbcConnectionResource(
             cmd, l, DEFAULT_JDBC_DRIVER, DEFAULT_DB_PROVIDER, DEFAULT_DATABASE);
   } catch (final ClassNotFoundException e) {
     System.err.println("JDBC resoruce setup failed:");
     System.err.println(e.toString());
     System.exit(1); // == EXIT ==
   } catch (ResourceInitializationException e) {
     System.err.println("JDBC resoruce setup failed:");
     System.err.println(e.toString());
     System.exit(1); // == EXIT ==
   }
   /* BEGIN entity annotator */
   final String queryFileName = cmd.getOptionValue('Q');
   final String entityMapPath = cmd.getOptionValue('m', DEFAULT_MAPPING_FILE);
   final String namespace = cmd.getOptionValue('n', DEFAULT_NAMESPACE);
   String[] queries = cmd.getOptionValues('q');
   File entityMap; // m
   if (queryFileName != null) {
     final File queryFile = new File(queryFileName);
     if (!queryFile.isFile() || !queryFile.canRead()) {
       System.err.print("cannot read query file ");
       System.err.println(queryFile);
       System.exit(1); // == EXIT ==
     }
     String[] fileQueries = null;
     try {
       fileQueries =
           IOUtils.read(new FileInputStream(queryFile), Pipeline.inputEncoding(cmd)).split("\n");
     } catch (final Exception e) {
       System.err.print("cannot read query file ");
       System.err.print(queryFile);
       System.err.print(":");
       System.err.println(e.getLocalizedMessage());
       System.exit(1); // == EXIT ==
     }
     if (queries == null || queries.length == 0) {
       queries = fileQueries;
     } else {
       final String[] tmp = new String[queries.length + fileQueries.length];
       System.arraycopy(queries, 0, tmp, 0, queries.length);
       System.arraycopy(fileQueries, 0, tmp, queries.length, fileQueries.length);
       queries = tmp;
     }
   }
   entityMap = new File(entityMapPath);
   if (!entityMap.isFile() || !entityMap.canRead()) {
     System.err.print("cannot read entity map file ");
     System.err.println(entityMapPath);
     System.exit(1); // == EXIT ==
   }
   if (queries == null || queries.length == 0) {
     queries = DEFAULT_SQL_QUERIES;
   }
   /* END entity annotator */
   try {
     final Pipeline pipeline = new Pipeline(2); // tika and known entity annotator
     KnownEntityAnnotator.Builder builder =
         KnownEntityAnnotator.configure(namespace, queries, entityMap, jdbcResource);
     pipeline.setReader(cmd);
     pipeline.configureTika(cmd);
     pipeline.set(1, Pipeline.multiviewEngine(builder.create()));
     pipeline.setConsumer(Pipeline.textEngine(writer.create()));
     pipeline.run();
     pipeline.destroy();
   } catch (final UIMAException e) {
     l.severe(e.toString());
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == EXIT ==
   } catch (final IOException e) {
     l.severe(e.toString());
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == EXIT ==
   }
   System.exit(0);
 }
示例#16
0
  private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set device name, use DCMRCV by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("NULL|3DES|AES");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption");
    opts.addOption(OptionBuilder.create("tls"));

    OptionGroup tlsProtocol = new OptionGroup();
    tlsProtocol.addOption(
        new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections"));
    tlsProtocol.addOption(
        new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections"));
    tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections"));
    tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections"));
    tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections"));
    opts.addOptionGroup(tlsProtocol);

    opts.addOption("noclientauth", false, "disable client authentification for TLS");

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default");
    opts.addOption(OptionBuilder.create("keystore"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("password for keystore file, 'secret' by default");
    opts.addOption(OptionBuilder.create("keystorepw"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "password for accessing the key in the keystore, keystore password by default");
    opts.addOption(OptionBuilder.create("keypw"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default");
    opts.addOption(OptionBuilder.create("truststore"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("password for truststore file, 'secret' by default");
    opts.addOption(OptionBuilder.create("truststorepw"));

    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "store received objects into files in specified directory <dir>."
            + " Do not store received objects by default.");
    opts.addOption(OptionBuilder.create("dest"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "file path or URL of properties for mapping Calling AETs to "
            + "sub-directories of the storage directory specified by "
            + "-dest, to separate the storage location dependend on "
            + "Calling AETs.");
    opts.addOption(OptionBuilder.create("calling2dir"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "file path or URL of properties for mapping Called AETs to "
            + "sub-directories of the storage directory specified by "
            + "-dest, to separate the storage location dependend on "
            + "Called AETs.");
    opts.addOption(OptionBuilder.create("called2dir"));

    OptionBuilder.withArgName("sub-dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "storage sub-directory used for Calling AETs for which no "
            + " mapping is defined by properties specified by "
            + "-calling2dir, 'OTHER' by default.");
    opts.addOption(OptionBuilder.create("callingdefdir"));

    OptionBuilder.withArgName("sub-dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "storage sub-directory used for Called AETs for which no "
            + " mapping is defined by properties specified by "
            + "-called2dir, 'OTHER' by default.");
    opts.addOption(OptionBuilder.create("calleddefdir"));

    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "register stored objects in cache journal files in specified directory <dir>."
            + " Do not register stored objects by default.");
    opts.addOption(OptionBuilder.create("journal"));

    OptionBuilder.withArgName("pattern");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "cache journal file path, with "
            + "'yyyy' will be replaced by the current year, "
            + "'MM' by the current month, 'dd' by the current date, "
            + "'HH' by the current hour and 'mm' by the current minute. "
            + "'yyyy/MM/dd/HH/mm' by default.");
    opts.addOption(OptionBuilder.create("journalfilepath"));

    opts.addOption("defts", false, "accept only default transfer syntax.");
    opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax.");
    opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data.");

    OptionGroup scRetrieveAET = new OptionGroup();
    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "Retrieve AE Title included in Storage Commitment "
            + "N-EVENT-REPORT in items of the Referenced SOP Sequence.");
    scRetrieveAET.addOption(OptionBuilder.create("scretraets"));
    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "Retrieve AE Title included in Storage Commitment "
            + "N-EVENT-REPORT outside of the Referenced SOP Sequence.");
    scRetrieveAET.addOption(OptionBuilder.create("scretraet"));
    opts.addOptionGroup(scRetrieveAET);

    opts.addOption(
        "screusefrom",
        false,
        "attempt to issue the Storage Commitment N-EVENT-REPORT on "
            + "the same Association on which the N-ACTION operation was "
            + "performed; use different Association for N-EVENT-REPORT by "
            + "default.");

    opts.addOption(
        "screuseto",
        false,
        "attempt to issue the Storage Commitment N-EVENT-REPORT on "
            + "previous initiated Association to the Storage Commitment SCU; "
            + "initiate new Association for N-EVENT-REPORT by default.");

    OptionBuilder.withArgName("port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "port of Storage Commitment SCU to connect to issue "
            + "N-EVENT-REPORT on different Association; 104 by default.");
    opts.addOption(OptionBuilder.create("scport"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "delay in ms for N-EVENT-REPORT-RQ to Storage Commitment SCU, " + "1s by default");
    opts.addOption(OptionBuilder.create("scdelay"));

    OptionBuilder.withArgName("retry");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "number of retries to issue N-EVENT-REPORT-RQ to Storage "
            + "Commitment SCU, 0 by default");
    opts.addOption(OptionBuilder.create("scretry"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "interval im ms between retries to issue N-EVENT-REPORT-RQ to"
            + "Storage Commitment SCU, 60s by default");
    opts.addOption(OptionBuilder.create("scretryperiod"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "maximum number of outstanding operations performed "
            + "asynchronously, unlimited by default.");
    opts.addOption(OptionBuilder.create("async"));

    opts.addOption(
        "pdv1",
        false,
        "send only one PDV in one P-Data-TF PDU, "
            + "pack command and data PDV in one P-DATA-TF PDU by default.");
    opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default");

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default");
    opts.addOption(OptionBuilder.create("connectTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default");
    opts.addOption(OptionBuilder.create("rspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default");
    opts.addOption(OptionBuilder.create("acceptTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "delay in ms for Socket close after sending A-ABORT, 50ms by default");
    opts.addOption(OptionBuilder.create("soclosedelay"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "delay in ms for DIMSE-RSP; useful for testing asynchronous mode");
    opts.addOption(OptionBuilder.create("rspdelay"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default");
    opts.addOption(OptionBuilder.create("requestTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default");
    opts.addOption(OptionBuilder.create("releaseTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "period in ms to check for outstanding DIMSE-RSP, 10s by default");
    opts.addOption(OptionBuilder.create("reaper"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default");
    opts.addOption(OptionBuilder.create("idleTO"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "maximal length in KB of received P-DATA-TF PDUs, 16KB by default");
    opts.addOption(OptionBuilder.create("rcvpdulen"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default");
    opts.addOption(OptionBuilder.create("sndpdulen"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB");
    opts.addOption(OptionBuilder.create("sorcvbuf"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB");
    opts.addOption(OptionBuilder.create("sosndbuf"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
        "minimal buffer size to write received object to file, 1KB by default");
    opts.addOption(OptionBuilder.create("bufsize"));

    opts.addOption("h", "help", false, "print this message");
    opts.addOption("V", "version", false, "print the version information and exit");
    CommandLine cl = null;
    try {
      cl = new GnuParser().parse(opts, args);
    } catch (ParseException e) {
      exit("dcmrcv: " + e.getMessage());
      throw new RuntimeException("unreachable");
    }
    if (cl.hasOption("V")) {
      Package p = DcmRcv.class.getPackage();
      System.out.println("dcmrcv v" + p.getImplementationVersion());
      System.exit(0);
    }
    if (cl.hasOption("h") || cl.getArgList().size() == 0) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
      System.exit(0);
    }
    return cl;
  }
  public static void main(String[] args) {
    Options options = new Options();

    Option inputOpt = OptionBuilder.create(IN);
    inputOpt.setArgName("INPUT");
    inputOpt.setDescription("Input CDO resource directory");
    inputOpt.setArgs(1);
    inputOpt.setRequired(true);

    Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS);
    inClassOpt.setArgName("CLASS");
    inClassOpt.setDescription("FQN of EPackage implementation class");
    inClassOpt.setArgs(1);
    inClassOpt.setRequired(true);

    Option repoOpt = OptionBuilder.create(REPO_NAME);
    repoOpt.setArgName("REPO_NAME");
    repoOpt.setDescription("CDO Repository name");
    repoOpt.setArgs(1);
    repoOpt.setRequired(true);

    options.addOption(inputOpt);
    options.addOption(inClassOpt);
    options.addOption(repoOpt);

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine commandLine = parser.parse(options, args);

      String repositoryDir = commandLine.getOptionValue(IN);
      String repositoryName = commandLine.getOptionValue(REPO_NAME);

      Class<?> inClazz =
          CdoQueryGetBranchStatements.class
              .getClassLoader()
              .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS));
      inClazz.getMethod("init").invoke(null);

      EmbeddedCDOServer server = new EmbeddedCDOServer(repositoryDir, repositoryName);
      try {
        server.run();
        CDOSession session = server.openSession();
        CDOTransaction transaction = session.openTransaction();
        Resource resource = transaction.getRootResource();
        {
          Runtime.getRuntime().gc();
          long initialUsedMemory =
              Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
          LOG.log(
              Level.INFO,
              MessageFormat.format(
                  "Used memory before query: {0}",
                  MessageUtil.byteCountToDisplaySize(initialUsedMemory)));
          LOG.log(Level.INFO, "Start query");
          long begin = System.currentTimeMillis();
          Set<TextElement> list = ASE2015JavaQueries.getCommentsTagContent(resource);
          long end = System.currentTimeMillis();
          LOG.log(Level.INFO, "End query");
          LOG.log(
              Level.INFO, MessageFormat.format("Query result contains {0} elements", list.size()));
          LOG.log(
              Level.INFO,
              MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin)));
          Runtime.getRuntime().gc();
          long finalUsedMemory =
              Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
          LOG.log(
              Level.INFO,
              MessageFormat.format(
                  "Used memory after query: {0}",
                  MessageUtil.byteCountToDisplaySize(finalUsedMemory)));
          LOG.log(
              Level.INFO,
              MessageFormat.format(
                  "Memory use increase: {0}",
                  MessageUtil.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory)));
        }

        transaction.close();
        session.close();
      } finally {
        server.stop();
      }
    } catch (ParseException e) {
      MessageUtil.showError(e.toString());
      MessageUtil.showError("Current arguments: " + Arrays.toString(args));
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("java -jar <this-file.jar>", options, true);
    } catch (Throwable e) {
      MessageUtil.showError(e.toString());
    }
  }
示例#18
0
  /**
   * Configures the program options
   *
   * @param options
   */
  private static void configureOptions(Options options) {

    Option transformationOpt = OptionBuilder.create(TRANSFORMATION);
    transformationOpt.setLongOpt(TRANSFORMATION_LONG);
    transformationOpt.setArgName("transformation.emftvm");
    transformationOpt.setDescription("URI of the ATL transformation file.");
    transformationOpt.setArgs(1);
    transformationOpt.setRequired(true);

    Option sourcemmOpt = OptionBuilder.create(SOURCE_PACKAGE);
    sourcemmOpt.setLongOpt(SOURCE_PACKAGE_LONG);
    sourcemmOpt.setArgName("source.ecore");
    sourcemmOpt.setDescription("FQN of the source package.");
    sourcemmOpt.setArgs(1);
    sourcemmOpt.setRequired(true);

    Option targetmmOpt = OptionBuilder.create(TARGET_PACKAGE);
    targetmmOpt.setLongOpt(TARGET_PACKAGE_LONG);
    targetmmOpt.setArgName("target.ecore");
    targetmmOpt.setDescription("FQN of the target package.");
    targetmmOpt.setArgs(1);
    targetmmOpt.setRequired(true);

    Option inputOpt = OptionBuilder.create(INPUT_MODEL);
    inputOpt.setLongOpt(INPUT_MODEL_LONG);
    inputOpt.setArgName("input.xmi");
    inputOpt.setDescription("URI of the input file.");
    inputOpt.setArgs(1);
    inputOpt.setRequired(true);

    Option outputOpt = OptionBuilder.create(OUTPUT_MODEL);
    outputOpt.setLongOpt(OUTPUT_MODEL_LONG);
    outputOpt.setArgName("output.xmi");
    outputOpt.setDescription("URI of the output file. Optional.");
    outputOpt.setArgs(1);

    Option recordsOpt = OptionBuilder.create(RECORDS_FILE);
    recordsOpt.setLongOpt(RECORDS_FILE_LONG);
    recordsOpt.setArgName("records.rec");
    recordsOpt.setDescription("URI of the records file.");
    recordsOpt.setArgs(1);
    recordsOpt.setRequired(true);

    Option recommendedMappersOption = OptionBuilder.create(RECOMMENDED_MAPPERS);
    recommendedMappersOption.setLongOpt(RECOMMENDED_MAPPERS_LONG);
    recommendedMappersOption.setArgName("mappers_hint");
    recommendedMappersOption.setDescription(
        "The recommended number of mappers (not strict, used only as a hint). Optional, defaults to 1. Excludes the use of '-n'.");
    recommendedMappersOption.setType(Number.class);
    recommendedMappersOption.setArgs(1);

    Option recordsPerMapperOption = OptionBuilder.create(RECORDS_PER_MAPPER);
    recordsPerMapperOption.setLongOpt(RECORDS_PER_MAPPER_LONG);
    recordsPerMapperOption.setArgName("recors_per_mapper");
    recordsPerMapperOption.setDescription(
        "Number of records to be processed by mapper. Optional, defaults to all records. Excludes the use of '-m'.");
    recordsPerMapperOption.setType(Number.class);
    recordsPerMapperOption.setArgs(1);

    OptionGroup mappersGroup = new OptionGroup();
    mappersGroup.addOption(recommendedMappersOption);
    mappersGroup.addOption(recordsPerMapperOption);

    Option quietOption = OptionBuilder.create(QUIET);
    quietOption.setLongOpt(QUIET_LONG);
    quietOption.setDescription(
        "Do not print any information about the transformation execution on the standard output. Optional, disabled by default.");
    quietOption.setArgs(0);

    Option verboseOption = OptionBuilder.create(VERBOSE);
    verboseOption.setLongOpt(VERBOSE_LONG);
    verboseOption.setDescription("Verbose mode. Optional, disabled by default.");
    verboseOption.setArgs(0);

    OptionGroup loggingGroup = new OptionGroup();
    loggingGroup.addOption(quietOption);
    loggingGroup.addOption(verboseOption);

    options.addOption(transformationOpt);
    options.addOption(sourcemmOpt);
    options.addOption(targetmmOpt);
    options.addOption(recordsOpt);
    options.addOption(inputOpt);
    options.addOption(outputOpt);
    options.addOptionGroup(loggingGroup);
    options.addOptionGroup(mappersGroup);
  }
示例#19
0
 /** * 添加工具执行时的选项 */
 private static void option() {
   // 添加 -f 选项
   OptionBuilder.withLongOpt("from");
   OptionBuilder.withDescription("new Apk file path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option fromOption = OptionBuilder.create("f");
   patchOptions.addOption(fromOption);
   allOptions.addOption(fromOption);
   // 添加 -t 选项
   OptionBuilder.withLongOpt("to");
   OptionBuilder.withDescription("old Apk file path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option toOption = OptionBuilder.create("t");
   patchOptions.addOption(toOption);
   allOptions.addOption(toOption);
   // 添加 -k 选项
   OptionBuilder.withLongOpt("keystore");
   OptionBuilder.withDescription("keystore path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option keystoreOption = OptionBuilder.create("k");
   patchOptions.addOption(keystoreOption);
   mergeOptions.addOption(keystoreOption);
   allOptions.addOption(keystoreOption);
   // 添加 -p 选项
   OptionBuilder.withLongOpt("kpassword");
   OptionBuilder.withDescription("keystore password.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("***");
   Option kPasswordOption = OptionBuilder.create("p");
   patchOptions.addOption(kPasswordOption);
   mergeOptions.addOption(kPasswordOption);
   allOptions.addOption(kPasswordOption);
   // 添加 -a 选项
   OptionBuilder.withLongOpt("alias");
   OptionBuilder.withDescription("alias.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("alias");
   Option aliasOption = OptionBuilder.create("a");
   patchOptions.addOption(aliasOption);
   mergeOptions.addOption(aliasOption);
   allOptions.addOption(aliasOption);
   // 添加 -e 选项
   OptionBuilder.withLongOpt("epassword");
   OptionBuilder.withDescription("entry password.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("***");
   Option ePasswordOption = OptionBuilder.create("e");
   patchOptions.addOption(ePasswordOption);
   mergeOptions.addOption(ePasswordOption);
   allOptions.addOption(ePasswordOption);
   // 添加 -o 选项
   OptionBuilder.withLongOpt("out");
   OptionBuilder.withDescription("output dir.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("dir");
   Option outOption = OptionBuilder.create("o");
   patchOptions.addOption(outOption);
   mergeOptions.addOption(outOption);
   allOptions.addOption(outOption);
   // 添加 -n 选项
   OptionBuilder.withLongOpt("name");
   OptionBuilder.withDescription("patch name.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("name");
   Option nameOption = OptionBuilder.create("n");
   patchOptions.addOption(nameOption);
   mergeOptions.addOption(nameOption);
   allOptions.addOption(nameOption);
   // 添加 -m 选项
   OptionBuilder.withLongOpt("merge");
   OptionBuilder.withDescription("path of .apatch files.");
   OptionBuilder.hasArg(false);
   OptionBuilder.withArgName("loc...");
   Option mergeOption = OptionBuilder.create("m");
   mergeOptions.addOption(mergeOption);
   allOptions.addOption(mergeOption);
 }
示例#20
0
  public static void main(String[] args) {
    Options options = new Options();

    Option inputOpt = OptionBuilder.create(IN);
    inputOpt.setArgName("INPUT");
    inputOpt.setDescription("Input model");
    inputOpt.setArgs(1);
    inputOpt.setRequired(true);

    Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS);
    inClassOpt.setArgName("CLASS");
    inClassOpt.setDescription("FQN of EPackage implementation class");
    inClassOpt.setArgs(1);
    inClassOpt.setRequired(true);

    options.addOption(inputOpt);
    options.addOption(inClassOpt);

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine commandLine = parser.parse(options, args);

      URI uri = URI.createFileURI(commandLine.getOptionValue(IN));

      Class<?> inClazz =
          XmiTraverser.class.getClassLoader().loadClass(commandLine.getOptionValue(EPACKAGE_CLASS));
      inClazz.getMethod("init").invoke(null);

      ResourceSet resourceSet = new ResourceSetImpl();
      resourceSet
          .getResourceFactoryRegistry()
          .getExtensionToFactoryMap()
          .put("xmi", new XMIResourceFactoryImpl());
      resourceSet
          .getResourceFactoryRegistry()
          .getExtensionToFactoryMap()
          .put("zxmi", new XMIResourceFactoryImpl());

      Resource resource = resourceSet.createResource(uri);

      Map<String, Object> loadOpts = new HashMap<String, Object>();
      resource.load(loadOpts);

      LOG.log(Level.INFO, "Start counting");
      int count = 0;
      long begin = System.currentTimeMillis();
      for (Iterator<EObject> iterator = resource.getAllContents();
          iterator.hasNext();
          iterator.next(), count++) ;
      long end = System.currentTimeMillis();
      LOG.log(Level.INFO, "End counting");
      LOG.log(Level.INFO, MessageFormat.format("Resource {0} contains {1} elements", uri, count));
      LOG.log(
          Level.INFO,
          MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin)));

      resource.unload();

    } catch (ParseException e) {
      MessageUtil.showError(e.toString());
      MessageUtil.showError("Current arguments: " + Arrays.toString(args));
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("java -jar <this-file.jar>", options, true);
    } catch (Throwable e) {
      MessageUtil.showError(e.toString());
    }
  }
示例#21
0
  /**
   * Parsing command line.
   *
   * @param args
   */
  private void parseCommandLine(String[] args) {
    Options ops = new Options();

    // help
    OptionBuilder.withLongOpt("help");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(rb.getString("OPT_HELP_MSG"));
    ops.addOption(OptionBuilder.create("h"));

    // input file
    OptionBuilder.withLongOpt("input");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(true);
    OptionBuilder.withDescription(rb.getString("OPT_INPUT_MSG"));
    ops.addOption(OptionBuilder.create("i"));

    // input file
    OptionBuilder.withLongOpt("charset");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription(rb.getString("OPT_CHARSET_MSG"));
    ops.addOption(OptionBuilder.create("ch"));

    OptionBuilder.withDescription(rb.getString("OPT_CSV_MSG"));
    ops.addOption(OptionBuilder.create("csv"));

    OptionBuilder.withDescription(rb.getString("OPT_TABTXT_MSG"));
    ops.addOption(OptionBuilder.create("tab"));

    OptionBuilder.withDescription(rb.getString("OPT_DOUBLE_QUOTES"));
    ops.addOption(OptionBuilder.create("dq"));

    BasicParser parser = new BasicParser();

    try {
      CommandLine cl = parser.parse(ops, args);
      delimiter = ",";
      if (cl.hasOption("tab")) {
        delimiter = "\t";
      } else if (cl.hasOption("csv")) {
        delimiter = ",";
      }

      if (cl.hasOption("dq")) {
        // double quotes
        flgDoubleQuotes = true;
      } else {
        flgDoubleQuotes = false;
      }
      if (cl.hasOption("h")) {
        showHelp(ops);
      }

      charset = "UTF-8";
      if (cl.hasOption("ch")) {
        String val = cl.getOptionValue("ch");
        if (val != null && val.length() > 0) {
          charset = val;
        }
      }

      if (cl.hasOption("i")) {
        String val = cl.getOptionValue("i");
        if (val != null && val.length() > 0) {
          readExcel(val);
        }
      } else {
        showHelp(ops);
      }
    } catch (ParseException e) {
      showHelp(ops);
    }
  }