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:com.gooddata.GoodData.java

private String getUserAgent() {
    final Package pkg = Package.getPackage("com.gooddata");
    final String clientVersion = pkg != null && pkg.getImplementationVersion() != null
            ? pkg.getImplementationVersion()
            : UNKNOWN_VERSION;/*from  w  w w.  ja  v  a 2 s  . c o m*/

    final VersionInfo vi = loadVersionInfo("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
    final String apacheVersion = vi != null ? vi.getRelease() : UNKNOWN_VERSION;

    return String.format("%s/%s (%s; %s) %s/%s", "GoodData-Java-SDK", clientVersion,
            System.getProperty("os.name"), System.getProperty("java.specification.version"),
            "Apache-HttpClient", apacheVersion);
}

From source file:com.alfaariss.oa.OAContextListener.java

/**
 * Starts the engine before all servlets are initialized.
 * // w  w  w . jav a 2 s  .c o  m
 * Searches for the properties needed for the configuration in:
 * <code>[Servlet context dir]/WEB-INF/[PROPERTIES_FILENAME]</code>
 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
 */
@Override
public void contextInitialized(ServletContextEvent oServletContextEvent) {
    Properties pConfig = new Properties();
    try {
        _logger.info("Starting Asimba");

        Package pCurrent = OAContextListener.class.getPackage();

        String sSpecVersion = pCurrent.getSpecificationVersion();
        if (sSpecVersion != null)
            _logger.info("Specification-Version: " + sSpecVersion);

        String sImplVersion = pCurrent.getImplementationVersion();
        if (sImplVersion != null)
            _logger.info("Implementation-Version: " + sImplVersion);

        ServletContext oServletContext = oServletContextEvent.getServletContext();

        Enumeration enumContextAttribs = oServletContext.getInitParameterNames();
        while (enumContextAttribs.hasMoreElements()) {
            String sName = (String) enumContextAttribs.nextElement();
            pConfig.put(sName, oServletContext.getInitParameter(sName));
        }

        if (pConfig.size() > 0) {
            _logger.info("Using configuration items found in servlet context: " + pConfig);
        }

        // Add MountingPoint to PathTranslator
        PathTranslator.getInstance().addKey(MP_WEBAPP_ROOT, oServletContext.getRealPath(""));

        // Try to see whether there is a system property with the location of the properties file:
        String sPropertiesFilename = System.getProperty(PROPERTIES_FILENAME_PROPERTY);
        if (null != sPropertiesFilename && !"".equals(sPropertiesFilename)) {
            File fConfig = new File(sPropertiesFilename);
            if (fConfig.exists()) {
                _logger.info("Reading Asimba properties from " + fConfig.getAbsolutePath());
                pConfig.putAll(getProperties(fConfig));
            }
        }

        String sWebInf = oServletContext.getRealPath("WEB-INF");
        if (sWebInf != null) {
            _logger.info("Cannot find path in ServletContext for WEB-INF");
            StringBuffer sbConfigFile = new StringBuffer(sWebInf);
            if (!sbConfigFile.toString().endsWith(File.separator))
                sbConfigFile.append(File.separator);
            sbConfigFile.append(PROPERTIES_FILENAME);

            File fConfig = new File(sbConfigFile.toString());
            if (fConfig.exists()) {
                _logger.info("Updating configuration items with the items in file: " + fConfig.toString());
                pConfig.putAll(getProperties(fConfig));
            } else {
                _logger.info("No optional configuration properties (" + PROPERTIES_FILENAME
                        + ") file found at: " + fConfig.toString());
            }
        }
        //Search for PROPERTIES_FILENAME file in servlet context classloader classpath 
        //it looks first at this location: ./<context>/web-inf/classes/[PROPERTIES_FILENAME]
        //if previous location didn't contain PROPERTIES_FILENAME then checking: 
        //./tomcat/common/classes/PROPERTIES_FILENAME
        URL urlProperties = oServletContext.getClass().getClassLoader().getResource(PROPERTIES_FILENAME);
        if (urlProperties != null) {
            String sProperties = urlProperties.getFile();
            _logger.debug("Found '" + PROPERTIES_FILENAME + "' file in classpath: " + sProperties);
            File fProperties = new File(sProperties);
            if (fProperties != null && fProperties.exists()) {
                _logger.info("Updating configuration items with the items in file: "
                        + fProperties.getAbsolutePath());
                pConfig.putAll(getProperties(fProperties));
            } else
                _logger.info("Could not resolve: " + fProperties.getAbsolutePath());
        } else
            _logger.info("No optional '" + PROPERTIES_FILENAME
                    + "' configuration file found in servlet context classpath");

        if (!pConfig.containsKey("configuration.handler.filename")) {
            StringBuffer sbOAConfigFile = new StringBuffer(sWebInf);
            if (!sbOAConfigFile.toString().endsWith(File.separator))
                sbOAConfigFile.append(File.separator);
            sbOAConfigFile.append("conf");
            sbOAConfigFile.append(File.separator);
            sbOAConfigFile.append("asimba.xml");
            File fOAConfig = new File(sbOAConfigFile.toString());
            if (fOAConfig.exists()) {
                pConfig.put("configuration.handler.filename", sbOAConfigFile.toString());
                _logger.info(
                        "Setting 'configuration.handler.filename' configuration property with configuration file found at: "
                                + fOAConfig.toString());
            }
        }

        _oEngineLauncher.start(pConfig);

        _logger.info("Started Engine with OAContextListener");
    } catch (Exception e) {
        _logger.error("Can't start Engine with OAContextListener", e);

        _logger.debug("try stopping the server");
        _oEngineLauncher.stop();
    }

}

From source file:mod.org.dcm4che2.tool.DcmSnd.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*w  ww .  ja  v 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("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("salt");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "Anonymize the files.  Set to 0 for a random anonymization (not repeatable) or 1 for a daily anonymization or another"
                    + " value for a specific salt for reproducible anonymization (useful for allowing studies to be sent at a later date and still correctly named/associated)");
    OptionBuilder.withLongOpt("anonymize");
    opts.addOption(OptionBuilder.create("a"));

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

From source file:com.upload.DcmSnd.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*  w  w w.  ja 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("salt");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "Anonymize the files.  Set to 0 for a random anonymization (not repeatable) or 1 for a daily anonymization or another"
                    + " value for a specific salt for reproducible anonymization (useful for allowing studies to be sent at a later date and still correctly named/associated)");
    OptionBuilder.withLongOpt("anonymize");
    opts.addOption(OptionBuilder.create("a"));

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

From source file:org.trimou.engine.MustacheEngineBuilder.java

/**
 * Builds the engine instance.//from   ww w  .j a  v  a 2 s.  c  om
 *
 * @return the built engine
 */
public MustacheEngine build() {

    registerBuiltinHelpersIfNecessary();

    MustacheEngine engine = new DefaultMustacheEngine(this);
    for (EngineBuiltCallback callback : engineReadyCallbacks) {
        callback.engineBuilt(engine);
    }

    String version = null;
    String timestamp = null;

    // First try to get trimou-build.properties file
    InputStream in = MustacheEngineBuilder.class.getResourceAsStream(BUILD_PROPERTIES_FILE);

    try {
        if (in != null) {
            try {
                Properties buildProperties = new Properties();
                buildProperties.load(in);
                version = buildProperties.getProperty("version");
                timestamp = buildProperties.getProperty("timestamp");
            } finally {
                in.close();
            }
        }
    } catch (IOException e) {
        // No-op
    }
    if (version == null) {
        // If not available use the manifest info
        Package pack = MustacheEngineBuilder.class.getPackage();
        version = pack.getSpecificationVersion();
        timestamp = pack.getImplementationVersion();
    }
    if (StringUtils.isEmpty(version)) {
        version = "SNAPSHOT";
        timestamp = "n/a";
    }

    int idx = timestamp.indexOf('T');
    if (idx > 0) {
        timestamp = timestamp.substring(0, idx);
    }

    logger.info("Engine built {} ({})", version, timestamp);
    logger.debug("Engine configuration: " + engine.getConfiguration().getInfo());
    isBuilt = true;
    return engine;
}

From source file:com.netscape.cmstools.cli.MainCLI.java

public void printVersion() {
    Package pkg = MainCLI.class.getPackage();
    System.out.println("PKI Command-Line Interface " + pkg.getImplementationVersion());
}

From source file:se.jguru.nazgul.tools.plugin.checkstyle.exec.DefaultCheckstyleExecutor.java

/**
 * Get the effective Checkstyle version at runtime.
 *
 * @return the MANIFEST implementation version of Checkstyle API package (can be <code>null</code>)
 * @todo Copied from CheckstyleReportGenerator - move to a utility class
 *///from  w  ww  .j av  a  2 s . co m
private String getCheckstyleVersion() {
    Package checkstyleApiPackage = Configuration.class.getPackage();

    return (checkstyleApiPackage == null) ? null : checkstyleApiPackage.getImplementationVersion();
}

From source file:org.dcm4che2.tool.dcmsnd.DcmSnd.java

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

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

    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 );
        throw new RuntimeException();
    }
    return cl;
}

From source file:DcmQR.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();
    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();//from   w w w .java  2s.  c om
    OptionBuilder.withDescription("set AET, local address and listening port of local Application Entity");
    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"));

    opts.addOption("nossl2", false, "disable 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_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"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("retrieve instances of matching entities by C-MOVE to specified destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("cget", false, "retrieve instances of matching entities by C-GET.");

    OptionBuilder.withArgName("cuid[:ts]");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate support of specified Storage SOP Class and Transfer "
            + "Syntaxes. The Storage SOP\nClass may be specified by its UID "
            + "or by one\nof following key words:\n" + "CR  - Computed Radiography Image Storage\n"
            + "CT  - CT Image Storage\n" + "MR  - MRImageStorage\n" + "US  - Ultrasound Image Storage\n"
            + "NM  - Nuclear Medicine Image Storage\n" + "PET - PET Image Storage\n"
            + "SC  - Secondary Capture Image Storage\n" + "XA  - XRay Angiographic Image Storage\n"
            + "XRF - XRay Radiofluoroscopic Image Storage\n"
            + "DX  - Digital X-Ray Image Storage for Presentation\n"
            + "                            MG  - Digital Mammography X-Ray Image Storage\n"
            + "for Presentation\n" + "PR  - Grayscale Softcopy Presentation State Storage\n"
            + "                            KO  - Key Object Selection Document Storage\n"
            + "SR  - Basic Text Structured Report Document Storage\n"
            + "                            The Transfer Syntaxes may be specified by a comma\n"
            + "                            separated list of UIDs or by one of following key\n"
            + "                            words:\n"
            + "                            IVRLE - offer only Implicit VR Little Endian\n"
            + "                            Transfer Syntax\n"
            + "                            LE - offer Explicit and Implicit VR Little Endian\n"
            + "                            Transfer Syntax\n"
            + "                            BE - offer Explicit VR Big Endian Transfer Syntax\n"
            + "                            DEFL - offer Deflated Explicit VR Little\n"
            + "                            Endian Transfer Syntax\n"
            + "                            JPLL - offer JEPG Loss Less Transfer Syntaxes\n"
            + "                            JPLY - offer JEPG Lossy Transfer Syntaxes\n"
            + "                            MPEG2 - offer MPEG2 Transfer Syntax\n"
            + "                            NOPX - offer No Pixel Data Transfer Syntax\n"
            + "                            NOPXD - offer No Pixel Data Deflate Transfer Syntax\n"
            + "                            If only the Storage SOP Class is specified, all\n"
            + "                            Transfer Syntaxes listed above except No Pixel Data\n"
            + "                            and No Pixel Data Delflate Transfer Syntax are\n"
            + "                            offered.");
    opts.addOption(OptionBuilder.create("cstore"));

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

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "maximum number of outstanding C-MOVE-RQ " + "it may invoke asynchronously, 1 by default.");
    opts.addOption(OptionBuilder.create("async"));

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

    opts.addOption("noextneg", false, "disable extended negotiation.");
    opts.addOption("rel", false, "negotiate support of relational queries and retrieval.");
    opts.addOption("datetime", false, "negotiate support of combined date and time attribute range matching.");
    opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching.");

    opts.addOption("retall", false,
            "negotiate private FIND SOP Classes " + "to fetch all available attributes of matching entities.");
    opts.addOption("blocked", false,
            "negotiate private FIND SOP Classes "
                    + "to return attributes of several matching entities per FIND\n"
                    + "                            response.");
    opts.addOption("vmf", false,
            "negotiate private FIND SOP Classes to "
                    + "return attributes of legacy CT/MR images of one series as\n"
                    + "                           virtual multiframe object.");
    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\n" + "                           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 C-FIND-RSP, 60s by default");
    opts.addOption(OptionBuilder.create("cfindrspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cmoverspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cgetrspTO"));

    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("minimal buffer size to write received object to file, 1KB by default");
    opts.addOption(OptionBuilder.create("filebuf"));

    OptionGroup qrlevel = new OptionGroup();

    OptionBuilder.withDescription(
            "perform patient level query, multiple " + "exclusive with -S and -I, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("patient");
    opts.addOption(OptionBuilder.create("P"));

    OptionBuilder.withDescription(
            "perform series level query, multiple " + "exclusive with -P and -I, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("series");
    opts.addOption(OptionBuilder.create("S"));

    OptionBuilder.withDescription(
            "perform instance level query, multiple " + "exclusive with -P and -S, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("image");
    opts.addOption(OptionBuilder.create("I"));

    opts.addOptionGroup(qrlevel);

    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\n"
                    + "or 00100010. Attributes in nested Datasets can\n"
                    + "be specified by including the name/tag value of\n"
                    + "                            the sequence attribute, e.g. 00400275/00400009\n"
                    + "for Scheduled Procedure Step ID in the Request\n" + "Attributes Sequence");
    opts.addOption(OptionBuilder.create("q"));

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

    opts.addOption("evalRetrieveAET", false, "Only Move studies not allready stored on destination AET");
    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");

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("repeat query (and retrieve) several times");
    opts.addOption(OptionBuilder.create("repeat"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms between repeated query (and retrieve), no delay by default");
    opts.addOption(OptionBuilder.create("repeatdelay"));

    opts.addOption("reuseassoc", false, "Reuse association for repeated query (and retrieve)");
    opts.addOption("closeassoc", false, "Close association between repeated query (and retrieve)");

    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("dcmqr: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmQR.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.dcm4che2.tool.dcmqr.DcmQR.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*w ww . j a  v  a2s  .  c  o  m*/
    OptionBuilder.withDescription("set device name, use DCMQR 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"));

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

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("retrieve instances of matching entities by C-MOVE to specified destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("nocfind", false,
            "retrieve instances without previous query - unique keys must be specified by -q options");

    opts.addOption("cget", false, "retrieve instances of matching entities by C-GET.");

    OptionBuilder.withArgName("cuid[:ts]");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate support of specified Storage SOP Class and Transfer "
            + "Syntaxes. The Storage SOP Class may be specified by its UID "
            + "or by one of following key words:\n" + "CR  - Computed Radiography Image Storage\n"
            + "CT  - CT Image Storage\n" + "MR  - MRImageStorage\n" + "US  - Ultrasound Image Storage\n"
            + "NM  - Nuclear Medicine Image Storage\n" + "PET - PET Image Storage\n"
            + "SC  - Secondary Capture Image Storage\n" + "XA  - XRay Angiographic Image Storage\n"
            + "XRF - XRay Radiofluoroscopic Image Storage\n"
            + "DX  - Digital X-Ray Image Storage for Presentation\n"
            + "MG  - Digital Mammography X-Ray Image Storage for Presentation\n"
            + "PR  - Grayscale Softcopy Presentation State Storage\n"
            + "KO  - Key Object Selection Document Storage\n"
            + "SR  - Basic Text Structured Report Document Storage\n"
            + "The Transfer Syntaxes may be specified by a comma "
            + "separated list of UIDs or by one of following key " + "words:\n"
            + "IVRLE - offer only Implicit VR Little Endian " + "Transfer Syntax\n"
            + "LE - offer Explicit and Implicit VR Little Endian " + "Transfer Syntax\n"
            + "BE - offer Explicit VR Big Endian Transfer Syntax\n"
            + "DEFL - offer Deflated Explicit VR Little " + "Endian Transfer Syntax\n"
            + "JPLL - offer JEPG Loss Less Transfer Syntaxes\n" + "JPLY - offer JEPG Lossy Transfer Syntaxes\n"
            + "MPEG2 - offer MPEG2 Transfer Syntax\n" + "NOPX - offer No Pixel Data Transfer Syntax\n"
            + "NOPXD - offer No Pixel Data Deflate Transfer Syntax\n"
            + "If only the Storage SOP Class is specified, all "
            + "Transfer Syntaxes listed above except No Pixel Data "
            + "and No Pixel Data Delflate Transfer Syntax are " + "offered.");
    opts.addOption(OptionBuilder.create("cstore"));

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

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "maximum number of outstanding C-MOVE-RQ " + "it may invoke asynchronously, 1 by default.");
    opts.addOption(OptionBuilder.create("async"));

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

    opts.addOption("noextneg", false, "disable extended negotiation.");
    opts.addOption("rel", false, "negotiate support of relational queries and retrieval.");
    opts.addOption("datetime", false, "negotiate support of combined date and time attribute range matching.");
    opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching.");

    opts.addOption("retall", false,
            "negotiate private FIND SOP Classes " + "to fetch all available attributes of matching entities.");
    opts.addOption("blocked", false, "negotiate private FIND SOP Classes "
            + "to return attributes of several matching entities per FIND " + "response.");
    opts.addOption("vmf", false, "negotiate private FIND SOP Classes to "
            + "return attributes of legacy CT/MR images of one series as " + "virtual multiframe object.");
    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 C-FIND-RSP, 60s by default");
    opts.addOption(OptionBuilder.create("cfindrspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cmoverspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cgetrspTO"));

    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("minimal buffer size to write received object to file, 1KB by default");
    opts.addOption(OptionBuilder.create("filebuf"));

    OptionGroup qrlevel = new OptionGroup();

    OptionBuilder.withDescription("perform patient level query, multiple "
            + "exclusive with -S and -I, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("patient");
    opts.addOption(OptionBuilder.create("P"));

    OptionBuilder.withDescription("perform series level query, multiple "
            + "exclusive with -P and -I, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("series");
    opts.addOption(OptionBuilder.create("S"));

    OptionBuilder.withDescription("perform instance level query, multiple "
            + "exclusive with -P and -S, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("image");
    opts.addOption(OptionBuilder.create("I"));

    OptionBuilder.withArgName("cuid");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate addition private C-FIND SOP " + "class with specified UID");
    opts.addOption(OptionBuilder.create("cfind"));

    opts.addOptionGroup(qrlevel);

    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 including the name/tag value of "
                    + "the sequence attribute, e.g. 00400275/00400009 "
                    + "for Scheduled Procedure Step ID in the Request " + "Attributes Sequence");
    opts.addOption(OptionBuilder.create("q"));

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

    opts.addOption("evalRetrieveAET", false, "Only Move studies not allready stored on destination AET");
    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");

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("repeat query (and retrieve) several times");
    opts.addOption(OptionBuilder.create("repeat"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms between repeated query (and retrieve), no delay by default");
    opts.addOption(OptionBuilder.create("repeatdelay"));

    opts.addOption("reuseassoc", false, "Reuse association for repeated query (and retrieve)");
    opts.addOption("closeassoc", false, "Close association between repeated query (and retrieve)");

    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("dcmqr: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmQR.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;
}