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:de.thetaphi.forbiddenapis.CliMain.java

private void printVersion() {
    final Package pkg = this.getClass().getPackage();
    logInfo(String.format(Locale.ENGLISH, "%s %s", pkg.getImplementationTitle(),
            pkg.getImplementationVersion()));
}

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

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();//www .j av a 2 s. c om
    OptionBuilder.withDescription("set device name, use DCMSND by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set AET, local address and listening port 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"));

    opts.addOption("ts1", false,
            "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with "
                    + "Explicit VR Little Endian TS in one PC.");

    opts.addOption("fileref", false,
            "send objects without pixel data, but with a reference to "
                    + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax "
                    + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive.");

    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_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("aet@host:port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("request storage commitment of (successfully) sent objects "
            + "afterwards in new association to specified remote " + "Application Entity");
    opts.addOption(OptionBuilder.create("stgcmtae"));

    opts.addOption("stgcmt", false,
            "request storage commitment of (successfully) sent objects " + "afterwards in same association");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding operations it may invoke "
            + "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("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 closing the listening socket, " + "1000ms by default");
    opts.addOption(OptionBuilder.create("shutdowndelay"));

    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("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default");
    opts.addOption(OptionBuilder.create("bufsize"));

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

From source file:org.springframework.security.config.SecurityNamespaceHandler.java

public SecurityNamespaceHandler() {
    String coreVersion = SpringSecurityCoreVersion.getVersion();

    Package pkg = SpringSecurityCoreVersion.class.getPackage();

    if (pkg == null || coreVersion == null) {
        logger.info("Couldn't determine package version information.");
        return;/*from  w  w w.j ava 2  s  .c  om*/
    }

    String version = pkg.getImplementationVersion();
    logger.info("Spring Security 'config' module version is " + version);

    if (version.compareTo(coreVersion) != 0) {
        logger.error(
                "You are running with different versions of the Spring Security 'core' and 'config' modules");
    }
}

From source file:com.quinsoft.zeidon.standardoe.JavaObjectEngine.java

/**
 * Instantiates a Java Object Engine using the options specified.
 *
 * @param options//from w ww . j  av  a  2  s.c om
 */
public JavaObjectEngine(JavaOeConfiguration options) {
    ZeidonLogger logger = options.getZeidonLogger();
    zeidonHomeDir = options.getHomeDirectory();
    domainClassLoader = options.getDomainClassLoader();
    threadPool = options.getActivateThreadPool();
    zeidonPreferencesFactory = options.getPreferencesFactory();
    uuidGenerator = options.getUuidGenerator();
    oeListener = options.getObjectEngineListener();

    Package _package = this.getClass().getPackage();
    String version = _package.getImplementationVersion();
    String builtDate = _package.getImplementationTitle();
    logger.info("Zeidon JOE Version: %s  Build Date: %s", version, builtDate);
    logger.info("classpath = %s", getClassPath(logger));
    logger.info("User.dir = %s", System.getProperty("user.dir"));

    // Generate a UUID as a task ID.
    id = uuidGenerator.generate().toString();

    // Create HashMap with weak values so that tasks will be automatically GC'd when they are no longer being used.
    taskList = new MapMaker().concurrencyLevel(10).weakValues().makeMap();
    persistentTaskList = options.getPersistentTaskCacheMap();

    applicationList = new ApplicationList(zeidonHomeDir, logger);
    systemTask = createTask(ObjectEngine.ZEIDON_SYSTEM_APP_NAME, true, ObjectEngine.ZEIDON_SYSTEM_APP_NAME);
    oeListener.setObjectEngine(this);

    // Check to see if we should start the browser.
    String startBrowser = JoeUtils.getEnvProperty("zeidon.start.browser");
    if (StringUtils.isBlank(startBrowser))
        startBrowser = systemTask.readZeidonConfig("Browser", "Start", "");
    else
        // Log a message in case the ENVVAR overrides the value from zeidon.ini
        logger.info("startBrowser indicator is from zeidon.start.browser: %s", startBrowser);

    if (!StringUtils.isBlank(startBrowser) && startBrowser.toUpperCase().startsWith("Y"))
        startBrowser();

    assert logAssertMessage(systemTask); // Write a message to the log if assertions are on.
}

From source file:com.digium.respoke.Respoke.java

private String getSDKHeader() {
    Package pkg = getClass().getPackage();
    String javaVersion = String.format("Java/%s", System.getProperty("java.version"));
    String osVersion = String.format("%s %s", System.getProperty("os.name"), System.getProperty("os.version"));
    String packageVersion = String.format("%s/%s", pkg.getImplementationTitle(),
            pkg.getImplementationVersion());

    return String.format("%s (%s) %s", packageVersion, osVersion, javaVersion);
}

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

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

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

    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set AET, local address and listening port 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"));

    opts.addOption("ts1", false,
            "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with "
                    + "Explicit VR Little Endian TS in one PC.");

    opts.addOption("fileref", false,
            "send objects without pixel data, but with a reference to "
                    + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax "
                    + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive.");

    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_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("aet@host:port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("request storage commitment of (successfully) sent objects "
            + "afterwards in new association to specified remote " + "Application Entity");
    opts.addOption(OptionBuilder.create("stgcmtae"));

    opts.addOption("stgcmt", false,
            "request storage commitment of (successfully) sent objects " + "afterwards in same association");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding operations it may invoke "
            + "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("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 closing the listening socket, " + "1000ms by default");
    opts.addOption(OptionBuilder.create("shutdowndelay"));

    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("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default");
    opts.addOption(OptionBuilder.create("bufsize"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for rescan source folder. Sended file removed.");
    opts.addOption(OptionBuilder.create("rescan"));

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

From source file:it.crs4.seal.read_sort.MergeAlignments.java

private void writeSamHeader(OutputStream rawOut) throws IOException {
    Writer out = new BufferedWriter(new OutputStreamWriter(rawOut));
    out.write("@HD\tVN:1.0\tSO:" + sortOrder + "\n");

    // prep @SQ format string
    StringBuilder formatBuilder = new StringBuilder(50);
    formatBuilder.append("@SQ\tSN:%s\tLN:%d");

    if (genomeAssemblyId != null)
        formatBuilder.append("\tAS:").append(genomeAssemblyId);
    if (referenceRootPath != null)
        formatBuilder.append("\tUR:").append(referenceRootPath.toUri());
    if (generatedMd5)
        formatBuilder.append("\tM5:%s");

    formatBuilder.append("\n");

    String format = formatBuilder.toString();
    if (generatedMd5) {
        for (BwaRefAnnotation.Contig c : refAnnotation)
            out.write(String.format(format, c.getName(), c.getLength(), checksums.getChecksum(c.getName())));
    } else {/*from  ww  w .j  a v a  2s  .com*/
        for (BwaRefAnnotation.Contig c : refAnnotation)
            out.write(String.format(format, c.getName(), c.getLength()));
    }

    // @PG:  Seal name and version
    String version = "not available";
    Package pkg = this.getClass().getPackage();
    if (pkg != null && pkg.getImplementationVersion() != null)
        version = pkg.getImplementationVersion();
    else
        log.warn("Could not get package version");

    out.write("@PG\tID:seal\tVN:" + version + "\n");

    // @RG, if provided
    if (!readGroupFields.isEmpty()) {
        StringBuilder rgBuilder = new StringBuilder("@RG");
        for (Map.Entry<String, String> pair : readGroupFields.entrySet())
            rgBuilder.append("\t").append(pair.getKey()).append(":").append(pair.getValue());
        rgBuilder.append("\n");

        out.write(rgBuilder.toString());
    }

    out.flush();
}

From source file:org.dcm4che2.tool.dcmgpwl.DcmGPWL.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*  w  ww  . j  a va 2  s.co  m*/
    OptionBuilder.withDescription("set device name, use DCMGPWL 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("metasop", false, "offer General Purpose Worklist Management Meta SOP Class.");
    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("status");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("match/set GP-SPS/GP-PPS to specified <status>");
    opts.addOption(OptionBuilder.create("status"));

    OptionBuilder.withArgName("iuid:tuid");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription(
            "modify status of GP-SPS with SOP Instance UID <iuid> " + "using Transaction UID <tuid>.");
    opts.addOption(OptionBuilder.create("action"));

    OptionBuilder.withArgName("iuid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("create GP-PPS with SOP Instance UID <iuid>.");
    opts.addOption(OptionBuilder.create("createpps"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("retrieve AET used in SOP references in Output Information"
            + "Sequence in created or updated GP-PPS.");
    opts.addOption(OptionBuilder.create("retrieve"));

    OptionBuilder.withArgName("iuid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("update GP-PPS with SOP Instance UID <iuid>.");
    opts.addOption(OptionBuilder.create("setpps"));

    OptionBuilder.withArgName("iuid:tuid");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription(
            "reference GP-SPS with SOP Instance UID <iuid> and " + "Transaction UID <tuid> in created GP-PPS.");
    opts.addOption(OptionBuilder.create("refsps"));

    OptionBuilder.withArgName("attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription("specify matching key or PPS attribute. attr can be specified "
            + "by name or tag value (in hex), e.g. PatientName or 00100010.");
    opts.addOption(OptionBuilder.create("A"));

    OptionBuilder.withArgName("datetime");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify matching SPS start datetime (range)");
    opts.addOption(OptionBuilder.create("D"));

    OptionBuilder.withArgName("attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription("specify matching Referenced Request key or PPS attribute. "
            + "attr can be specified by name or tag value (in hex)");
    opts.addOption(OptionBuilder.create("rqA"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Workitem Code");
    opts.addOption(OptionBuilder.create("workitem"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Processing Application Code");
    opts.addOption(OptionBuilder.create("application"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Station Name Code");
    opts.addOption(OptionBuilder.create("station"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Station Class Code");
    opts.addOption(OptionBuilder.create("class"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Station Geographic Location Code");
    opts.addOption(OptionBuilder.create("location"));

    OptionBuilder.withArgName("code:scheme:[name]");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify matching Scheduled Human Performer Code");
    opts.addOption(OptionBuilder.create("performer"));

    OptionBuilder.withArgName("code:scheme:name");
    OptionBuilder.hasArgs(3);
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription("specify Actual Human Performer Code");
    opts.addOption(OptionBuilder.create("perfcode"));

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify Actual Human Performer Name");
    opts.addOption(OptionBuilder.create("perfname"));

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify Actual Human Performer Organisation");
    opts.addOption(OptionBuilder.create("perforg"));

    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("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("store query results in DICOM files in directory <dir>.");
    opts.addOption(OptionBuilder.create("o"));

    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("dcmgpwl: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmGPWL.class.getPackage();
        System.out.println("dcmgpwl 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:adalid.util.info.JavaInfo.java

public void printPackageDetails(String name) {
    Package pack = Package.getPackage(name);
    out.println("Package " + name + ": " + pack);
    if (pack != null) {
        out.println("\t" + Attributes.Name.IMPLEMENTATION_TITLE + ":   " + pack.getImplementationTitle());
        out.println("\t" + Attributes.Name.IMPLEMENTATION_VENDOR + ":  " + pack.getImplementationVendor());
        out.println("\t" + Attributes.Name.IMPLEMENTATION_VERSION + ": " + pack.getImplementationVersion());
        out.println("\t" + Attributes.Name.SPECIFICATION_TITLE + ":    " + pack.getSpecificationTitle());
        out.println("\t" + Attributes.Name.SPECIFICATION_VENDOR + ":   " + pack.getSpecificationVendor());
        out.println("\t" + Attributes.Name.SPECIFICATION_VERSION + ":  " + pack.getSpecificationVersion());
        out.println();/*from w  ww.  j  a  v  a  2 s  .c om*/
    }
}

From source file:projetg2.DcmSnd.java

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

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

    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set AET, local address and listening port 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"));

    opts.addOption("ts1", false,
            "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with "
                    + "Explicit VR Little Endian TS in one PC.");

    opts.addOption("fileref", false,
            "send objects without pixel data, but with a reference to "
                    + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax "
                    + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive.");

    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_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("aet@host:port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("request storage commitment of (successfully) sent objects "
            + "afterwards in new association to specified remote " + "Application Entity");
    opts.addOption(OptionBuilder.create("stgcmtae"));

    opts.addOption("stgcmt", false,
            "request storage commitment of (successfully) sent objects " + "afterwards in same association");

    OptionBuilder.withArgName("attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription("Replace value of specified attribute "
            + "with specified value in transmitted objects. attr can be "
            + "specified by name or tag value (in hex), e.g. PatientName " + "or 00100010.");
    opts.addOption(OptionBuilder.create("set"));

    OptionBuilder.withArgName("sx1[:sx2[:sx3]");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription(
            "Suffix SOP [,Series [,Study]] " + "Instance UID with specified value[s] in transmitted objects.");
    opts.addOption(OptionBuilder.create("setuid"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding operations it may invoke "
            + "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("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 closing the listening socket, " + "1000ms by default");
    opts.addOption(OptionBuilder.create("shutdowndelay"));

    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("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default");
    opts.addOption(OptionBuilder.create("bufsize"));

    OptionBuilder.withArgName("count");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Batch size - Number of files to be sent in each batch, "
            + "where a storage commit is done between batches ");
    opts.addOption(OptionBuilder.create("batchsize"));

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