/** ** Main entery point for debugging/testing */ public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); Print.setAllOutputToStdout(true); Print.setEncoding(ENCODING_UTF8); String accountID = RTConfig.getString(ARG_ACCOUNT, "demo"); GoogleGeocodeV2 gn = new GoogleGeocodeV2("google", null, null); /* reverse geocode */ if (RTConfig.hasProperty(ARG_REVGEOCODE)) { GeoPoint gp = new GeoPoint(RTConfig.getString(ARG_REVGEOCODE, null)); if (!gp.isValid()) { Print.logInfo("Invalid GeoPoint specified"); System.exit(1); } Print.logInfo("Reverse-Geocoding GeoPoint: " + gp); Print.sysPrintln( "RevGeocode = " + gn.getReverseGeocode(gp, null /*localeStr*/, false /*cache*/)); // Note: Even though the values are printed in UTF-8 character encoding, the // characters may not appear to be property displayed if the console display // does not support UTF-8. System.exit(0); } /* no options */ Print.sysPrintln("No options specified"); System.exit(1); }
public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java Parser [input]"); System.exit(0); } Parser p = new Parser(args[0]); }
private Document getXMLDocument(InputStream is) { SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document doc = null; try { doc = builder.build(is); } catch (JDOMException e) { e.printStackTrace(); System.exit(-1); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } return doc; }
/** * EPML2PNML * * @param args String[] */ private static void EPML2PNML(String[] args) { if (args.length != 2) { System.out.println("���ṩEPML�ļ�·����PNML���Ŀ¼!"); System.exit(-1); } epmlImport epml = new epmlImport(); // load the single epml file String filename = args[0]; try { EPCResult epcRes = (EPCResult) epml.importFile(new FileInputStream(filename)); // convert all epc models to pnml files ArrayList<ConfigurableEPC> alEPCs = epcRes.getAllEPCs(); PnmlExport export = new PnmlExport(); for (ConfigurableEPC epc : alEPCs) { String id = epc.getIdentifier(); if (id.equals("1An_klol") || id.equals("1An_l1y8") || id.equals("1Ex_dzq9") || id.equals("1Ex_e6dx") || id.equals("1Ku_9soy") || id.equals("1Ku_a4cg") || id.equals("1Or_lojl") || id.equals("1Pr_d1ur") || id.equals("1Pr_djki") || id.equals("1Pr_dkfa") || id.equals("1Pr_dl73") || id.equals("1Ve_musj") || id.equals("1Ve_mvwz")) continue; // save pnml files to the same folder File outFile = new File(args[1] + "/" + id + ".pnml"); if (outFile.exists()) continue; FileOutputStream fos = new FileOutputStream(outFile); PetriNet petri = AMLtoPNML.convert(epc); try { export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos); } catch (Exception ex1) { ex1.printStackTrace(System.out); } } } catch (IOException ex) { ex.printStackTrace(System.out); } System.out.println("EPML Conversion Done"); }
/** * Main program. * * <p>\u0040param args Program parameters. */ public static void main(String[] args) { // Initialize. try { if (!initialize(args)) { System.exit(1); } // Process all files. long startTime = System.currentTimeMillis(); int filesProcessed = processFiles(args); long processingTime = (System.currentTimeMillis() - startTime + 999) / 1000; // Terminate. terminate(filesProcessed, processingTime); } catch (Exception e) { System.out.println(e.getMessage()); } }
private static void AML2PNML(String[] args) { if (args.length != 3) { System.out.println("���ṩAML����Ŀ¼��PNML���Ŀ¼�Լ��ֵ��ļ�!"); System.exit(-1); } System.out.println("����Ŀ¼��" + args[0]); System.out.println("���Ŀ¼��" + args[1]); System.out.println("�ֵ��ļ���" + args[2]); // load the dict AMLtoPNML.loadDict(args[2]); File srcDir = new File(args[0]); File[] lstAML = srcDir.listFiles(); PnmlExport export = new PnmlExport(); for (int i = 0; i < lstAML.length; i++) { if (lstAML[i].isDirectory()) { continue; } System.out.print(lstAML[i].getName() + "==>"); try { FileInputStream fis = new FileInputStream(lstAML[i]); int idx = lstAML[i].getName().indexOf(".xml"); File outFile = new File(args[1] + "/" + lstAML[i].getName().substring(0, idx) + ".pnml"); FileOutputStream fos = new FileOutputStream(outFile); EPCResult epcRes = (EPCResult) AMLtoPNML.importFile(fis); ConfigurableEPC epc = epcRes.getMainEPC(); PetriNet petri = AMLtoPNML.convert(epc); export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos); System.out.println(outFile.getName()); } catch (FileNotFoundException ex) { ex.printStackTrace(System.out); } catch (IOException ioe) { ioe.printStackTrace(System.out); } catch (Exception e) { e.printStackTrace(System.out); } } System.out.println("Conversion Done"); }
/** ** Main entery point for debugging/testing */ public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); Print.setAllOutputToStdout(true); Print.setEncoding(ENCODING_UTF8); /* host */ String host = RTConfig.getString("host", null); if (!StringTools.isBlank(host)) { HOST_PRIMARY = host; } /* GeoPoint */ GeoPoint gp = new GeoPoint(RTConfig.getString("gp", null)); if (!gp.isValid()) { Print.logInfo("Invalid GeoPoint specified"); System.exit(1); } Print.logInfo("Reverse-Geocoding GeoPoint: " + gp); /* Reverse Geocoding */ Nominatim gn = new Nominatim("nominatim", null, RTConfig.getCommandLineProperties()); Print.sysPrintln("RevGeocode = " + gn.getReverseGeocode(gp, null /*localeStr*/)); }
public static void main(String[] args) throws IOException { String filename = "z.xml"; // NOT LOCALIZABLE, main try { String uri = "file:" + new File(filename).getAbsolutePath(); // NOT LOCALIZABLE, main // // turn it into an in-memory object. // Parser parser = getParser(); parser.setDocumentHandler(new XmlParser()); parser.setErrorHandler(new MyErrorHandler()); parser.parse(uri); } catch (SAXParseException err) { Debug.trace( "** Parsing error" // NOT LOCALIZABLE, main + ", line " + err.getLineNumber() // NOT LOCALIZABLE + ", uri " + err.getSystemId()); // NOT LOCALIZABLE Debug.trace(" " + err.getMessage()); } catch (SAXException e) { Exception x = e; if (e.getException() != null) x = e.getException(); x.printStackTrace(); } catch (Throwable t) { t.printStackTrace(); } byte[] buf = new byte[256]; Debug.trace("Press ENTER to exit."); // NOT LOCALIZABLE System.in.read(buf, 0, 256); System.exit(0); }
/** The main entry point */ public static void main(String[] args) throws FileNotFoundException, IOException { String xmlfile = null; int debug = 0; int maxErrs = 10; boolean nsAware = true; boolean validating = true; boolean showWarnings = (debug > 2); boolean showErrors = true; Vector catalogFiles = new Vector(); for (int i = 0; i < args.length; i++) { if (args[i].equals("-c")) { ++i; catalogFiles.add(args[i]); continue; } if (args[i].equals("-w")) { validating = false; continue; } if (args[i].equals("-v")) { validating = true; continue; } if (args[i].equals("-n")) { nsAware = false; continue; } if (args[i].equals("-N")) { nsAware = true; continue; } if (args[i].equals("-d")) { ++i; String debugstr = args[i]; try { debug = Integer.parseInt(debugstr); if (debug >= 0) { Debug.setDebug(debug); showWarnings = (debug > 2); } } catch (Exception e) { // nop } continue; } if (args[i].equals("-E")) { ++i; String errstr = args[i]; try { int errs = Integer.parseInt(errstr); if (errs >= 0) { maxErrs = errs; } } catch (Exception e) { // nop } continue; } xmlfile = args[i]; } if (xmlfile == null) { System.out.println("Usage: org.apache.xml.resolver.apps.xread [opts] xmlfile"); System.exit(1); } ResolvingXMLReader reader = new ResolvingXMLReader(); try { reader.setFeature("http://xml.org/sax/features/namespaces", nsAware); reader.setFeature("http://xml.org/sax/features/validation", validating); } catch (SAXException e) { // nop; } Catalog catalog = reader.getCatalog(); for (int count = 0; count < catalogFiles.size(); count++) { String file = (String) catalogFiles.elementAt(count); catalog.parseCatalog(file); } XParseError xpe = new XParseError(showErrors, showWarnings); xpe.setMaxMessages(maxErrs); reader.setErrorHandler(xpe); String parseType = validating ? "validating" : "well-formed"; String nsType = nsAware ? "namespace-aware" : "namespace-ignorant"; if (maxErrs > 0) { System.out.println("Attempting " + parseType + ", " + nsType + " parse"); } Date startTime = new Date(); try { reader.parse(xmlfile); } catch (SAXException sx) { System.out.println("SAX Exception: " + sx); } catch (Exception e) { e.printStackTrace(); } Date endTime = new Date(); long millisec = endTime.getTime() - startTime.getTime(); long secs = 0; long mins = 0; long hours = 0; if (millisec > 1000) { secs = millisec / 1000; millisec = millisec % 1000; } if (secs > 60) { mins = secs / 60; secs = secs % 60; } if (mins > 60) { hours = mins / 60; mins = mins % 60; } if (maxErrs > 0) { System.out.print("Parse "); if (xpe.getFatalCount() > 0) { System.out.print("failed "); } else { System.out.print("succeeded "); System.out.print("("); if (hours > 0) { System.out.print(hours + ":"); } if (hours > 0 || mins > 0) { System.out.print(mins + ":"); } System.out.print(secs + "." + millisec); System.out.print(") "); } System.out.print("with "); int errCount = xpe.getErrorCount(); int warnCount = xpe.getWarningCount(); if (errCount > 0) { System.out.print(errCount + " error"); System.out.print(errCount > 1 ? "s" : ""); System.out.print(" and "); } else { System.out.print("no errors and "); } if (warnCount > 0) { System.out.print(warnCount + " warning"); System.out.print(warnCount > 1 ? "s" : ""); System.out.print("."); } else { System.out.print("no warnings."); } System.out.println(""); } if (xpe.getErrorCount() > 0) { System.exit(1); } }
/** * @param errCode * @param msg */ public static void exit(int errCode, String msg) { System.err.println(msg); System.exit(errCode); }
public static void main(String[] args) { AML2PNML(args); // EPML2PNML(args); System.exit(0); }
public static void main(String args[]) { if (args.length < 3) { System.err.println("Usage: Generate model-file ( -s length | -c count length )"); System.exit(1); } try { SAXParserFactory saxFactory = SAXParserFactory.newInstance(); saxFactory.setNamespaceAware(true); SAXParser saxParser = saxFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); XMLModelReader modelReader = new XMLModelReader(xmlReader); FileReader modelInput = new FileReader(args[0]); InputSource source = new InputSource(modelInput); Model model = modelReader.load(source); modelInput.close(); model.check(); if (args[1].equals("-s")) { int[][] result = model.generateSequence(Integer.parseInt(args[2])); List lexicon = model.getLexicon(); for (int i = 0; i < result[0].length; i++) { System.out.print((Character) lexicon.get(result[0][i])); } System.out.println(); int numberOfStates = model.getNumberOfStates(); if (numberOfStates > 9) { for (int i = 0; i < result[1].length; i++) { System.out.print(result[1][i]); System.out.print(','); } } else { for (int i = 0; i < result[1].length; i++) { System.out.print(result[1][i]); } } System.out.println(); for (int i = 1; i < numberOfStates; i++) { System.out.println(i + " = " + model.getStateName(i)); } } else if (args[1].equals("-c")) { List lexicon = model.getLexicon(); int count = Integer.parseInt(args[2]); int length = Integer.parseInt(args[3]); ListOfSequences uniqueSeqs = new ListOfSequences(); for (int i = 0; i < count; i++) { int[][] result = model.generateSequence(length); uniqueSeqs.addSequence(result[0]); } Iterator seqs = uniqueSeqs.iterator(); while (seqs.hasNext()) { SequenceCount seq = (SequenceCount) seqs.next(); int[] key = seq.getSequence(); for (int i = 0; i < key.length; i++) { System.out.print((Character) lexicon.get(key[i])); } System.out.print(','); System.out.println(seq.getCount()); } } } catch (java.io.IOException ex) { ex.printStackTrace(); } catch (org.xml.sax.SAXException ex) { System.err.println(ex.getMessage()); } catch (javax.xml.parsers.ParserConfigurationException ex) { ex.printStackTrace(); } }