1 package com
.interrupt
.bookkeeping
.cc
;
3 import java
.util
.ArrayList
;
4 import java
.util
.HashMap
;
8 import org
.apache
.log4j
.Logger
;
10 import com
.interrupt
.bookkeeping
.account
.GDebit
;
11 import com
.interrupt
.bookkeeping
.cc
.analysis
.DepthFirstAdapter
;
12 import com
.interrupt
.bookkeeping
.cc
.bkell
.Bkell
;
13 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.AbstractCommand
;
14 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.GOption
;
15 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.Token
;
16 import com
.interrupt
.bookkeeping
.cc
.node
.AAccountCommandoption
;
17 import com
.interrupt
.bookkeeping
.cc
.node
.AAccountCommandtoken
;
18 import com
.interrupt
.bookkeeping
.cc
.node
.AAccountsCommandtoken
;
19 import com
.interrupt
.bookkeeping
.cc
.node
.AAmountCommandoption
;
20 import com
.interrupt
.bookkeeping
.cc
.node
.ACreditCommandtoken
;
21 import com
.interrupt
.bookkeeping
.cc
.node
.ACurrencyCommandoption
;
22 import com
.interrupt
.bookkeeping
.cc
.node
.ACweightCommandoption
;
23 import com
.interrupt
.bookkeeping
.cc
.node
.ADateCommandoption
;
24 import com
.interrupt
.bookkeeping
.cc
.node
.ADebitCommandtoken
;
25 import com
.interrupt
.bookkeeping
.cc
.node
.AEntriesCommandtoken
;
26 import com
.interrupt
.bookkeeping
.cc
.node
.AEntryCommandoption
;
27 import com
.interrupt
.bookkeeping
.cc
.node
.AEntryCommandtoken
;
28 import com
.interrupt
.bookkeeping
.cc
.node
.AEntryidCommandoption
;
29 import com
.interrupt
.bookkeeping
.cc
.node
.AEntrynumCommandoption
;
30 import com
.interrupt
.bookkeeping
.cc
.node
.AFileCommandoption
;
31 import com
.interrupt
.bookkeeping
.cc
.node
.AGroupCommandoption
;
32 import com
.interrupt
.bookkeeping
.cc
.node
.AGroupidCommandoption
;
33 import com
.interrupt
.bookkeeping
.cc
.node
.AIdCommandoption
;
34 import com
.interrupt
.bookkeeping
.cc
.node
.AInputOption
;
35 import com
.interrupt
.bookkeeping
.cc
.node
.AJournalCommandoption
;
36 import com
.interrupt
.bookkeeping
.cc
.node
.AJournalCommandtoken
;
37 import com
.interrupt
.bookkeeping
.cc
.node
.AJournalsCommandtoken
;
38 import com
.interrupt
.bookkeeping
.cc
.node
.ANameCommandoption
;
39 import com
.interrupt
.bookkeeping
.cc
.node
.AOptsCommandInput
;
40 import com
.interrupt
.bookkeeping
.cc
.node
.APasswdCommandoption
;
41 import com
.interrupt
.bookkeeping
.cc
.node
.AProfiledetailCommandtoken
;
42 import com
.interrupt
.bookkeeping
.cc
.node
.AProfiledetailsCommandtoken
;
43 import com
.interrupt
.bookkeeping
.cc
.node
.ASystemCommandtoken
;
44 import com
.interrupt
.bookkeeping
.cc
.node
.ATransactionCommandtoken
;
45 import com
.interrupt
.bookkeeping
.cc
.node
.ATypeCommandoption
;
46 import com
.interrupt
.bookkeeping
.cc
.node
.AUnameCommandoption
;
47 import com
.interrupt
.bookkeeping
.cc
.node
.AUserCommandtoken
;
48 import com
.interrupt
.bookkeeping
.cc
.node
.AUseridCommandoption
;
49 import com
.interrupt
.bookkeeping
.cc
.node
.AUsersCommandtoken
;
50 import com
.interrupt
.bookkeeping
.cc
.node
.PCommandoption
;
52 public class CommandOptionVisitor
extends DepthFirstAdapter
{
55 private AbstractCommand command
= null;
56 private Logger logger
= Logger
.getLogger(CommandOptionVisitor
.class);
59 public AbstractCommand
getCommand() {
62 public void setCommand(AbstractCommand command
) {
63 this.command
= command
;
70 public void caseAEntryCommandoption(AEntryCommandoption node
) {
72 String node_t
= node
.getEntryOpt().getText();
73 //logger.debug("caseAEntryCommandoption CALLED ["+node_t+"]");
75 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
76 result
= result
.trim();
78 GOption option
= new GOption();
79 option
.setName("entry");
80 option
.setValue(result
);
81 this.command
.addOption(option
);
85 public void caseAEntryidCommandoption(AEntryidCommandoption node
) {
87 String node_t
= node
.getEntryidOpt().getText();
88 //logger.debug("caseAEntryidCommandoption CALLED ["+node_t+"]");
90 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
91 result
= result
.trim();
94 GOption option
= new GOption();
95 option
.setName("entryid");
96 option
.setValue(result
);
97 this.command
.addOption(option
);
102 public void caseAAccountCommandoption(AAccountCommandoption node
) {
104 String node_t
= node
.getAccountOpt().getText();
105 //logger.debug("caseAAccountCommandoption CALLED ["+node_t+"]");
107 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
108 result
= result
.trim();
111 GOption option
= new GOption();
112 option
.setName("account");
113 option
.setValue(result
);
114 this.command
.addOption(option
);
118 public void caseAJournalCommandoption(AJournalCommandoption node
) {
120 String node_t
= node
.getJournalOpt().getText();
121 //logger.debug("caseAJournalCommandoption CALLED ["+node_t+"]");
123 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
124 result
= result
.trim();
127 GOption option
= new GOption();
128 option
.setName("journal");
129 option
.setValue(result
);
130 this.command
.addOption(option
);
135 public void caseANameCommandoption(ANameCommandoption node
) {
137 String node_t
= node
.getNameOpt().getText();
138 //logger.debug("caseANameCommandoption CALLED ["+node_t+"]");
140 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
141 result
= result
.trim();
144 GOption option
= new GOption();
145 option
.setName("name");
146 option
.setValue(result
);
147 this.command
.addOption(option
);
152 public void caseATypeCommandoption(ATypeCommandoption node
) {
154 String node_t
= node
.getTypeOpt().getText();
155 //logger.debug("caseATypeCommandoption CALLED ["+node_t+"]");
157 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
158 result
= result
.trim();
161 GOption option
= new GOption();
162 option
.setName("type");
163 option
.setValue(result
);
164 this.command
.addOption(option
);
169 public void caseACweightCommandoption(ACweightCommandoption node
) {
171 String node_t
= node
.getCounterweightOpt().getText();
172 //logger.debug("caseACweightCommandoption CALLED ["+node_t+"]");
174 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
175 result
= result
.trim();
178 GOption option
= new GOption();
179 option
.setName("counterWeight");
180 option
.setValue(result
);
181 this.command
.addOption(option
);
186 public void caseAAmountCommandoption(AAmountCommandoption node
) {
188 String node_t
= node
.getAmountOpt().getText();
189 //logger.debug("caseAAmountCommandoption CALLED ["+node_t+"]");
191 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
192 result
= result
.trim();
195 GOption option
= new GOption();
196 option
.setName("amount");
197 option
.setValue(result
);
198 this.command
.addOption(option
);
204 public void caseAIdCommandoption(AIdCommandoption node
) {
206 String node_t
= node
.getIdOpt().getText();
207 //logger.debug("caseAIdCommandoption CALLED ["+node_t+"]");
209 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
210 result
= result
.trim();
213 GOption option
= new GOption();
214 option
.setName("id");
215 option
.setValue(result
);
216 this.command
.addOption(option
);
220 public void caseAGroupCommandoption(AGroupCommandoption node
) {
222 String node_t
= node
.getGroupOpt().getText();
223 //logger.debug("caseAGroupCommandoption CALLED ["+node_t+"]");
225 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
226 result
= result
.trim();
228 GOption option
= new GOption();
229 option
.setName("group");
230 option
.setValue(result
);
231 this.command
.addOption(option
);
234 public void caseAUnameCommandoption(AUnameCommandoption node
) {
236 String node_t
= node
.getUnameOpt().getText();
238 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
239 result
= result
.trim();
241 GOption option
= new GOption();
242 option
.setName("username");
243 option
.setValue(result
);
244 this.command
.addOption(option
);
247 public void caseAPasswdCommandoption(APasswdCommandoption node
) {
249 String node_t
= node
.getPasswdOpt().getText();
250 //logger.debug("caseAIdCommandoption CALLED ["+node_t+"]");
252 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
253 result
= result
.trim();
255 GOption option
= new GOption();
256 option
.setName("password");
257 option
.setValue(result
);
258 this.command
.addOption(option
);
265 public void caseAEntrynumCommandoption(AEntrynumCommandoption node
) {
267 String node_t
= node
.getEntrynumOpt().getText();
268 //logger.debug("caseAEntrynumCommandoption CALLED ["+node_t+"]");
270 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
271 result
= result
.trim();
274 GOption option
= new GOption();
275 option
.setName("entrynum");
276 option
.setValue(result
);
277 this.command
.addOption(option
);
282 public void caseADateCommandoption(ADateCommandoption node
) {
284 String node_t
= node
.getDateOpt().getText();
285 //logger.debug("caseADateCommandoption CALLED ["+node_t+"]");
287 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
288 result
= result
.trim();
291 GOption option
= new GOption();
292 option
.setName("date");
293 option
.setValue(result
);
294 this.command
.addOption(option
);
299 public void caseAFileCommandoption(AFileCommandoption node
) {
301 String node_t
= node
.getFileOpt().getText();
302 //logger.debug("caseAFileCommandoption CALLED ["+node_t+"]");
304 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
305 result
= result
.trim();
308 GOption option
= new GOption();
309 option
.setName("file");
310 option
.setValue(result
);
311 this.command
.addOption(option
);
316 /* {groupid} groupid_opt |
317 {userid} userid_opt |
318 {currency} currency_opt;
320 public void caseAGroupidCommandoption(AGroupidCommandoption node
) {
322 String node_t
= node
.getGroupidOpt().getText();
323 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
324 result
= result
.trim();
326 GOption option
= new GOption();
327 option
.setName("groupid");
328 option
.setValue(result
);
329 this.command
.addOption(option
);
333 public void caseAUseridCommandoption(AUseridCommandoption node
) {
335 String node_t
= node
.getUseridOpt().getText();
336 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
337 result
= result
.trim();
339 GOption option
= new GOption();
340 option
.setName("userid");
341 option
.setValue(result
);
342 this.command
.addOption(option
);
346 public void caseACurrencyCommandoption(ACurrencyCommandoption node
) {
348 String node_t
= node
.getCurrencyOpt().getText();
349 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
350 result
= result
.trim();
352 GOption option
= new GOption();
353 option
.setName("currency");
354 option
.setValue(result
);
355 this.command
.addOption(option
);
360 /*public void caseAReturninputCommandoption(AReturninputCommandoption node) {
362 String node_t = node.getReturninputOpt().getText();
363 String result = node_t.replaceAll("-[a-zA-Z]+", "");
364 result = result.trim();
366 GOption option = new GOption();
367 option.setName("returninput");
368 option.setValue(result);
369 this.command.addOption(option);
378 public void caseASystemCommandtoken(ASystemCommandtoken node
) {
380 //logger.debug("caseADebitCommandtoken CALLED ["+node.getDebitTok().getText()+"]");
382 Token token
= new Token();
383 token
.setName("system");
384 this.command
.setToken(token
);
387 public void caseADebitCommandtoken(ADebitCommandtoken node
) {
389 //logger.debug("caseADebitCommandtoken CALLED ["+node.getDebitTok().getText()+"]");
391 Token token
= new Token();
392 token
.setName("debit");
393 this.command
.setToken(token
);
396 public void caseACreditCommandtoken(ACreditCommandtoken node
) {
398 //logger.debug("caseACreditCommandtoken CALLED ["+node.getCreditTok().getText()+"]");
400 Token token
= new Token();
401 token
.setName("credit");
402 this.command
.setToken(token
);
405 public void caseAEntryCommandtoken(AEntryCommandtoken node
) {
407 //logger.debug("caseAEntryCommandtoken CALLED ["+node.getEntryTok().getText()+"]");
409 Token token
= new Token();
410 token
.setName("entry");
411 this.command
.setToken(token
);
414 public void caseAEntriesCommandtoken(AEntriesCommandtoken node
) {
416 //logger.debug("caseAEntriesCommandtoken CALLED ["+node.getEntriesTok().getText()+"]");
418 Token token
= new Token();
419 token
.setName("entries");
420 this.command
.setToken(token
);
423 public void caseAJournalCommandtoken(AJournalCommandtoken node
) {
425 //logger.debug("caseAJournalCommandtoken CALLED ["+node.getJournalTok().getText()+"]");
427 Token token
= new Token();
428 token
.setName("journal");
429 this.command
.setToken(token
);
432 public void caseAJournalsCommandtoken(AJournalsCommandtoken node
) {
434 //logger.debug("caseAJournalsCommandtoken CALLED ["+node.getJournalsTok().getText()+"]");
436 Token token
= new Token();
437 token
.setName("journals");
438 this.command
.setToken(token
);
441 public void caseATransactionCommandtoken(ATransactionCommandtoken node
) {
443 //logger.debug("caseATransactionCommandtoken CALLED ["+node.getTransactionTok().getText()+"]");
445 Token token
= new Token();
446 token
.setName("transaction");
447 this.command
.setToken(token
);
450 public void caseAAccountCommandtoken(AAccountCommandtoken node
) {
452 //logger.debug("caseAAccountCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
454 Token token
= new Token();
455 token
.setName("account");
456 this.command
.setToken(token
);
459 public void caseAAccountsCommandtoken(AAccountsCommandtoken node
) {
461 //logger.debug("caseAAccountCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
463 Token token
= new Token();
464 token
.setName("accounts");
465 this.command
.setToken(token
);
468 public void caseAUserCommandtoken(AUserCommandtoken node
) {
470 //logger.debug("caseAUserCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
472 Token token
= new Token();
473 token
.setName("user");
474 this.command
.setToken(token
);
477 public void caseAUsersCommandtoken(AUsersCommandtoken node
) {
479 //logger.debug("caseAUsersCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
481 Token token
= new Token();
482 token
.setName("users");
483 this.command
.setToken(token
);
486 public void caseAProfiledetailsCommandtoken(AProfiledetailsCommandtoken node
) {
488 //logger.debug("caseAProfiledetailsCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
490 Token token
= new Token();
491 token
.setName("profileDetails");
492 this.command
.setToken(token
);
496 public void caseAProfiledetailCommandtoken(AProfiledetailCommandtoken node
) {
498 //logger.debug("caseAProfiledetailCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
500 Token token
= new Token();
501 token
.setName("profileDetail");
502 this.command
.setToken(token
);
507 public static void main(String args
[]) {
509 //-type type -name some -id qerfb1435c -date 06/24/2003
510 String string_t
= "-type type";
511 String string_n
= "-name some";
512 String string_i
= "-id qerfb1435c";
513 String string_d
= "-date 06/24/2003";
516 String result
= string_t
.replaceAll("-[a-zA-Z]+", "");
517 //logger.debug( "string_t Result: ["+result.trim()+"]" );
519 result
= string_n
.replaceAll("-[a-zA-Z]+", "");
520 //logger.debug( "string_n Result: ["+result.trim()+"]" );
522 result
= string_i
.replaceAll("-[a-zA-Z]+", "");
523 //logger.debug( "string_i Result: ["+result.trim()+"]" );
525 result
= string_d
.replaceAll("-[a-zA-Z]+", "");
526 //logger.debug( "string_d Result: ["+result.trim()+"]" );