| CommandContainer.java |
1 /*
2 * CVS: $Id: CommandContainer.java,v 1.6 2004/07/16 16:22:33 marcus Exp $
3 *
4 * This file is part of JZuul.
5 *
6 * JZuul is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * JZuul is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Zuul; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Copyrigth 2004 by marcus, leh
21 *
22 */
23
24package org.jzuul.engine;
25
26/**
27 *
28 * @version $Revision: 1.6 $
29 */
30public class CommandContainer {
31 /**
32 * die Aktion, also der Name des Befehls
33 */
34 private String action;
35
36 /**
37 * die Argumente des Befehls
38 */
39 private String[] args;
40
41 /**
42 * hat das Kommando Parameter gehabt
43 */
44 private boolean hasArgs = false;
45
46 //---------------------------------------
47
48 /**
49 * tja, der konstruktor für einen Befehl :-D
50 *
51 * @param action ein gültiges Befehlswort
52 */
53 public CommandContainer(String action) {
54 this.action = action;
55
56 }
57
58 /**
59 * Setzt die Argumente
60 *
61 * @param args neue Liste von Argumenten
62 */
63 public void setArgs(String[] args) {
64 this.hasArgs = true;
65 this.args = args;
66 }
67
68 /**
69 * Gibt die Argumenteliste des Command Objektes zurück
70 *
71 * @return die Liste der Argument die der Befehl hat
72 */
73 public String[] getArgs() {
74 return args;
75 }
76
77
78 /**
79 * Diese Methode setzt das Hauptbefehlsowort eines Befehls Objekt und sollte nur beim
80 * initialisieren des Objektes benutzt werden.
81 *
82 * @param action
83 */
84 public void setAction(String action) {
85 this.action = action;
86 }
87
88 /**
89 * Gibt das eigentliche Befehlswort zurück
90 *
91 * @return das Befehlswort
92 */
93 public String getAction() {
94 return action;
95 }
96
97 /**
98 * Hatte die Befehlszeile Argumente?
99 *
00 * @return true wenn dem so war, false otherwise
01 */
02 public boolean hasArgs() {
03 return hasArgs;
04 }
05
06 /**
07 * Ist der Befehl ein Kommando das zum Erfüllen eines Targets
08 * benutzt werden kann
09 *
10 * @return true wenn dem so ist, false otherwise
11 */
12 public boolean isTargetAction() {
13 return (TargetObject.actionTypeFromString(this.action) != -1);
14 }
15
16 /**
17 * Gibt die action Type Nummer des aktuellen Befehls zurück
18 *
19 * @return die ActionType nummer
20 */
21 public int getTargetNumber() {
22 return TargetObject.actionTypeFromString(this.action);
23 }
24}
25