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
.AReturnCommandoption
;
44 import com
.interrupt
.bookkeeping
.cc
.node
.ASystemCommandtoken
;
45 import com
.interrupt
.bookkeeping
.cc
.node
.ATransactionCommandtoken
;
46 import com
.interrupt
.bookkeeping
.cc
.node
.ATypeCommandoption
;
47 import com
.interrupt
.bookkeeping
.cc
.node
.AUnameCommandoption
;
48 import com
.interrupt
.bookkeeping
.cc
.node
.AUserCommandtoken
;
49 import com
.interrupt
.bookkeeping
.cc
.node
.AUseridCommandoption
;
50 import com
.interrupt
.bookkeeping
.cc
.node
.AUsersCommandtoken
;
51 import com
.interrupt
.bookkeeping
.cc
.node
.PCommandoption
;
53 public class CommandOptionVisitor
extends DepthFirstAdapter
{
56 private AbstractCommand command
= null;
57 private Logger logger
= Logger
.getLogger(CommandOptionVisitor
.class);
60 public AbstractCommand
getCommand() {
63 public void setCommand(AbstractCommand command
) {
64 this.command
= command
;
71 public void caseAEntryCommandoption(AEntryCommandoption node
) {
73 String node_t
= node
.getEntryOpt().getText();
74 //logger.debug("caseAEntryCommandoption CALLED ["+node_t+"]");
76 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
77 result
= result
.trim();
79 GOption option
= new GOption();
80 option
.setName("entry");
81 option
.setValue(result
);
82 this.command
.addOption(option
);
86 public void caseAEntryidCommandoption(AEntryidCommandoption node
) {
88 String node_t
= node
.getEntryidOpt().getText();
89 //logger.debug("caseAEntryidCommandoption CALLED ["+node_t+"]");
91 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
92 result
= result
.trim();
95 GOption option
= new GOption();
96 option
.setName("entryid");
97 option
.setValue(result
);
98 this.command
.addOption(option
);
103 public void caseAAccountCommandoption(AAccountCommandoption node
) {
105 String node_t
= node
.getAccountOpt().getText();
106 //logger.debug("caseAAccountCommandoption CALLED ["+node_t+"]");
108 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
109 result
= result
.trim();
112 GOption option
= new GOption();
113 option
.setName("account");
114 option
.setValue(result
);
115 this.command
.addOption(option
);
119 public void caseAJournalCommandoption(AJournalCommandoption node
) {
121 String node_t
= node
.getJournalOpt().getText();
122 //logger.debug("caseAJournalCommandoption CALLED ["+node_t+"]");
124 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
125 result
= result
.trim();
128 GOption option
= new GOption();
129 option
.setName("journal");
130 option
.setValue(result
);
131 this.command
.addOption(option
);
136 public void caseANameCommandoption(ANameCommandoption node
) {
138 String node_t
= node
.getNameOpt().getText();
139 //logger.debug("caseANameCommandoption CALLED ["+node_t+"]");
141 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
142 result
= result
.trim();
145 GOption option
= new GOption();
146 option
.setName("name");
147 option
.setValue(result
);
148 this.command
.addOption(option
);
153 public void caseATypeCommandoption(ATypeCommandoption node
) {
155 String node_t
= node
.getTypeOpt().getText();
156 //logger.debug("caseATypeCommandoption CALLED ["+node_t+"]");
158 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
159 result
= result
.trim();
162 GOption option
= new GOption();
163 option
.setName("type");
164 option
.setValue(result
);
165 this.command
.addOption(option
);
170 public void caseACweightCommandoption(ACweightCommandoption node
) {
172 String node_t
= node
.getCounterweightOpt().getText();
173 //logger.debug("caseACweightCommandoption CALLED ["+node_t+"]");
175 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
176 result
= result
.trim();
179 GOption option
= new GOption();
180 option
.setName("counterWeight");
181 option
.setValue(result
);
182 this.command
.addOption(option
);
187 public void caseAAmountCommandoption(AAmountCommandoption node
) {
189 String node_t
= node
.getAmountOpt().getText();
190 //logger.debug("caseAAmountCommandoption CALLED ["+node_t+"]");
192 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
193 result
= result
.trim();
196 GOption option
= new GOption();
197 option
.setName("amount");
198 option
.setValue(result
);
199 this.command
.addOption(option
);
205 public void caseAIdCommandoption(AIdCommandoption node
) {
207 String node_t
= node
.getIdOpt().getText();
208 //logger.debug("caseAIdCommandoption CALLED ["+node_t+"]");
210 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
211 result
= result
.trim();
214 GOption option
= new GOption();
215 option
.setName("id");
216 option
.setValue(result
);
217 this.command
.addOption(option
);
221 public void caseAGroupCommandoption(AGroupCommandoption node
) {
223 String node_t
= node
.getGroupOpt().getText();
224 //logger.debug("caseAGroupCommandoption CALLED ["+node_t+"]");
226 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
227 result
= result
.trim();
229 GOption option
= new GOption();
230 option
.setName("group");
231 option
.setValue(result
);
232 this.command
.addOption(option
);
235 public void caseAUnameCommandoption(AUnameCommandoption node
) {
237 String node_t
= node
.getUnameOpt().getText();
239 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
240 result
= result
.trim();
242 GOption option
= new GOption();
243 option
.setName("username");
244 option
.setValue(result
);
245 this.command
.addOption(option
);
248 public void caseAPasswdCommandoption(APasswdCommandoption node
) {
250 String node_t
= node
.getPasswdOpt().getText();
251 //logger.debug("caseAIdCommandoption CALLED ["+node_t+"]");
253 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
254 result
= result
.trim();
256 GOption option
= new GOption();
257 option
.setName("password");
258 option
.setValue(result
);
259 this.command
.addOption(option
);
266 public void caseAEntrynumCommandoption(AEntrynumCommandoption node
) {
268 String node_t
= node
.getEntrynumOpt().getText();
269 //logger.debug("caseAEntrynumCommandoption CALLED ["+node_t+"]");
271 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
272 result
= result
.trim();
275 GOption option
= new GOption();
276 option
.setName("entrynum");
277 option
.setValue(result
);
278 this.command
.addOption(option
);
283 public void caseADateCommandoption(ADateCommandoption node
) {
285 String node_t
= node
.getDateOpt().getText();
286 //logger.debug("caseADateCommandoption CALLED ["+node_t+"]");
288 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
289 result
= result
.trim();
292 GOption option
= new GOption();
293 option
.setName("date");
294 option
.setValue(result
);
295 this.command
.addOption(option
);
300 public void caseAFileCommandoption(AFileCommandoption node
) {
302 String node_t
= node
.getFileOpt().getText();
303 //logger.debug("caseAFileCommandoption CALLED ["+node_t+"]");
305 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
306 result
= result
.trim();
309 GOption option
= new GOption();
310 option
.setName("file");
311 option
.setValue(result
);
312 this.command
.addOption(option
);
317 /* {groupid} groupid_opt |
318 {userid} userid_opt |
319 {currency} currency_opt;
321 public void caseAGroupidCommandoption(AGroupidCommandoption node
) {
323 String node_t
= node
.getGroupidOpt().getText();
324 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
325 result
= result
.trim();
327 GOption option
= new GOption();
328 option
.setName("groupid");
329 option
.setValue(result
);
330 this.command
.addOption(option
);
334 public void caseAUseridCommandoption(AUseridCommandoption node
) {
336 String node_t
= node
.getUseridOpt().getText();
337 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
338 result
= result
.trim();
340 GOption option
= new GOption();
341 option
.setName("userid");
342 option
.setValue(result
);
343 this.command
.addOption(option
);
347 public void caseACurrencyCommandoption(ACurrencyCommandoption node
) {
349 String node_t
= node
.getCurrencyOpt().getText();
350 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
351 result
= result
.trim();
353 GOption option
= new GOption();
354 option
.setName("currency");
355 option
.setValue(result
);
356 this.command
.addOption(option
);
361 /*public void caseAReturninputCommandoption(AReturninputCommandoption node) {
363 String node_t = node.getReturninputOpt().getText();
364 String result = node_t.replaceAll("-[a-zA-Z]+", "");
365 result = result.trim();
367 GOption option = new GOption();
368 option.setName("returninput");
369 option.setValue(result);
370 this.command.addOption(option);
373 public void caseAReturnCommandoption(AReturnCommandoption node)
375 inAReturnCommandoption(node);
376 if(node.getReturninputOpt() != null)
378 node.getReturninputOpt().apply(this);
380 outAReturnCommandoption(node);
383 public void caseAReturnCommandoption(AReturnCommandoption node
) {
385 String node_t
= node
.getReturninputOpt().getText();
386 String result
= node_t
.replaceAll("-[a-zA-Z]+", "");
387 result
= result
.trim();
389 GOption option
= new GOption();
390 option
.setName("returninput");
391 option
.setValue(result
);
392 this.command
.addOption(option
);
399 public void caseASystemCommandtoken(ASystemCommandtoken node
) {
401 //logger.debug("caseADebitCommandtoken CALLED ["+node.getDebitTok().getText()+"]");
403 Token token
= new Token();
404 token
.setName("system");
405 this.command
.setToken(token
);
408 public void caseADebitCommandtoken(ADebitCommandtoken node
) {
410 //logger.debug("caseADebitCommandtoken CALLED ["+node.getDebitTok().getText()+"]");
412 Token token
= new Token();
413 token
.setName("debit");
414 this.command
.setToken(token
);
417 public void caseACreditCommandtoken(ACreditCommandtoken node
) {
419 //logger.debug("caseACreditCommandtoken CALLED ["+node.getCreditTok().getText()+"]");
421 Token token
= new Token();
422 token
.setName("credit");
423 this.command
.setToken(token
);
426 public void caseAEntryCommandtoken(AEntryCommandtoken node
) {
428 //logger.debug("caseAEntryCommandtoken CALLED ["+node.getEntryTok().getText()+"]");
430 Token token
= new Token();
431 token
.setName("entry");
432 this.command
.setToken(token
);
435 public void caseAEntriesCommandtoken(AEntriesCommandtoken node
) {
437 //logger.debug("caseAEntriesCommandtoken CALLED ["+node.getEntriesTok().getText()+"]");
439 Token token
= new Token();
440 token
.setName("entries");
441 this.command
.setToken(token
);
444 public void caseAJournalCommandtoken(AJournalCommandtoken node
) {
446 //logger.debug("caseAJournalCommandtoken CALLED ["+node.getJournalTok().getText()+"]");
448 Token token
= new Token();
449 token
.setName("journal");
450 this.command
.setToken(token
);
453 public void caseAJournalsCommandtoken(AJournalsCommandtoken node
) {
455 //logger.debug("caseAJournalsCommandtoken CALLED ["+node.getJournalsTok().getText()+"]");
457 Token token
= new Token();
458 token
.setName("journals");
459 this.command
.setToken(token
);
462 public void caseATransactionCommandtoken(ATransactionCommandtoken node
) {
464 //logger.debug("caseATransactionCommandtoken CALLED ["+node.getTransactionTok().getText()+"]");
466 Token token
= new Token();
467 token
.setName("transaction");
468 this.command
.setToken(token
);
471 public void caseAAccountCommandtoken(AAccountCommandtoken node
) {
473 //logger.debug("caseAAccountCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
475 Token token
= new Token();
476 token
.setName("account");
477 this.command
.setToken(token
);
480 public void caseAAccountsCommandtoken(AAccountsCommandtoken node
) {
482 //logger.debug("caseAAccountCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
484 Token token
= new Token();
485 token
.setName("accounts");
486 this.command
.setToken(token
);
489 public void caseAUserCommandtoken(AUserCommandtoken node
) {
491 //logger.debug("caseAUserCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
493 Token token
= new Token();
494 token
.setName("user");
495 this.command
.setToken(token
);
498 public void caseAUsersCommandtoken(AUsersCommandtoken node
) {
500 //logger.debug("caseAUsersCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
502 Token token
= new Token();
503 token
.setName("users");
504 this.command
.setToken(token
);
507 public void caseAProfiledetailsCommandtoken(AProfiledetailsCommandtoken node
) {
509 //logger.debug("caseAProfiledetailsCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
511 Token token
= new Token();
512 token
.setName("profileDetails");
513 this.command
.setToken(token
);
517 public void caseAProfiledetailCommandtoken(AProfiledetailCommandtoken node
) {
519 //logger.debug("caseAProfiledetailCommandtoken CALLED ["+node.getAccountTok().getText()+"]");
521 Token token
= new Token();
522 token
.setName("profileDetail");
523 this.command
.setToken(token
);
528 public static void main(String args
[]) {
530 //-type type -name some -id qerfb1435c -date 06/24/2003
531 String string_t
= "-type type";
532 String string_n
= "-name some";
533 String string_i
= "-id qerfb1435c";
534 String string_d
= "-date 06/24/2003";
537 String result
= string_t
.replaceAll("-[a-zA-Z]+", "");
538 //logger.debug( "string_t Result: ["+result.trim()+"]" );
540 result
= string_n
.replaceAll("-[a-zA-Z]+", "");
541 //logger.debug( "string_n Result: ["+result.trim()+"]" );
543 result
= string_i
.replaceAll("-[a-zA-Z]+", "");
544 //logger.debug( "string_i Result: ["+result.trim()+"]" );
546 result
= string_d
.replaceAll("-[a-zA-Z]+", "");
547 //logger.debug( "string_d Result: ["+result.trim()+"]" );