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