List of usage examples for org.apache.commons.cli OptionBuilder hasArg
public static OptionBuilder hasArg()
From source file:org.openmainframe.ade.ext.main.UpdateGroups.java
/** * Method for building the allowed options. * @param options Options object for adding the options created with OptionBuilder. *///from w w w. ja va2s . c om private void buildOptions(Options options) { OptionBuilder.withArgName(OPTION_HELP); OptionBuilder.withLongOpt(OPTION_HELP); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Print help message and exit."); options.addOption(OptionBuilder.create('h')); OptionBuilder.withArgName(OPTION_INPUT_JSON); OptionBuilder.withLongOpt(OPTION_INPUT_JSON); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); OptionBuilder.withDescription("Specify the JSON input file."); options.addOption(OptionBuilder.create("j")); }
From source file:org.openmainframe.ade.main.Train.java
@Override protected void parseArgs(String[] args) throws AdeException { final Option helpOpt = new Option("h", "help", false, "Print help message and exit"); OptionBuilder.withLongOpt(ALL_OPT);/* ww w . j a v a 2 s.c om*/ OptionBuilder.isRequired(false); OptionBuilder.withDescription("All analysis groups"); final Option allAnalysisGroupsOpt = OptionBuilder.create('a'); OptionBuilder.withLongOpt(GROUPS_OPT); OptionBuilder.withArgName("ANALYSIs GROUPS"); OptionBuilder.hasArgs(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Selected analysis groups"); final Option selectAnalysisGroupsOpt = OptionBuilder.create('s'); final OptionGroup inputAnalysisGroupsOptGroup = new OptionGroup().addOption(allAnalysisGroupsOpt) .addOption(selectAnalysisGroupsOpt); inputAnalysisGroupsOptGroup.setRequired(true); OptionBuilder.withLongOpt(UNSELECT_OPT); OptionBuilder.withArgName("ANALYSIS GROUPS"); OptionBuilder.hasArgs(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Unselect analysis groups. Used only with '" + ALL_OPT + "'"); final Option unselectAnalysisGroupsOpt = OptionBuilder.create('u'); OptionBuilder.withLongOpt(DURATION_OPT); OptionBuilder.withArgName("DURATION (ISO 8601)"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Duration from/to start/end date. Defaults to infinity. Replaces either 'start-date' or 'end-date'"); final Option periodOpt = OptionBuilder.create(); OptionBuilder.withLongOpt(NUM_DAYS_OPT); OptionBuilder.withArgName("INT"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Number of days. same as '" + DURATION_OPT + "'"); final Option numDaysOpt = OptionBuilder.create('n'); final OptionGroup periodOptGroup = new OptionGroup().addOption(periodOpt).addOption(numDaysOpt); OptionBuilder.withLongOpt(START_DATE_OPT); OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder.withDescription( "Start of date range. Optional. Replaces 'duration'/'num-days' when used along with 'end-date'"); final Option startDateOpt = OptionBuilder.create(); OptionBuilder.withLongOpt(END_DATE_OPT); OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]"); OptionBuilder.hasArg(); OptionBuilder.isRequired(false); OptionBuilder .withDescription("End of date range. Defaults to this moment. Replaces 'duration'/'num-days' when" + " used along with 'start-date'"); final Option endDateOpt = OptionBuilder.create(); final Options options = new Options(); options.addOption(helpOpt); options.addOptionGroup(inputAnalysisGroupsOptGroup); options.addOption(unselectAnalysisGroupsOpt); options.addOptionGroup(periodOptGroup); options.addOption(endDateOpt); options.addOption(startDateOpt); final CommandLineParser parser = new GnuParser(); CommandLine line; try { // parse the command line arguments line = parser.parse(options, args); } catch (MissingOptionException exp) { new HelpFormatter().printHelp(HELP + "\nOptions:", options); throw new AdeUsageException("Command line parsing failed", exp); } catch (ParseException exp) { // oops, something went wrong throw new AdeUsageException("Argument Parsing failed", exp); } if (line.hasOption(helpOpt.getLongOpt())) { new HelpFormatter().printHelp(HELP, options); closeAll(); System.exit(0); } if (line.hasOption(UNSELECT_OPT) && !line.hasOption(ALL_OPT)) { throw new AdeUsageException("'" + UNSELECT_OPT + "' cannot be used without '" + ALL_OPT + "'"); } final Set<Integer> allAnalysisGroups = Ade.getAde().getDataStore().sources().getAllAnalysisGroups(); if (line.hasOption(ALL_OPT)) { System.out.println("Operating on all available analysis groups"); if (!line.hasOption(UNSELECT_OPT)) { m_analysisGroups = allAnalysisGroups; } else { final Set<Integer> unselectedAnalysisGroups = parseAnalysisGroups(allAnalysisGroups, line.getOptionValues(UNSELECT_OPT)); final Set<String> unselectedGroupNames = getGroupNames(unselectedAnalysisGroups); System.out.println("Omitting analysis groups: " + unselectedGroupNames.toString()); m_analysisGroups = new TreeSet<Integer>(allAnalysisGroups); m_analysisGroups.removeAll(unselectedAnalysisGroups); } } else if (line.hasOption(GROUPS_OPT)) { m_analysisGroups = parseAnalysisGroups(allAnalysisGroups, line.getOptionValues(GROUPS_OPT)); final Set<String> operatingAnalysisGroups = getGroupNames(m_analysisGroups); System.out.println("Operating on analysis groups: " + operatingAnalysisGroups.toString()); } if ((line.hasOption(NUM_DAYS_OPT) || line.hasOption(DURATION_OPT)) && line.hasOption(START_DATE_OPT) && line.hasOption(END_DATE_OPT)) { throw new AdeUsageException("Cannot use '" + DURATION_OPT + "'/'" + NUM_DAYS_OPT + "', '" + START_DATE_OPT + "' and '" + END_DATE_OPT + "' together"); } if (line.hasOption(NUM_DAYS_OPT)) { final String numDaysStr = line.getOptionValue(NUM_DAYS_OPT); final int numDays = Integer.parseInt(numDaysStr); this.m_period = Period.days(numDays); } if (line.hasOption(DURATION_OPT)) { final String periodStr = line.getOptionValue(DURATION_OPT); this.m_period = ISOPeriodFormat.standard().parsePeriod(periodStr); } if (line.hasOption(START_DATE_OPT)) { m_startDate = parseDate(line.getOptionValue(START_DATE_OPT)); } if (line.hasOption(END_DATE_OPT)) { m_endDate = parseDate(line.getOptionValue(END_DATE_OPT)); } }
From source file:org.opennms.tools.syslog.Main.java
@SuppressWarnings({ "static-access", "deprecation" }) public static void main(final String... args) throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withDescription("this help").withLongOpt("help").create("h")); options.addOption(OptionBuilder.hasArg().withArgName("DIRECTORY").withDescription("OpenNMS home directory") .withLongOpt("opennms-home").create("o")); final CommandLineParser parser = new GnuParser(); try {/* ww w .j ava2s .c o m*/ final CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("syslog-profiler", options, true); System.exit(1); } if (line.hasOption("opennms-home")) { OPENNMS_HOME = line.getOptionValue("opennms-home"); } else { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("syslog-profiler", "You must specify your OpenNMS home.", options, null); System.exit(1); } } catch (Throwable e) { LOG.warn("An error occurred trying to parse the command-line.", e); } System.out.println("- using " + OPENNMS_HOME + "/etc for configuration files"); System.setProperty("opennms.home", OPENNMS_HOME); MBeanServer server = ManagementFactory.getPlatformMBeanServer(); List<Invoke> invokes = new ArrayList<Invoke>(); invokes.add((Invoke) CastorUtils.unmarshal(Invoke.class, new StringReader("<invoke at=\"start\" pass=\"0\" method=\"init\"/>"))); invokes.add((Invoke) CastorUtils.unmarshal(Invoke.class, new StringReader("<invoke at=\"start\" pass=\"1\" method=\"start\"/>"))); invokes.add((Invoke) CastorUtils.unmarshal(Invoke.class, new StringReader("<invoke at=\"status\" pass=\"0\" method=\"status\"/>"))); invokes.add((Invoke) CastorUtils.unmarshal(Invoke.class, new StringReader("<invoke at=\"stop\" pass=\"0\" method=\"stop\"/>"))); List<Service> services = new ArrayList<Service>(); Invoker invoker = new Invoker(); invoker.setServer(server); invoker.setAtType(InvokeAtType.START); for (final Service s : Invoker.getDefaultServiceConfigFactory().getServices()) { if (s.getName().contains("Eventd") || s.getName().contains("Syslogd")) { services.add(s); } } List<InvokerService> invokerServices = InvokerService.createServiceList(services.toArray(new Service[0])); System.err.println(invokerServices); invoker.setServices(invokerServices); invoker.instantiateClasses(); Thread.sleep(10000); }
From source file:org.openscience.jmol.app.Jmol.java
public static void main(String[] args) { Dialog.setupUIManager();/* w w w. j a v a 2 s . co m*/ Jmol jmol = null; String modelFilename = null; String scriptFilename = null; Options options = new Options(); options.addOption("b", "backgroundtransparent", false, GT._("transparent background")); options.addOption("h", "help", false, GT._("give this help page")); options.addOption("n", "nodisplay", false, GT._("no display (and also exit when done)")); options.addOption("c", "check", false, GT._("check script syntax only")); options.addOption("i", "silent", false, GT._("silent startup operation")); options.addOption("l", "list", false, GT._("list commands during script execution")); options.addOption("o", "noconsole", false, GT._("no console -- all output to sysout")); options.addOption("t", "threaded", false, GT._("independent commmand thread")); options.addOption("x", "exit", false, GT._("exit after script (implicit with -n)")); OptionBuilder.withLongOpt("script"); OptionBuilder.withDescription("script file to execute"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("s")); OptionBuilder.withLongOpt("menu"); OptionBuilder.withDescription("menu file to use"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("m")); OptionBuilder.withArgName(GT._("property=value")); OptionBuilder.hasArg(); OptionBuilder.withValueSeparator(); OptionBuilder.withDescription(GT._("supported options are given below")); options.addOption(OptionBuilder.create("D")); OptionBuilder.withLongOpt("geometry"); // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616")); OptionBuilder.withDescription(GT._("window width x height, e.g. {0}", "-g500x500")); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("g")); OptionBuilder.withLongOpt("quality"); // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616")); OptionBuilder.withDescription(GT._( "JPG image quality (1-100; default 75) or PNG image compression (0-9; default 2, maximum compression 9)")); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("q")); OptionBuilder.withLongOpt("write"); OptionBuilder .withDescription(GT._("{0} or {1}:filename", new Object[] { "CLIP", "GIF|JPG|JPG64|PNG|PPM" })); OptionBuilder.withValueSeparator(); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("w")); int startupWidth = 0, startupHeight = 0; CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(options, args); } catch (ParseException exception) { System.err.println("Unexpected exception: " + exception.toString()); } if (line.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Jmol", options); // now report on the -D options System.out.println(); System.out.println(GT._("For example:")); System.out.println(); System.out.println("Jmol -ions myscript.spt -w JPEG:myfile.jpg > output.txt"); System.out.println(); System.out.println(GT._("The -D options are as follows (defaults in parenthesis):")); System.out.println(); System.out.println(" cdk.debugging=[true|false] (false)"); System.out.println(" cdk.debug.stdout=[true|false] (false)"); System.out.println(" display.speed=[fps|ms] (ms)"); System.out.println(" JmolConsole=[true|false] (true)"); System.out.println(" jmol.logger.debug=[true|false] (false)"); System.out.println(" jmol.logger.error=[true|false] (true)"); System.out.println(" jmol.logger.fatal=[true|false] (true)"); System.out.println(" jmol.logger.info=[true|false] (true)"); System.out.println(" jmol.logger.logLevel=[true|false] (false)"); System.out.println(" jmol.logger.warn=[true|false] (true)"); System.out.println(" plugin.dir (unset)"); System.out.println(" user.language=[CA|CS|DE|EN|ES|FR|NL|PT|TR] (EN)"); System.exit(0); } args = line.getArgs(); if (args.length > 0) { modelFilename = args[0]; } // Process more command line arguments // these are also passed to viewer String commandOptions = ""; //silent startup if (line.hasOption("i")) { commandOptions += "-i"; isSilent = Boolean.TRUE; } // transparent background if (line.hasOption("b")) { commandOptions += "-b"; } // independent command thread if (line.hasOption("t")) { commandOptions += "-t"; } //list commands during script operation if (line.hasOption("l")) { commandOptions += "-l"; } //output to sysout if (line.hasOption("o")) { commandOptions += "-o"; haveConsole = Boolean.FALSE; } //no display (and exit) if (line.hasOption("n")) { // this ensures that noDisplay also exits commandOptions += "-n-x"; haveDisplay = Boolean.FALSE; } //check script only if (line.hasOption("c")) { commandOptions += "-c"; } //run script if (line.hasOption("s")) { commandOptions += "-s"; scriptFilename = line.getOptionValue("s"); } //menu file if (line.hasOption("m")) { menuFile = line.getOptionValue("m"); } //exit when script completes (or file is read) if (line.hasOption("x")) { commandOptions += "-x"; } String imageType_name = null; //write image to clipboard or image file if (line.hasOption("w")) { imageType_name = line.getOptionValue("w"); } Dimension size; try { String vers = System.getProperty("java.version"); if (vers.compareTo("1.1.2") < 0) { System.out.println("!!!WARNING: Swing components require a " + "1.1.2 or higher version VM!!!"); } size = historyFile.getWindowSize(JMOL_WINDOW_NAME); if (size != null && haveDisplay.booleanValue()) { startupWidth = size.width; startupHeight = size.height; } //OUTER window dimensions /* if (line.hasOption("g") && haveDisplay.booleanValue()) { String geometry = line.getOptionValue("g"); int indexX = geometry.indexOf('x'); if (indexX > 0) { startupWidth = parseInt(geometry.substring(0, indexX)); startupHeight = parseInt(geometry.substring(indexX + 1)); } } */ Point b = historyFile.getWindowBorder(JMOL_WINDOW_NAME); //first one is just approximate, but this is set in doClose() //so it will reset properly -- still, not perfect //since it is always one step behind. if (b == null) border = new Point(12, 116); else border = new Point(b.x, b.y); //note -- the first time this is run after changes it will not work //because there is a bootstrap problem. int width = -1; int height = -1; int quality = 75; //INNER frame dimensions if (line.hasOption("g")) { String geometry = line.getOptionValue("g"); int indexX = geometry.indexOf('x'); if (indexX > 0) { width = Parser.parseInt(geometry.substring(0, indexX)); height = Parser.parseInt(geometry.substring(indexX + 1)); //System.out.println("setting geometry to " + geometry + " " + border + " " + startupWidth + startupHeight); } if (haveDisplay.booleanValue()) { startupWidth = width + border.x; startupHeight = height + border.y; } } if (line.hasOption("q")) quality = Parser.parseInt(line.getOptionValue("q")); if (imageType_name != null) commandOptions += "-w\1" + imageType_name + "\t" + width + "\t" + height + "\t" + quality + "\1"; if (startupWidth <= 0 || startupHeight <= 0) { startupWidth = 500 + border.x; startupHeight = 500 + border.y; } JFrame jmolFrame = new JFrame(); Point jmolPosition = historyFile.getWindowPosition(JMOL_WINDOW_NAME); if (jmolPosition != null) { jmolFrame.setLocation(jmolPosition); } //now pass these to viewer jmol = getJmol(jmolFrame, startupWidth, startupHeight, commandOptions); // Open a file if one is given as an argument -- note, this CAN be a script file if (modelFilename != null) { jmol.viewer.openFile(modelFilename); jmol.viewer.getOpenFileError(); } // OK, by now it is time to execute the script if (scriptFilename != null) { report("Executing script: " + scriptFilename); if (haveDisplay.booleanValue()) jmol.splash.showStatus(GT._("Executing script...")); jmol.viewer.evalFile(scriptFilename); } } catch (Throwable t) { System.out.println("uncaught exception: " + t); t.printStackTrace(); } if (haveConsole.booleanValue()) { Point location = jmol.frame.getLocation(); size = jmol.frame.getSize(); // Adding console frame to grab System.out & System.err consoleframe = new JFrame(GT._("Jmol Java Console")); consoleframe.setIconImage(jmol.frame.getIconImage()); try { final ConsoleTextArea consoleTextArea = new ConsoleTextArea(); consoleTextArea.setFont(java.awt.Font.decode("monospaced")); consoleframe.getContentPane().add(new JScrollPane(consoleTextArea), java.awt.BorderLayout.CENTER); if (Boolean.getBoolean("clearConsoleButton")) { JButton buttonClear = new JButton(GT._("Clear")); buttonClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { consoleTextArea.setText(""); } }); consoleframe.getContentPane().add(buttonClear, java.awt.BorderLayout.SOUTH); } } catch (IOException e) { JTextArea errorTextArea = new JTextArea(); errorTextArea.setFont(java.awt.Font.decode("monospaced")); consoleframe.getContentPane().add(new JScrollPane(errorTextArea), java.awt.BorderLayout.CENTER); errorTextArea.append(GT._("Could not create ConsoleTextArea: ") + e); } Dimension consoleSize = historyFile.getWindowSize(CONSOLE_WINDOW_NAME); Point consolePosition = historyFile.getWindowPosition(CONSOLE_WINDOW_NAME); if ((consoleSize != null) && (consolePosition != null)) { consoleframe.setBounds(consolePosition.x, consolePosition.y, consoleSize.width, consoleSize.height); } else { consoleframe.setBounds(location.x, location.y + size.height, size.width, 200); } Boolean consoleVisible = historyFile.getWindowVisibility(CONSOLE_WINDOW_NAME); if ((consoleVisible != null) && (consoleVisible.equals(Boolean.TRUE))) { consoleframe.show(); } } }
From source file:org.openscience.jvxl.Jvxl.java
public static void main(String[] args) { boolean blockData = false; int fileIndex = Integer.MAX_VALUE; String inputFile = null;/*from w w w .j a va 2 s . co m*/ String mapFile = null; String outputFile = null; float cutoff = Float.NaN; boolean isPositiveOnly = false; P4 plane = null; boolean bicolor = false; boolean reverseColor = false; float min = Float.NaN; float max = Float.NaN; Options options = new Options(); options.addOption("h", "help", false, "give this help page"); /* * examples: * * jvxl ch3cl-density.cub --min=0.0 --max=0.2 --map ch3cl-esp.cub * jvxl ethene-HOMO.cub --bicolor --output ethene.jvxl * jvxl d_orbitals.jvxl --index 2 --phase yz * jvxl d_orbitals.jvxl --map sets * jvxl --plane xy --min=0.0 --max=0.2 --map data/ch3cl-density.cub */ // file options options.addOption("B", "blockdata", false, "multiple cube data are in blocks, not interspersed"); options.addOption("P", "progressive", false, "create JVXL+ progressive X low-to-high format"); OptionBuilder.withLongOpt("file"); OptionBuilder.withDescription("file containing surface data"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("f")); OptionBuilder.withLongOpt("index"); OptionBuilder.withDescription("index of surface in file (starting with 1)"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("i")); OptionBuilder.withLongOpt("plane"); OptionBuilder.withDescription("plane: x, y, z, xy, xz, yz, z2, x2-y2, or {a,b,c,d}"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("p")); OptionBuilder.withLongOpt("map"); OptionBuilder.withDescription("file containing data to map onto the surface or \"sets\""); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("m")); OptionBuilder.withLongOpt("output"); OptionBuilder.withDescription("JVXL output file"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("o")); // surface options OptionBuilder.withLongOpt("cutoff"); OptionBuilder.withDescription("isosurface cutoff value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("c")); // color mapping options options.addOption("b", "bicolor", false, "bicolor map (orbital)"); options.addOption("r", "reversecolor", false, "reverse color"); OptionBuilder.withLongOpt("colorScheme"); OptionBuilder.withDescription("VRML color scheme: bw, wb, roygb, bgyor, rwb, bwr, low, high"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("s")); OptionBuilder.withLongOpt("phase"); OptionBuilder.withDescription("color by phase: x, y, z, xy, xz, yz, z2, x2-y2"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("F")); OptionBuilder.withLongOpt("min"); OptionBuilder.withDescription("color absolute minimum value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("n")); OptionBuilder.withLongOpt("max"); OptionBuilder.withDescription("color absolute maximum value"); OptionBuilder.withValueSeparator('='); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create("x")); CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(options, args); } catch (ParseException exception) { Logger.error("Unexpected exception: " + exception.toString()); } if (line.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Jvxl", options); return; } args = line.getArgs(); if (args.length > 0) { inputFile = args[0]; } // files blockData = (line.hasOption("B")); if (line.hasOption("i")) { fileIndex = PT.parseInt(line.getOptionValue("i")); } if (line.hasOption("f")) { inputFile = line.getOptionValue("f"); } if (line.hasOption("m")) { mapFile = line.getOptionValue("m"); } if (line.hasOption("p")) { plane = getPlane(line.getOptionValue("p")); if (plane == null) { Logger.error("invalid plane"); return; } Logger.info("using plane " + plane); if (mapFile == null) mapFile = inputFile; if (inputFile == null) inputFile = mapFile; } if (line.hasOption("o")) { outputFile = line.getOptionValue("o"); } else { outputFile = inputFile; if (outputFile.indexOf(".") < 0) outputFile += "."; String sIndex = (fileIndex == Integer.MAX_VALUE ? "" : "_" + fileIndex); if (sIndex.length() == 0 && outputFile.indexOf(".jvxl") >= 0) sIndex += "_new"; outputFile = outputFile.substring(0, outputFile.lastIndexOf(".")) + sIndex + ".jvxl"; } // Process more command line arguments // these are also passed to vwr bicolor = (line.hasOption("b")); reverseColor = (line.hasOption("r")); if (bicolor && mapFile != null) { Logger.warn("--map option ignored; incompatible with --bicolor"); mapFile = null; } if (line.hasOption("c")) { String s = line.getOptionValue("c"); if (s.indexOf("+") == 0) { isPositiveOnly = true; s = s.substring(1); } cutoff = PT.parseFloat(s); } if (line.hasOption("n")) { if (bicolor) Logger.warn("--min option ignored; incompatible with --bicolor"); else min = PT.parseFloat(line.getOptionValue("n")); } if (line.hasOption("x")) { if (bicolor) Logger.warn("--max option ignored; incompatible with --bicolor"); else max = PT.parseFloat(line.getOptionValue("x")); } // if (line.hasOption("P")) { // phase = line.getOptionValue("P"); // } boolean progressive = line.hasOption("P"); // compose the surface SurfaceGenerator sg = new SurfaceGenerator(null, null, null, null); // input file sg.version = VERSION; if (blockData) sg.setProp("blockData", Boolean.TRUE, null); if (!Float.isNaN(cutoff)) sg.setProp(isPositiveOnly ? "cutoffPositive" : "cutoff", Float.valueOf(cutoff), null); if (bicolor) sg.setProp("sign", null, null); if (reverseColor) sg.setProp("reverseColor", null, null); //if (phase != null) //sg.setProp("phase", phase); if (progressive) sg.setProp("progressive", null, null); if (plane != null) sg.setProp("plane", plane, null); else { if (fileIndex != Integer.MAX_VALUE) sg.setProp("fileIndex", Integer.valueOf(fileIndex), null); Object t = FileReader.getBufferedReaderOrErrorMessageFromName(inputFile); if (t instanceof String) { Logger.error((String) t); return; } BufferedReader br = (BufferedReader) t; sg.setProp("readFile", br, null); try { br.close(); } catch (Exception e) { // } } sg.setProp("title", line.toString(), null); //color scheme is only for VMRL //if (colorScheme != null) { // ColorEncoder ce = new ColorEncoder(null); // ce.setColorScheme(colorScheme, false); // sg.setProp("colorScheme", ce); // } if (!Float.isNaN(min)) sg.setProp("red", Float.valueOf(min), null); if (!Float.isNaN(max)) sg.setProp("blue", Float.valueOf(max), null); if (mapFile != null) { Object t = FileReader.getBufferedReaderOrErrorMessageFromName(mapFile); if (t instanceof String) { Logger.error((String) t); return; } BufferedReader br2 = (BufferedReader) t; sg.setProp("mapColor", br2, null); try { br2.close(); } catch (Exception e) { // } } writeFile(outputFile, (String) sg.getProperty("jvxlFileData", 0)); Logger.info((String) sg.getProperty("jvxlFileInfo", 0)); Logger.info("\ncreated " + outputFile); }
From source file:org.psystems.dicom.daemon.Archive.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set device name, use DCMRCV by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg();//from www .ja v a 2s . co m OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store received objects into files in specified directory <dir>." + " Do not store received objects by default."); opts.addOption(OptionBuilder.create("dest")); OptionBuilder.withArgName("URL"); OptionBuilder.hasArg(); OptionBuilder.withDescription("jdbc connect <URL>.\n example: " + Extractor.connectionStr); opts.addOption(OptionBuilder.create("jdbcconnect")); OptionBuilder.withArgName("config"); OptionBuilder.hasArg(); OptionBuilder.withDescription("config file <config> .\n example: " + Extractor.configStr); opts.addOption(OptionBuilder.create("config")); opts.addOption("startdb", false, "Start 'Derby Network Server' set JavaVM Args: -Dderby.system.home=dtabase/instance -Dderby.drda.startNetworkServer=true -Dderby.drda.portNumber=1527 -Dderby.drda.host=localhost"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Calling AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Calling AETs."); opts.addOption(OptionBuilder.create("calling2dir")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Called AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Called AETs."); opts.addOption(OptionBuilder.create("called2dir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Calling AETs for which no " + " mapping is defined by properties specified by " + "-calling2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("callingdefdir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Called AETs for which no " + " mapping is defined by properties specified by " + "-called2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("calleddefdir")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("register stored objects in cache journal files in specified directory <dir>." + " Do not register stored objects by default."); opts.addOption(OptionBuilder.create("journal")); OptionBuilder.withArgName("pattern"); OptionBuilder.hasArg(); OptionBuilder.withDescription("cache journal file path, with " + "'yyyy' will be replaced by the current year, " + "'MM' by the current month, 'dd' by the current date, " + "'HH' by the current hour and 'mm' by the current minute. " + "'yyyy/MM/dd/HH/mm' by default."); opts.addOption(OptionBuilder.create("journalfilepath")); opts.addOption("defts", false, "accept only default transfer syntax."); opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax."); opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data."); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for DIMSE-RSP; useful for testing asynchronous mode"); opts.addOption(OptionBuilder.create("rspdelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default"); opts.addOption(OptionBuilder.create("requestTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmarchive: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption("V")) { Package p = Archive.class.getPackage(); System.out.println("dcmarchive v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption("h")/* || cl.getArgList().size() == 0*/) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.psystems.dicom.daemon.Dcm2Jpg.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("frame"); OptionBuilder.hasArg(); OptionBuilder.withDescription("frame to convert, 1 (= first frame) by default"); opts.addOption(OptionBuilder.create("f")); OptionBuilder.withArgName("prfile"); OptionBuilder.hasArg();/* w ww . j a v a2 s . com*/ OptionBuilder.withDescription("file path of presentation state to apply"); opts.addOption(OptionBuilder.create("p")); OptionBuilder.withArgName("center"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Window Center"); opts.addOption(OptionBuilder.create("c")); OptionBuilder.withArgName("width"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Window Width"); opts.addOption(OptionBuilder.create("w")); opts.addOption("sigmoid", false, "apply sigmoid VOI LUT function with given Window Center/Width"); opts.addOption("noauto", false, "disable auto-windowing for images w/o VOI attributes"); OptionBuilder.withArgName("file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path of P-Value to gray value map"); opts.addOption(OptionBuilder.create("pv2gray")); OptionBuilder.withArgName(".xxx"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "jpeg file extension used with destination directory argument," + " default: '.jpg'."); opts.addOption(OptionBuilder.create("jpgext")); 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("dcm2jpg: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Dcm2Jpg.class.getPackage(); System.out.println("dcm2jpg 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.psystems.dicom.daemon.DcmRcvOriginal.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set device name, use DCMRCV by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg();//from w w w. j av a2 s .co m OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store received objects into files in specified directory <dir>." + " Do not store received objects by default."); opts.addOption(OptionBuilder.create("dest")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Calling AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Calling AETs."); opts.addOption(OptionBuilder.create("calling2dir")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Called AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Called AETs."); opts.addOption(OptionBuilder.create("called2dir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Calling AETs for which no " + " mapping is defined by properties specified by " + "-calling2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("callingdefdir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Called AETs for which no " + " mapping is defined by properties specified by " + "-called2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("calleddefdir")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("register stored objects in cache journal files in specified directory <dir>." + " Do not register stored objects by default."); opts.addOption(OptionBuilder.create("journal")); OptionBuilder.withArgName("pattern"); OptionBuilder.hasArg(); OptionBuilder.withDescription("cache journal file path, with " + "'yyyy' will be replaced by the current year, " + "'MM' by the current month, 'dd' by the current date, " + "'HH' by the current hour and 'mm' by the current minute. " + "'yyyy/MM/dd/HH/mm' by default."); opts.addOption(OptionBuilder.create("journalfilepath")); opts.addOption("defts", false, "accept only default transfer syntax."); opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax."); opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data."); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for DIMSE-RSP; useful for testing asynchronous mode"); opts.addOption(OptionBuilder.create("rspdelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default"); opts.addOption(OptionBuilder.create("requestTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmrcv: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption("V")) { Package p = DcmRcvOriginal.class.getPackage(); System.out.println("dcmrcv v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption("h") || cl.getArgList().size() == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.psystems.dicom.daemon.DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set device name, use DCMSND by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg();//from w ww.jav a 2 s . c o m 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.psystems.dicom.daemon.Repeater.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set device name, use DCMSND by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg();/*from w ww .ja v a 2s . com*/ 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; }