1
2
3
4 package net.sf.tomp.xml.include.xtcl;
5
6 import net.sf.tomp.xml.type.xtcl.TypeDatabaseFilterCommand;
7 import net.sf.tomp.xml.type.xtcl.TypeDetectorFilterCommand;
8 import net.sf.tomp.xtcl.Command;
9 import net.sf.tomp.xtcl.CommandLineReader;
10 import net.sf.tomp.xtcl.CompilerBase;
11
12 import java.util.StringTokenizer;
13
14 /***
15 * @author tomp
16 */
17 public class XTCompiler extends CompilerBase {
18 public Command compile(String[] cl, CommandLineReader clr) throws Exception {
19 Command commandToReturn = null;
20
21 if (cl.length == 0) {
22 return null;
23 }
24
25 int i = 0;
26 String ci = cl[i++];
27
28
29 if (ci.equalsIgnoreCase("ADAPTIVEXINCLUDER")) {
30 AdaptiveXIncluderCommand command = new AdaptiveXIncluderCommand();
31
32 command.setVar(cl[i++]);
33 command.setTypeDatabaseVar(cl[i++]);
34
35
36 while (i < cl.length) {
37 String param = cl[i++];
38 StringTokenizer pst = new StringTokenizer(param, "=");
39 String name = pst.nextToken();
40 Object value = pst.nextToken();
41
42 command.setParameter(name, value);
43 }
44
45 commandToReturn = command;
46
47
48 } else if (ci.equalsIgnoreCase("ADAPTIVEFILTER")) {
49 AdaptiveFilterCommand command = new AdaptiveFilterCommand();
50
51 command.setVar(cl[i++]);
52 command.setTypeDatabaseVar(cl[i++]);
53
54
55 while (i < cl.length) {
56 String param = cl[i++];
57 StringTokenizer pst = new StringTokenizer(param, "=");
58 String name = pst.nextToken();
59 Object value = pst.nextToken();
60
61 command.setParameter(name, value);
62 }
63
64 commandToReturn = command;
65
66
67 } else if (ci.equalsIgnoreCase("TYPEDETECTORFILTER")) {
68 TypeDetectorFilterCommand command = new TypeDetectorFilterCommand();
69
70 command.setVar(cl[i++]);
71 command.setTypeDatabaseVar(cl[i++]);
72
73
74 while (i < cl.length) {
75 String param = cl[i++];
76 StringTokenizer pst = new StringTokenizer(param, "=");
77 String name = pst.nextToken();
78 Object value = pst.nextToken();
79
80 command.setParameter(name, value);
81 }
82
83 commandToReturn = command;
84
85
86 } else if (ci.equalsIgnoreCase("TYPEDATABASEFILTER")) {
87 TypeDatabaseFilterCommand command = new TypeDatabaseFilterCommand();
88
89 if (i < cl.length) {
90 command.setVar(cl[i++]);
91 }
92
93
94 commandToReturn = command;
95 } else {
96 return compileByNextCompiler(ci, cl, clr);
97 }
98
99 assertWholeLineRead(ci, i, cl, commandToReturn);
100
101
102 return commandToReturn;
103 }
104 }