Example usage for java.lang Package getImplementationVersion

List of usage examples for java.lang Package getImplementationVersion

Introduction

In this page you can find the example usage for java.lang Package getImplementationVersion.

Prototype

public String getImplementationVersion() 

Source Link

Document

Return the version of this implementation.

Usage

From source file:DcmRcv.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("NULL|3DES|AES");
    OptionBuilder.hasArg();/*from   www .java 2 s. co  m*/
    OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption");
    opts.addOption(OptionBuilder.create("tls"));

    opts.addOption("nossl2", false, "disable acceptance of SSLv2Hello TLS handshake");
    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"));

    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.");

    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("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;
}

From source file:org.dcm4che2.tool.dcmwado.DcmWado.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();
    OptionBuilder.withArgName("suid:Suid:iuid");
    OptionBuilder.hasArgs(3);// www  . jav  a 2s  .c o  m
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription(
            "Retrieve object with given Study " + "Instance UID, Series Instance UID and SOP Instance UID.");
    opts.addOption(OptionBuilder.create("uid"));

    OptionBuilder.withArgName("Suid:iuid");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("Series Instance UID and SOP Instance UID "
            + "of the presentation state storage object to be applied to the " + "image.");
    opts.addOption(OptionBuilder.create("pr"));

    opts.addOption("dcm", false, "Request DICOM object. (MIME type: application/dicom)");
    opts.addOption("jpeg", false, "Request JPEG image. (MIME type: image/jpeg)");
    opts.addOption("gif", false, "Request GIF image. (MIME type: image/gif)");
    opts.addOption("png", false, "Request PNG image. (MIME type: image/png)");
    opts.addOption("jp2", false, "Request JPEG 2000 image. (MIME type: image/jp2)");
    opts.addOption("mpeg", false, "Request MPEG video. (MIME type: video/mpeg)");
    opts.addOption("txt", false, "Request plain text document. (MIME type: text/plain)");
    opts.addOption("html", false, "Request HTML document. (MIME type: text/html)");
    opts.addOption("xml", false, "Request XML document. (MIME type: text/xml)");
    opts.addOption("rtf", false, "Request RTF document. (MIME type: text/rtf)");
    opts.addOption("pdf", false, "Request PDF document. (MIME type: application/pdf)");
    opts.addOption("cda1", false,
            "Request CDA Level 1 document. " + "(MIME type: application/x-hl7-cda-level-one+xml)");

    OptionBuilder.withArgName("type");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Request document with the specified MIME type."
            + "Alternative MIME types can be specified by additional -mime options.");
    opts.addOption(OptionBuilder.create("mime"));

    OptionBuilder.withArgName("uid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Returned object shall be encoded with "
            + "the specified Transfer Syntax. Alternative Transfer Syntaxes "
            + "can be specified by additional -ts options.");
    opts.addOption(OptionBuilder.create("ts"));

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Returned object shall be encoded with " + "specified Character set. Alternative Character sets "
                    + "can be specified by additional -charset options.");
    opts.addOption(OptionBuilder.create("charset"));

    opts.addOption("anonymize", false,
            "Remove all patient identification" + "information from returned DICOM Object");

    OptionBuilder.withArgName("type");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Burn in patient information" + "(-annotation=patient) and/or technique information "
                    + "(-annotation=technique) in returned pixel data.");
    opts.addOption(OptionBuilder.create("annotation"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Maximal number of pixel rows in returned image.");
    opts.addOption(OptionBuilder.create("rows"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Maximal number of pixel columns in returned image.");
    opts.addOption(OptionBuilder.create("columns"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("Return single frame with that number " + "within a multi-frame image object.");
    opts.addOption(OptionBuilder.create("frame"));

    OptionBuilder.withArgName("x1:y1:x2:y2");
    OptionBuilder.hasArgs(4);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("Return rectangular region of image "
            + "matrix specified by top left (x1,y1) and bottom right (x2,y2) "
            + "corner in relative coordinates within the range 0.0 to 1.0.");
    opts.addOption(OptionBuilder.create("window"));

    OptionBuilder.withArgName("center/width");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator('/');
    OptionBuilder
            .withDescription("Specifies center and width of the " + "VOI window to be applied to the image.");
    opts.addOption(OptionBuilder.create("window"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Quality of the image to be returned " + "within the range 1 to 100, 100 being the best quality.");
    opts.addOption(OptionBuilder.create("quality"));

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Directory to store retrieved objects, " + "working directory by default");
    opts.addOption(OptionBuilder.create("dir"));

    OptionBuilder.withArgName("dirpath");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Directory to store retrieved objects, " + "working directory by default");
    opts.addOption(OptionBuilder.create("dir"));

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Store retrieved object to specified file, "
            + "use SOP Instance UID + format specific file extension as " + "file name by default.");
    opts.addOption(OptionBuilder.create("o"));

    opts.addOption("nostore", false, "Do not store retrieved objects to files.");
    opts.addOption("nokeepalive", false, "Close TCP connection after each response.");
    opts.addOption("noredirect", false, "Disable HTTP redirects.");

    OptionBuilder.withArgName("kB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Size of byte buffer in KB " + "used for copying the retrieved object to disk, 8 KB by default.");
    opts.addOption(OptionBuilder.create("buffersize"));

    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 (MissingOptionException e) {
        exit("dcmwado: Missing required option " + e.getMessage());
        throw new RuntimeException("unreachable");
    } catch (ParseException e) {
        exit("dcmwado: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmWado.class.getPackage();
        System.out.println("dcmwado v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().isEmpty()) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }
    int narg = cl.getArgList().size();
    if (narg == 0)
        exit("Missing url of WADO server");
    if (narg == 1) {
        if (!cl.hasOption("uid")) {
            exit("You must either option -uid <uids> or <file>|<directory> specify");
        }
    } else {
        if (cl.hasOption("uid")) {
            exit("You may not specify option -uid <uids> together with " + "<file>|<directory>.");
        }
    }
    return cl;
}

From source file:org.dcm4che2.tool.dcmof.DcmOF.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();//from   w w w .j a  v a  2s  .  c o m
    OptionBuilder.withDescription("set device name, use DCMOF 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("Activate MWL SCP, providing MWL Items stored in specified directory.");
    opts.addOption(OptionBuilder.create("mwl"));

    OptionGroup mpps = new OptionGroup();
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Activate MPPS SCP, storing received MPPS in specified directory.");
    mpps.addOption(OptionBuilder.create("mpps"));
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Activate MPPS SCP, storing XML received MPPS in specified directory in XML format.");
    mpps.addOption(OptionBuilder.create("mppsxml"));
    opts.addOptionGroup(mpps);

    OptionGroup ian = new OptionGroup();
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Activate IAN SCP, storing received IAN in specified directory.");
    ian.addOption(OptionBuilder.create("ian"));
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("Activate IAN SCP, storing received IAN in specified directory in XML format.");
    ian.addOption(OptionBuilder.create("ianxml"));
    opts.addOptionGroup(ian);

    OptionGroup scn = new OptionGroup();
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Activate SCN SCP, storing received SCN in specified directory.");
    scn.addOption(OptionBuilder.create("scn"));
    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("Activate SCN SCP, storing received SCN in specified directory in XML format.");
    scn.addOption(OptionBuilder.create("scnxml"));
    opts.addOptionGroup(scn);

    opts.addOption("c", "compact", false, "suppress additional whitespaces in XML output");
    opts.addOption("C", "comments", false, "include attribute names as comments in XML output");

    OptionGroup ts = new OptionGroup();
    OptionBuilder.withDescription("accept only default Transfer Syntax.");
    ts.addOption(OptionBuilder.create("defts"));
    OptionBuilder.withDescription("accept Explict VR Big Endian Transfer Syntax.");
    ts.addOption(OptionBuilder.create("bigendian"));
    opts.addOptionGroup(ts);

    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("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("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"));

    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("dcmof: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption("V")) {
        Package p = DcmOF.class.getPackage();
        System.out.println("dcmof 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;
}

From source file:org.dcm4che2.tool.dcmmwl.DcmMWL.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*from ww w  . ja v a2 s  . c o m*/
    OptionBuilder.withDescription("set device name, use DCMMWL by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("aet[@host]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "set AET and local address of local " + "Application Entity, use device name and pick up any valid "
                    + "local address to bind the socket by default");
    opts.addOption(OptionBuilder.create("L"));

    OptionBuilder.withArgName("username");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "enable User Identity Negotiation with specified username and " + " optional passcode");
    opts.addOption(OptionBuilder.create("username"));

    OptionBuilder.withArgName("passcode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "optional passcode for User Identity Negotiation, " + "only effective with option -username");
    opts.addOption(OptionBuilder.create("passcode"));

    opts.addOption("uidnegrsp", false,
            "request positive User Identity Negotation response, " + "only effective with option -username");

    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_1.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"));

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");
    opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching.");
    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("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("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-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("timeout in ms for receiving A-RELEASE-RP, 5s by default");
    opts.addOption(OptionBuilder.create("releaseTO"));

    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("[seq/]attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription(
            "specify matching key. attr can be " + "specified by name or tag value (in hex), e.g. PatientName "
                    + "or 00100010. Attributes in nested Datasets can "
                    + "be specified by preceding the name/tag value of "
                    + "the sequence attribute, e.g. 00400100/00400009 "
                    + "for Scheduled Procedure Step ID in the Scheduled " + "Procedure Step Sequence.");
    opts.addOption(OptionBuilder.create("q"));

    OptionBuilder.withArgName("date");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching SPS start date " + "(range). Shortcut for -q00400100/00400002=<date>.");
    opts.addOption(OptionBuilder.create("date"));

    OptionBuilder.withArgName("time");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching SPS start time " + "(range). Shortcut for -q00400100/00400003=<time>.");
    opts.addOption(OptionBuilder.create("time"));

    OptionBuilder.withArgName("modality");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("specify matching Modality. Shortcut " + "for -q00400100/00080060=<modality>.");
    opts.addOption(OptionBuilder.create("mod"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching Scheduled Station AE " + "title. Shortcut for -q00400100/00400001=<aet>.");
    opts.addOption(OptionBuilder.create("aet"));

    OptionBuilder.withArgName("attr");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "specify additional return key. attr can " + "be specified by name or tag value (in hex).");
    opts.addOption(OptionBuilder.create("r"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "cancel query after receive of specified " + "number of responses, no cancel by default");
    opts.addOption(OptionBuilder.create("C"));

    opts.addOption("lowprior", false, "LOW priority of the C-FIND operation, MEDIUM by default");
    opts.addOption("highprior", false, "HIGH priority of the C-FIND operation, MEDIUM by default");
    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("dcmmwl: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmMWL.class.getPackage();
        System.out.println("dcmqr v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 1) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}

From source file:org.psystems.dicomweb.DcmRcv.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();//from   ww  w . j a  v  a2s .c  o m
    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.");

    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("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;
}

From source file:org.psystems.dicom.daemon.DcmRcvOriginal.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*w  w  w.  j a  va2  s . c  o  m*/
    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.");

    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("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 = DcmRcvOriginal.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;
}

From source file:org.dcm4che2.tool.dcmhpqr.DcmHPQR.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*from   w  w  w .j a  v a 2s  . c om*/
    OptionBuilder.withDescription("set device name, use DCMHPQR by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("aet[@host]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "set AET and local address of local " + "Application Entity, use device name and pick up any valid "
                    + "local address to bind the socket by default");
    opts.addOption(OptionBuilder.create("L"));

    OptionBuilder.withArgName("username");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "enable User Identity Negotiation with specified username and " + " optional passcode");
    opts.addOption(OptionBuilder.create("username"));

    OptionBuilder.withArgName("passcode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "optional passcode for User Identity Negotiation, " + "only effective with option -username");
    opts.addOption(OptionBuilder.create("passcode"));

    opts.addOption("uidnegrsp", false,
            "request positive User Identity Negotation response, " + "only effective with option -username");

    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_1.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"));

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");
    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("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("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-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("timeout in ms for receiving A-RELEASE-RP, 5s by default");
    opts.addOption(OptionBuilder.create("releaseTO"));

    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("[seq/]attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription(
            "specify matching key. attr can be " + "specified by name or tag value (in hex), e.g. PatientName "
                    + "or 00100010. Attributes in nested Datasets can "
                    + "be specified by preceding the name/tag value of "
                    + "the sequence attribute, e.g. 0072000C/00080060 "
                    + "for Modality in the Hanging Protocol Definition " + "Sequence.");
    opts.addOption(OptionBuilder.create("q"));

    OptionBuilder.withArgName("Modality");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("specify matching Modality. Shortcut " + "for -q0072000C/00080060=<modality>.");
    opts.addOption(OptionBuilder.create("mod"));

    OptionBuilder.withArgName("Laterality");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify matching Laterality. Shortcut for -q0072000C/00200060=<lat>.");
    opts.addOption(OptionBuilder.create("lat"));

    OptionBuilder.withArgName("AnatomicRegion");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching Anatomic Region Sequence Code Value and Coding Scheme Designator. "
                    + "Code Value and Coding Scheme Designer are separated by ':'. For example, T1234:DCM4CHE.");
    opts.addOption(OptionBuilder.create("ar"));

    OptionBuilder.withArgName("ProcedureCode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching Procedure Code Sequence Code Value and Coding Scheme Designator. "
                    + "Code Value and Coding Scheme Designer are separated by ':'. For example, T1234:DCM4CHE.");
    opts.addOption(OptionBuilder.create("pc"));

    OptionBuilder.withArgName("ReasonCode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching Reason for Requested Procedure Sequence Code Value and Coding Scheme Designator. "
                    + "Code Value and Coding Scheme Designer are separated by ':'. For example, T1234:DCM4CHE.");
    opts.addOption(OptionBuilder.create("rfrp"));

    OptionBuilder.withArgName("HPUserIDCode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "specify matching HP User ID Code Sequence Code Value and Coding Scheme Designator. "
                    + "Code Value and Coding Scheme Designer are separated by ':'. For example, T1234:DCM4CHE.");
    opts.addOption(OptionBuilder.create("user"));

    OptionBuilder.withArgName("attr");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "specify additional return key. attr can be specified by name or tag value (in hex).");
    opts.addOption(OptionBuilder.create("r"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "cancel query after receive of specified number of responses, no cancel by default");
    opts.addOption(OptionBuilder.create("C"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("retrieve matching objects to specified move destination.");
    opts.addOption(OptionBuilder.create("dest"));

    opts.addOption("lowprior", false, "LOW priority of the C-FIND/C-MOVE operation, MEDIUM by default");
    opts.addOption("highprior", false, "HIGH priority of the C-FIND/C-MOVE operation, MEDIUM by default");
    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("dcmhp: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmHPQR.class.getPackage();
        System.out.println("dcmhpqr v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 1) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}

From source file:com.codecrate.shard.ui.ShardApplicationDescriptor.java

public ShardApplicationDescriptor() {
    Package pkg = ShardApplicationDescriptor.class.getPackage();
    //String specVersion = pkg.getSpecificationVersion();
    String version = pkg.getImplementationVersion();
    setVersion(version);//from  ww w .j a va 2  s.  co m
}

From source file:org.rhq.enterprise.gui.common.framework.ServerInfoUIBean.java

private String getManifestVersion(Class clazz) {
    String version = null;//from   w  w  w.j  a  v a  2s.c  om
    try {
        Package pkg = clazz.getPackage();
        if (pkg != null) {
            version = pkg.getImplementationVersion();
            if (version == null) {
                version = pkg.getSpecificationVersion();
            }
        }
    } catch (Exception e) {
        log.error("Error while looking up manifest version for " + clazz + ".", e);
    }
    return version;
}

From source file:org.fusesource.mop.commands.Fork.java

/**
 * Forks a new child JVM and executes the remaining arguments as a child MOP
 * process/*  w  ww  . jav a2 s  . c om*/
 */
@Command
public void fork(MOP mop, LinkedList<String> args) throws Exception {
    LOG.info("forking MOP with " + args);

    // TODO we could try find a mop jar on the URL class loader?

    Package aPackage = Package.getPackage("org.fusesource.mop");
    String version = aPackage.getImplementationVersion();
    if (version == null) {
        version = aPackage.getSpecificationVersion();
    }
    LOG.debug("mop package version: " + version);

    // TODO LATEST/RELEASE don't tend to work?
    /*
     * if (version == null) { version = "RELEASE"; }
     */
    String classpath;
    if (version != null) {
        ArtifactId mopArtifactId = mop.parseArtifactId("org.fusesource.mop:mop-core:" + version);
        mop.setTransitive(false);
        mop.setArtifactIds(Arrays.asList(mopArtifactId));
        classpath = mop.classpath();
    } else {
        classpath = System.getProperty("java.class.path");
        if (classpath == null || classpath.length() == 0) {
            throw new Exception("no java.class.path system property available!");
        }
    }
    if (isWindows() && classpath.contains(" ")) {
        classpath = "\"" + classpath + "\"";
    }

    List<String> newArgs = new ArrayList<String>();
    String javaExe = "java";
    if (isWindows()) {
        javaExe += ".exe";
    }
    newArgs.add(javaExe);

    //Propagate repository props to the forked process:
    for (Entry<String, String> entry : mop.getRepository().getRepositorySystemProps().entrySet()) {
        mop.setSystemProperty(entry.getKey(), entry.getValue());
    }

    mop.addSystemProperties(newArgs);
    newArgs.add("-D" + MOP.MOP_WORKING_DIR_SYSPROPERTY + "=" + mop.getWorkingDirectory().getAbsolutePath());

    newArgs.add("-cp");
    newArgs.add(classpath);
    newArgs.add(MOP.class.getName());
    newArgs.addAll(args);

    LOG.debug("About to execute: " + newArgs);
    mop.exec(newArgs);
}