001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2004 Klaus Bartz
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021:
022: package com.izforge.izpack.event;
023:
024: import java.io.Serializable;
025: import java.util.HashSet;
026:
027: /**
028: * Base class for action classes like AntAction.
029: *
030: * @author Klaus Bartz
031: *
032: */
033: public class ActionBase implements Serializable {
034:
035: // --- String constants for parsing the XML specification -----------------
036: // --- These definitions are placed here because the const strings are -----
037: // --- used by more than one InstallerListener and UninstallerListener -----
038: // --- class. --------------------------------------------------------------
039:
040: private static final long serialVersionUID = 3690478013149884728L;
041:
042: public static final String PACK = "pack";
043:
044: public static final String NAME = "name";
045:
046: // Order related "symbols"
047: public static final String ORDER = "order";
048:
049: public static final String BEFOREPACK = "beforepack";
050:
051: public static final String AFTERPACK = "afterpack";
052:
053: public static final String BEFOREPACKS = "beforepacks";
054:
055: public static final String AFTERPACKS = "afterpacks";
056:
057: public static final String UNINSTALL_ORDER = "uninstall_order";
058:
059: public static final String BEFOREDELETION = "beforedeletion";
060:
061: public static final String AFTERDELETION = "afterdeletion";
062:
063: public static final String PROPERTY = "property";
064:
065: public static final String VALUE = "value";
066:
067: public static final String YES = "yes";
068:
069: public static final String NO = "no";
070:
071: public static final String FALSE = "false";
072:
073: public static final String TRUE = "true";
074:
075: public static final String QUIET = "quiet";
076:
077: public static final String VERBOSE = "verbose";
078:
079: public static final String LOGFILE = "logfile";
080:
081: public static final String BUILDFILE = "buildfile";
082:
083: public static final String PROPERTYFILE = "propertyfile";
084:
085: public static final String PATH = "path";
086:
087: public static final String SRCDIR = "srcdir";
088:
089: public static final String TARGETDIR = "targetdir";
090:
091: public static final String TARGET = "target";
092:
093: public static final String UNINSTALL_TARGET = "uninstall_target";
094:
095: public static final String ACTION = "action";
096:
097: public static final String UNINSTALL_ACTION = "uninstall_action";
098:
099: public static final String ONDEST = "ondestination";
100:
101: public static final String COPY = "copy";
102:
103: public static final String REMOVE = "remove";
104:
105: public static final String REWIND = "rewind";
106:
107: public static final String TOUCH = "touch";
108:
109: public static final String MOVE = "move";
110:
111: public static final String OVERRIDE = "override";
112:
113: public static final String UPDATE = "update";
114:
115: public static final String NOTHING = "nothing";
116:
117: public static final String FILESET = "fileset";
118:
119: public static final String MESSAGEID = "messageid";
120:
121: public static final String INCLUDE = "include";
122:
123: public static final String INCLUDES = "includes";
124:
125: public static final String EXCLUDE = "exclude";
126:
127: public static final String EXCLUDES = "excludes";
128:
129: public static final String OS = "os";
130:
131: public static final String FAMILY = "family";
132:
133: public static final String VERSION = "version";
134:
135: public static final String ARCH = "arch";
136:
137: public static final String CASESENSITIVE = "casesensitive";
138:
139: public static final String UNIX = "unix";
140:
141: public static final String WINDOWS = "windows";
142:
143: public static final String MAC = "mac";
144:
145: public static final String ASKTRUE = "asktrue";
146:
147: public static final String ASKFALSE = "askfalse";
148:
149: private static final HashSet<String> installOrders = new HashSet<String>();
150:
151: private static final HashSet<String> uninstallOrders = new HashSet<String>();
152:
153: protected String uninstallOrder = ActionBase.BEFOREDELETION;
154:
155: protected String order = null;
156:
157: protected String messageID = null;
158:
159: static {
160: installOrders.add(ActionBase.BEFOREPACK);
161: installOrders.add(ActionBase.AFTERPACK);
162: installOrders.add(ActionBase.BEFOREPACKS);
163: installOrders.add(ActionBase.AFTERPACKS);
164: uninstallOrders.add(ActionBase.BEFOREDELETION);
165: uninstallOrders.add(ActionBase.AFTERDELETION);
166: }
167:
168: /**
169: * Default constructor
170: */
171: public ActionBase() {
172: super ();
173: }
174:
175: /**
176: * Returns the order.
177: *
178: * @return the order
179: */
180: public String getOrder() {
181: return order;
182: }
183:
184: /**
185: * Sets the order to the given string. Valid values are "beforepacks", "beforepack", "afterpack"
186: * and "afterpacks".
187: *
188: * @param order order to be set
189: */
190: public void setOrder(String order) throws Exception {
191: if (!installOrders.contains(order))
192: throw new Exception("Bad value for order.");
193: this .order = order;
194: }
195:
196: /**
197: * Returns the order for uninstallation.
198: *
199: * @return the order for uninstallation
200: */
201: public String getUninstallOrder() {
202: return uninstallOrder;
203: }
204:
205: /**
206: * Sets the order to the given string for uninstallation. Valid values are "beforedeletion" and
207: * "afterdeletion".
208: *
209: * @param order order to be set
210: */
211: public void setUninstallOrder(String order) throws Exception {
212: if (!uninstallOrders.contains(order))
213: throw new Exception("Bad value for order.");
214: this .uninstallOrder = order;
215: }
216:
217: /**
218: * Returns the defined message ID for this action.
219: *
220: * @return the defined message ID
221: */
222: public String getMessageID() {
223: return messageID;
224: }
225:
226: /**
227: * Sets the message ID to the given string.
228: *
229: * @param string string to be used as message ID
230: */
231: public void setMessageID(String string) {
232: messageID = string;
233: }
234:
235: }
|