01: /*
02: * $Id: MatchConditionCommand.java 674 2006-10-06 12:15:59Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.org).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.client.commandline;
15:
16: /**
17: * @author hengels
18: */
19: public class MatchConditionCommand extends Command {
20: private String condition;
21: private String[] subjects;
22:
23: public MatchConditionCommand() {
24: usage = "CONDITION SUBJECT...\n Check if the subjects match the condition.";
25: }
26:
27: public String[] getSubjects() {
28: return subjects;
29: }
30:
31: public void setSubjects(String[] subjects) {
32: this .subjects = subjects;
33: }
34:
35: public void setArguments(String[] args) {
36: condition = args[0];
37:
38: subjects = new String[args.length - 1];
39: for (int i = 1; i < args.length; i++) {
40: String subject = args[i];
41: subjects[i - 1] = subject;
42: }
43: }
44:
45: public void run() {
46: for (int i = 0; i < subjects.length; i++) {
47: String subject = subjects[i];
48:
49: try {
50: boolean match = controller.matchCondition(subject,
51: condition);
52: System.out.println("match condition " + subject + " "
53: + condition + ": " + match);
54: } catch (Exception e) {
55: System.out.println("match condition " + subject + " "
56: + condition + ": ERROR");
57: e.printStackTrace();
58: }
59: }
60: }
61: }
|