001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: package com.izforge.izpack.installer;
021:
022: import java.util.ArrayList;
023: import java.util.HashMap;
024: import java.util.List;
025: import java.util.Map;
026:
027: import com.izforge.izpack.ExecutableFile;
028:
029: /**
030: * Holds uninstallation data. Implemented as a singleton.
031: *
032: * @author Julien Ponge created October 27, 2002
033: */
034: public class UninstallData {
035: /** The uninstall data object. */
036: private static UninstallData instance = null;
037:
038: /** The installed files list. */
039: private List<String> installedFilesList;
040:
041: /** The uninstallable files list. */
042: private List uninstallableFilesList;
043:
044: /** The executables list. */
045: private List executablesList;
046:
047: /** The uninstaller jar filename. */
048: private String uninstallerJarFilename;
049:
050: /** The uninstaller path. */
051: private String uninstallerPath;
052:
053: /** Additional uninstall data like uninstaller listener list. */
054: private Map<String, Object> additionalData;
055:
056: /** Filesmap which should removed by the root user for another user */
057: private String rootScript;
058:
059: /** The constructor. */
060: private UninstallData() {
061: installedFilesList = new ArrayList<String>();
062: uninstallableFilesList = new ArrayList();
063: executablesList = new ArrayList();
064: additionalData = new HashMap<String, Object>();
065: rootScript = "";
066: }
067:
068: /** Constant RootFiles = "rootfiles" */
069: public final static String ROOTSCRIPT = "rootscript";
070:
071: /**
072: * Returns the instance (it is a singleton).
073: *
074: * @return The instance.
075: */
076: public synchronized static UninstallData getInstance() {
077: if (instance == null)
078: instance = new UninstallData();
079: return instance;
080: }
081:
082: /**
083: * Adds a file to the data.
084: *
085: * @param path The file to add.
086: * @param uninstall If true, file must be uninstalled.
087: */
088: public synchronized void addFile(String path, boolean uninstall) {
089: if (path != null) {
090: installedFilesList.add(path);
091: if (uninstall)
092: uninstallableFilesList.add(path);
093: }
094: }
095:
096: /**
097: * Returns the installed files list.
098: *
099: * @return The installed files list.
100: */
101: public List<String> getInstalledFilesList() {
102: return installedFilesList;
103: }
104:
105: /**
106: * Returns the uninstallable files list.
107: *
108: * @return The uninstallable files list.
109: */
110: public List getUninstalableFilesList() {
111: return uninstallableFilesList;
112: }
113:
114: /**
115: * Adds an executable to the data.
116: *
117: * @param file The executable file.
118: */
119: public synchronized void addExecutable(ExecutableFile file) {
120: executablesList.add(file);
121: }
122:
123: /**
124: * Returns the executables list.
125: *
126: * @return The executables list.
127: */
128: public List getExecutablesList() {
129: return executablesList;
130: }
131:
132: /**
133: * Returns the uninstaller jar filename.
134: *
135: * @return The uninstaller jar filename.
136: */
137: public synchronized String getUninstallerJarFilename() {
138: return uninstallerJarFilename;
139: }
140:
141: /**
142: * Sets the uninstaller jar filename.
143: *
144: * @param name The uninstaller jar filename.
145: */
146: public synchronized void setUninstallerJarFilename(String name) {
147: uninstallerJarFilename = name;
148: }
149:
150: /**
151: * Returns the path to the uninstaller.
152: *
153: * @return The uninstaller filename path.
154: */
155: public String getUninstallerPath() {
156: return uninstallerPath;
157: }
158:
159: /**
160: * Sets the uninstaller path.
161: *
162: * @param path The uninstaller path.
163: */
164: public void setUninstallerPath(String path) {
165: uninstallerPath = path;
166: }
167:
168: /**
169: * Returns additional uninstall data like uninstaller listener list.
170: *
171: * @return additional uninstall data
172: */
173: public Map<String, Object> getAdditionalData() {
174: return additionalData;
175: }
176:
177: /**
178: * Sets additional uninstall data like uninstaller listener list.
179: *
180: * @param name key for the additional uninstall data
181: * @param value the additional uninstall data
182: */
183: public void addAdditionalData(String name, Object value) {
184: additionalData.put(name, value);
185: }
186:
187: /**
188: * Adds the given File to delete several Shortcuts as Root for the given Users.
189: *
190: * @param aRootUninstallScript The Script to exec as Root at uninstall.
191: */
192: public void addRootUninstallScript(String aRootUninstallScript) {
193: rootScript = aRootUninstallScript == null ? ""
194: : aRootUninstallScript;
195: }
196:
197: /**
198: * Returns the root data.
199: *
200: * @return root data
201: */
202: public String getRootScript() {
203: return rootScript;
204: }
205:
206: }
|