01: package com.jclark.xml.apps;
02:
03: import java.io.IOException;
04:
05: import com.jclark.xml.parse.io.Parser;
06: import com.jclark.xml.parse.io.ParserImpl;
07: import com.jclark.xml.parse.EntityManagerImpl;
08: import com.jclark.xml.parse.OpenEntity;
09: import com.jclark.xml.parse.NotWellFormedException;
10:
11: /**
12: * @version $Revision: 1.6 $ $Date: 1998/05/08 06:42:22 $
13: */
14: public class Time {
15:
16: /**
17: * Each of the specified argument is treated as the name
18: * of a file containing an XML document to be parsed.
19: * If no arguments are specified, the standard input is read.
20: * The total time in seconds for the parse is reported
21: * on the standard output.
22: * For each document that is not well-formed, a message
23: * is written in the standard error.
24: */
25: public static void main(String args[]) throws IOException {
26: long startTime = System.currentTimeMillis();
27: boolean hadErr = false;
28: if (args.length == 0)
29: hadErr = !parseEntity(EntityManagerImpl.openStandardInput());
30: else {
31: for (int i = 0; i < args.length; i++)
32: if (!parseEntity(EntityManagerImpl.openFile(args[i])))
33: hadErr = true;
34: }
35: System.out
36: .println((System.currentTimeMillis() - startTime) / 1000.0);
37: System.exit(hadErr ? 1 : 0);
38: }
39:
40: static boolean parseEntity(OpenEntity entity) throws IOException {
41: Parser parser = new ParserImpl();
42: try {
43: parser.parseDocument(entity);
44: return true;
45: } catch (NotWellFormedException e) {
46: System.err.println(e.getMessage());
47: return false;
48: }
49: }
50: }
|