List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:com.esri.geoportal.base.metadata.MetadataCLI.java
/** //from w w w . ja v a2 s .c o m * <h1>run the javascript Evaluators.js scripts</h1> * from command line for testing. * * <div> java com.esri.geoportal.base.metadata.MetadataCLI -md={XMLFile_fullpath} *</div> * * <p><b>Note:</b> This only produces the basic JSON elements seen in the * elastic search json document. Other steps, such as itemID are found in {@link com.esri.geoportal.lib.elastic.request.PublishMetadataRequest#prePublish(ElasticContext, AccessUtil, AppResponse, MetadataDocument)} </p> * *<p><b>Note:</b> mainly tested in JetBrains Intellij</p> * <p><b>Note:</b> mvn command line call is in contrib</p> * * @author David Valentine * */ public static void main(String[] args) { Option help = Option.builder("h").required(false).longOpt("help").desc("HELP").build(); // Option metadataJsDir = // Option.builder("js") // .required(true) // .hasArg() // .longOpt("jsdir") // .desc("Base metadata javascript directory") // // .type(File.class) // test if this is a directory // .build(); ; /* not needed. js read from classpath, metadata/js/Evaluator.js required to be on classpath. TODO: test if this works in/on a jar, if not might need to test if running in a jar, and set appropriate resource location */ Option metadataFile = Option.builder("md").required(true).hasArg().longOpt("metdatafile") .desc("Metadata File") // .type(File.class) .build(); ; Option verbose = Option.builder("v").required(false) .longOpt("verboase").build(); ; Options options = new Options(); options.addOption(help); //options.addOption(metadataJsDir); options.addOption(metadataFile); ; options.addOption(verbose); ; // create the parser CommandLineParser parser = new DefaultParser(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); Boolean v = line.hasOption("v"); String mds = line.getOptionValue("md"); File md = new File(mds); if (!md.isFile()) System.err.println("Md Metadata must be a file"); testScriptEvaluator(md, v); } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); } catch (Exception ex) { System.err.println("Metadata Evaluation Failed. Reason: " + ex.getMessage()); } }
From source file:com.genentech.chemistry.tool.SDF2HtmlTab.java
public static void main(String[] args) throws ParseException, JDOMException, IOException { long start = System.currentTimeMillis(); // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input sd file"); opt.setRequired(true);/*from w ww .ja v a 2s . c o m*/ options.addOption(opt); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); String inFile = cmd.getOptionValue("in"); args = cmd.getArgs(); if (args.length > 0) { exitWithHelp(options); } oemolistream ifs; Set<String> tagSet = getTagSet(inFile); System.out.println( "<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'>"); System.out.println("<head>"); System.out.println("<BASE href='" + BASEUrl + "'/>"); System.out.println( "<link href='/" + Settings.SERVLET_CONTEXT + "/css/Aestel.css' rel='stylesheet' type='text/css'/>"); System.out.println("<style type='text/css'>"); System.out.println("td.stru { width: " + (IMGWidth + 2) + "px; height: " + (IMGHeigth + 4) + "px; vertical-align: top; }"); System.out.println("table.grid tr.first { border-top: 3px solid black; }"); // for tables in tables System.out.println("table.grid table td { border: 0px; text-align: right;}"); System.out.println("table.grid table td:first-child { text-align: left;}"); System.out.println("th.head { border-left: 1px solid black; border-bottom: 2px solid black;\n" + " empty-cells: show; background-color: #6297ff; color: #000000;\n" + " padding: 0em .3em 0em .3em; vertical-align: middle; }"); System.out.println("</style>"); System.out.println("</head>"); System.out.println("<body>"); System.out.println("<table class='grid'><tr>"); System.out.println("<th class='head'>Structure</th>"); for (String tag : tagSet) System.out.println("<th class='head'>" + tag + "</th>"); System.out.println("</tr>"); OEGraphMol mol = new OEGraphMol(); ifs = new oemolistream(inFile); int iCounter = 0; while (oechem.OEReadMolecule(ifs, mol)) { iCounter++; System.out.println("<tr>"); String smi = OETools.molToCanSmi(mol, true); String img = DepictHelper.DEFAULT.getExcelSmilesImageElement(BASEUrl, 120, 120, ImageType.PNG, smi, null); System.out.print(" <td class='stru'>"); System.out.print(img); System.out.println("</td>"); for (String tag : tagSet) { String val = oechem.OEGetSDData(mol, tag); System.out.print(" <td>"); System.out.print(val); System.out.println("</td>"); } System.out.println("</tr>"); } System.out.println("</table></body></html>"); System.err.printf("SDF2HtmlTab: Exported %d structures in %dsec\n", iCounter, (System.currentTimeMillis() - start) / 1000); }
From source file:de.tudarmstadt.lt.lm.app.GenerateNgrams.java
@SuppressWarnings("static-access") public static void main(String[] args) { Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?")); opts.addOption(OptionBuilder.withLongOpt("ptype").withArgName("class").hasArg().withDescription( "specify the instance of the language model provider that you want to use: {LtSegProvider, BreakIteratorStringProvider, UimaStringProvider, PreTokenizedStringProvider} (default: LtSegProvider)") .create("p")); opts.addOption(OptionBuilder.withLongOpt("cardinality").withArgName("ngram-order").hasArg().withDescription( "Specify the cardinality of the ngrams (min. 1). Specify a range using 'from-to'. (Examples: 5 = extract 5grams; 1-5 = extract 1grams, 2grams, ..., 5grams; default: 1-5).") .create("n")); opts.addOption(OptionBuilder.withLongOpt("dir").withArgName("directory").isRequired().hasArg() .withDescription(/*from w w w. ja va 2 s .c om*/ "specify the directory that contains '.txt' files that are used as source for generating ngrams.") .create("d")); opts.addOption(OptionBuilder.withLongOpt("overwrite").withDescription("Overwrite existing ngram file.") .create("w")); CommandLine cli = null; try { cli = new GnuParser().parse(opts, args); } catch (Exception e) { print_usage(opts, e.getMessage()); } if (cli.hasOption("?")) print_usage(opts, null); AbstractStringProvider prvdr = null; try { prvdr = StartLM .getStringProviderInstance(cli.getOptionValue("ptype", LtSegProvider.class.getSimpleName())); } catch (Exception e) { print_usage(opts, String.format("Could not instantiate LmProvider '%s': %s", cli.getOptionValue("ptype", LtSegProvider.class.getSimpleName()), e.getMessage())); } String n_ = cli.getOptionValue("cardinality", "1-5"); int dash_index = n_.indexOf('-'); int n_e = Integer.parseInt(n_.substring(dash_index + 1, n_.length()).trim()); int n_b = n_e; if (dash_index == 0) n_b = 1; if (dash_index > 0) n_b = Math.max(1, Integer.parseInt(n_.substring(0, dash_index).trim())); final File src_dir = new File(cli.getOptionValue("dir")); boolean overwrite = Boolean.parseBoolean(cli.getOptionValue("overwrite", "false")); generateNgrams(src_dir, prvdr, n_b, n_e, overwrite); }
From source file:com.microsoft.azure.management.appservice.samples.ManageWebAppStorageAccountConnection.java
/** * Main entry point.//from w w w . j a v a2s.c o m * @param args the parameters */ public static void main(String[] args) { try { //============================================================= // Authenticate final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); Azure azure = Azure.configure().withLogLevel(LogLevel.BASIC).authenticate(credFile) .withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:edu.msu.cme.rdp.readseq.ToFasta.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("m", "mask", true, "Mask sequence name indicating columns to drop"); String maskSeqid = null;/*from w ww . j a v a 2 s.c o m*/ try { CommandLine line = new PosixParser().parse(options, args); if (line.hasOption("mask")) { maskSeqid = line.getOptionValue("mask"); } args = line.getArgs(); if (args.length == 0) { throw new Exception(""); } } catch (Exception e) { new HelpFormatter().printHelp("USAGE: to-fasta <input-file>", options); System.err.println("ERROR: " + e.getMessage()); System.exit(1); return; } SeqReader reader = null; FastaWriter out = new FastaWriter(System.out); Sequence seq; int totalSeqs = 0; long totalTime = System.currentTimeMillis(); for (String fname : args) { if (fname.equals("-")) { reader = new SequenceReader(System.in); } else { File seqFile = new File(fname); if (maskSeqid == null) { reader = new SequenceReader(seqFile); } else { reader = new IndexedSeqReader(seqFile, maskSeqid); } } long startTime = System.currentTimeMillis(); int thisFileTotalSeqs = 0; while ((seq = reader.readNextSequence()) != null) { out.writeSeq(seq.getSeqName().replace(" ", "_"), seq.getDesc(), seq.getSeqString()); thisFileTotalSeqs++; } totalSeqs += thisFileTotalSeqs; System.err.println("Converted " + thisFileTotalSeqs + " (total sequences: " + totalSeqs + ") sequences from " + fname + " (" + reader.getFormat() + ") to fasta in " + (System.currentTimeMillis() - startTime) / 1000 + " s"); } System.err.println("Converted " + totalSeqs + " to fasta in " + (System.currentTimeMillis() - totalTime) / 1000 + " s"); out.close(); }
From source file:module.entities.UsernameChecker.CheckOpengovUsernames.java
/** * @param args the command line arguments *///from ww w . j a va2s .co m public static void main(String[] args) throws SQLException, IOException { // args = new String[1]; // args[0] = "searchConf.txt"; Date d = new Date(); long milTime = d.getTime(); long execStart = System.nanoTime(); Timestamp startTime = new Timestamp(milTime); long lStartTime; long lEndTime = 0; int status_id = 1; JSONObject obj = new JSONObject(); if (args.length != 1) { System.out.println("None or too many argument parameters where defined! " + "\nPlease provide ONLY the configuration file name as the only argument."); } else { try { configFile = args[0]; initLexicons(); Database.init(); lStartTime = System.currentTimeMillis(); System.out.println("Opengov username identification process started at: " + startTime); usernameCheckerId = Database.LogUsernameChecker(lStartTime); TreeMap<Integer, String> OpenGovUsernames = Database.GetOpenGovUsers(); HashSet<ReportEntry> report_names = new HashSet<>(); if (OpenGovUsernames.size() > 0) { for (int userID : OpenGovUsernames.keySet()) { String DBusername = Normalizer .normalize(OpenGovUsernames.get(userID).toUpperCase(locale), Normalizer.Form.NFD) .replaceAll("\\p{M}", ""); String username = ""; int type; String[] splitUsername = DBusername.split(" "); if (checkNameInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 1; } else if (checkOrgInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 2; } else { username = DBusername; type = -1; } ReportEntry cerEntry = new ReportEntry(userID, username.trim(), type); report_names.add(cerEntry); } status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", ""); Database.UpdateOpengovUsersReportName(report_names); lEndTime = System.currentTimeMillis(); } else { status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", "No usernames needed to be checked"); lEndTime = System.currentTimeMillis(); } } catch (Exception ex) { System.err.println(ex.getMessage()); status_id = 3; obj.put("message", "Opengov username checker encountered an error"); obj.put("details", ex.getMessage().toString()); lEndTime = System.currentTimeMillis(); } } long execEnd = System.nanoTime(); long executionTime = (execEnd - execStart); System.out.println("Total process time: " + (((executionTime / 1000000) / 1000) / 60) + " minutes."); Database.UpdateLogUsernameChecker(lEndTime, status_id, usernameCheckerId, obj); Database.closeConnection(); }
From source file:PropertyTable.java
/** This main method allows the class to be demonstrated standalone */ public static void main(String[] args) { // Specify the name of the class as a command-line argument Class beanClass = null;/* w w w .ja v a 2 s . c om*/ try { // Use reflection to get the Class from the classname beanClass = Class.forName("javax.swing.JLabel"); } catch (Exception e) { // Report errors System.out.println("Can't find specified class: " + e.getMessage()); System.out.println("Usage: java TableDemo <JavaBean class name>"); System.exit(0); } // Create a table to display the properties of the specified class JTable table = new PropertyTable(beanClass); // Then put the table in a scrolling window, put the scrolling // window into a frame, and pop it all up on to the screen JScrollPane scrollpane = new JScrollPane(table); JFrame frame = new JFrame("Properties of JavaBean: "); frame.getContentPane().add(scrollpane); frame.setSize(500, 400); frame.setVisible(true); }
From source file:com.amalto.workbench.utils.ResourcesUtil.java
public static void main(String[] args) { // init();/*from w w w .j a v a 2 s . c o m*/ // getXMLString("http://localhost:8080"+picURI); // getResourcesNameListFromURI("http://localhost:8080"+cmURI); // getResourcesMapFromURI("http://localhost:8080"+cmURI); try { postResourcesFromFile("demo2", "d:/bud.xsd", "http://localhost:8080" + cmURI);//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:Base64Decoder.java
/** * Test the decoder.//from w w w.ja va 2 s. co m * Run it with one argument: the string to be decoded, it will print out * the decoded value. */ public static void main(String args[]) { if (args.length == 1) { try { Base64Decoder b = new Base64Decoder(args[0]); System.out.println("[" + b.processString() + "]"); } catch (Exception e) { System.out.println("Invalid Base64 format !"); System.exit(1); } } else if ((args.length == 2) && (args[0].equals("-f"))) { try { FileInputStream in = new FileInputStream(args[1]); Base64Decoder b = new Base64Decoder(in, System.out); b.process(); } catch (Exception ex) { System.out.println("error: " + ex.getMessage()); System.exit(1); } } else { System.out.println("Base64Decoder [strong] [-f file]"); } System.exit(0); }
From source file:com.genentech.chemistry.openEye.apps.SDFSubRMSD.java
public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file oe-supported"); opt.setRequired(true);//from w w w . j a va 2 s. c om options.addOption(opt); opt = new Option("out", true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); opt = new Option("fragFile", true, "file with single 3d substructure query"); opt.setRequired(false); options.addOption(opt); opt = new Option("isMDL", false, "if given the fragFile is suposed to be an mdl query file, query features are supported."); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); String fragFile = cmd.getOptionValue("fragFile"); // read fragment OESubSearch ss; oemolistream ifs = new oemolistream(fragFile); OEMolBase mol; if (!cmd.hasOption("isMDL")) { mol = new OEGraphMol(); oechem.OEReadMolecule(ifs, mol); ss = new OESubSearch(mol, OEExprOpts.AtomicNumber, OEExprOpts.BondOrder); } else { int aromodel = OEIFlavor.Generic.OEAroModelOpenEye; int qflavor = ifs.GetFlavor(ifs.GetFormat()); ifs.SetFlavor(ifs.GetFormat(), (qflavor | aromodel)); int opts = OEMDLQueryOpts.Default | OEMDLQueryOpts.SuppressExplicitH; OEQMol qmol = new OEQMol(); oechem.OEReadMDLQueryFile(ifs, qmol, opts); ss = new OESubSearch(qmol); mol = qmol; } double nSSatoms = mol.NumAtoms(); double sssCoords[] = new double[mol.GetMaxAtomIdx() * 3]; mol.GetCoords(sssCoords); mol.Clear(); ifs.close(); if (!ss.IsValid()) throw new Error("Invalid query " + args[0]); ifs = new oemolistream(inFile); oemolostream ofs = new oemolostream(outFile); int count = 0; while (oechem.OEReadMolecule(ifs, mol)) { count++; double rmsd = Double.MAX_VALUE; double molCoords[] = new double[mol.GetMaxAtomIdx() * 3]; mol.GetCoords(molCoords); for (OEMatchBase mb : ss.Match(mol, false)) { double r = 0; for (OEMatchPairAtom mp : mb.GetAtoms()) { OEAtomBase asss = mp.getPattern(); double sx = sssCoords[asss.GetIdx() * 3]; double sy = sssCoords[asss.GetIdx() * 3]; double sz = sssCoords[asss.GetIdx() * 3]; OEAtomBase amol = mp.getTarget(); double mx = molCoords[amol.GetIdx() * 3]; double my = molCoords[amol.GetIdx() * 3]; double mz = molCoords[amol.GetIdx() * 3]; r += Math.sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my) + (sz - mz) * (sz - mz)); } r /= nSSatoms; rmsd = Math.min(rmsd, r); } if (rmsd != Double.MAX_VALUE) oechem.OESetSDData(mol, "SSSrmsd", String.format("%.3f", rmsd)); oechem.OEWriteMolecule(ofs, mol); mol.Clear(); } ifs.close(); ofs.close(); mol.delete(); ss.delete(); }