1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package ca.uhn.hl7v2.conf.classes.generator.builders;
32
33 import java.io.*;
34
35 import ca.uhn.hl7v2.conf.classes.exceptions.*;
36
37
38
39
40
41
42
43
44 public class ConfGen {
45
46
47
48
49 public static void main(String[] args) {
50 ConfGenf/classes/generator/builders/ConfGen.html#ConfGen">ConfGen gc = new ConfGen();
51 CommandParserses/generator/builders/CommandParser.html#CommandParser">CommandParser cp = new CommandParser();
52
53 cp.parse(args);
54
55 if (cp.getHelpFlag()) {
56 System.out.println("Usage: ConfGen [-vht] SOURCE DESTINATION PACKAGENAME");
57 return;
58 }
59
60 if (cp.getErrFlag()) {
61 System.out.println("ConfGen: command line parse error");
62 System.out.println("ConfGen: " + cp.getError());
63 return;
64 }
65
66 DeploymentManagergenerator/builders/DeploymentManager.html#DeploymentManager">DeploymentManager dm = new DeploymentManager(cp.getDest(), cp.getPackage());
67 if (cp.getTestFlag()) {
68 System.out.println("ConfGen: system test enabled");
69 gc.test();
70 return;
71 }
72 if (cp.getVerbFlag()) {
73 System.out.println("ConfGen: verbose display enabled");
74 dm.setVerbose(true);
75 }
76
77 System.out.println("Generating Source...");
78 gc.generateConf(dm, cp);
79 System.out.println("Done.");
80 }
81
82
83
84
85
86 public void generateConf(DeploymentManager dm, CommandParser cp) {
87 BufferedReader in = null;
88 try {
89 File f = new File(cp.getSource());
90 in = new BufferedReader(new FileReader(f));
91 char[] cbuf = new char[(int) f.length()];
92 in.read(cbuf, 0, (int) f.length());
93 dm.generate(String.valueOf(cbuf));
94 } catch (FileNotFoundException e) {
95 System.out.println("Filenotfoundexception: " + e.toString());
96 } catch (IOException e) {
97 System.out.println("IOexception:\n" + e.toString() + "\n");
98 } catch (ConformanceError e) {
99 System.out.println("ConformanceError:\n" + e.toString() + "\n");
100 } catch (ConformanceException e) {
101 System.out.println("ConformanceException:\n" + e.toString() + "\n");
102 } finally {
103 if (in != null)
104 try {
105 in.close();
106 } catch (IOException ignored) {
107 }
108 }
109 }
110
111
112
113 public void test() {
114 try {
115 System.out.print("Checking for XML Parser:");
116 Class.forName("org.w3c.dom.Element");
117 System.out.println(" PASS");
118 } catch (ClassNotFoundException e) {
119 System.out.println(" FAIL");
120 }
121
122 try {
123 System.out.print("Checking for Xerces:");
124 Class.forName("com.sun.org.apache.xerces.internal.parsers.DOMParser");
125 System.out.println(" PASS");
126 } catch (ClassNotFoundException e) {
127 System.out.println(" FAIL");
128 }
129
130 try {
131 System.out.print("Checking for Conformance Classes:");
132 Class.forName("ca.uhn.hl7v2.conf.classes.generator.builders.ConformanceMessageBuilder");
133 System.out.println(" PASS");
134 } catch (ClassNotFoundException e) {
135 System.out.println(" FAIL");
136 }
137
138 try {
139 System.out.print("Checking for Apache Ant:");
140 Class.forName("org.apache.tools.ant.Main");
141 System.out.println(" PASS");
142 } catch (ClassNotFoundException e) {
143 System.out.println(" FAIL");
144 }
145 }
146 }