KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > installer > UninstallData


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.izforge.izpack.installer;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Hashtable JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27
28
29 import com.izforge.izpack.ExecutableFile;
30 import com.izforge.izpack.util.os.unix.UnixUser;
31
32 /**
33  * Holds uninstallation data. Implemented as a singleton.
34  *
35  * @author Julien Ponge created October 27, 2002
36  */

37 public class UninstallData
38 {
39     /** The uninstall data object. */
40     private static UninstallData instance = null;
41
42     /** The files list. */
43     private List JavaDoc filesList;
44
45     /** The executables list. */
46     private List JavaDoc executablesList;
47
48     /** The uninstaller jar filename. */
49     private String JavaDoc uninstallerJarFilename;
50
51     /** The uninstaller path. */
52     private String JavaDoc uninstallerPath;
53
54     /** Additional uninstall data like uninstaller listener list. */
55     private Map JavaDoc additionalData;
56     
57     /** Filesmap which should removed by the root user for another user */
58     private String JavaDoc rootScript;
59
60     /** The constructor. */
61     private UninstallData()
62     {
63         filesList = new ArrayList JavaDoc();
64         executablesList = new ArrayList JavaDoc();
65         additionalData = new HashMap JavaDoc();
66         rootScript = new String JavaDoc();
67     }
68     
69     /** Constant RootFiles = "rootfiles" */
70     public final static String JavaDoc ROOTSCRIPT = "rootscript";
71
72     /**
73      * Returns the instance (it is a singleton).
74      *
75      * @return The instance.
76      */

77     public synchronized static UninstallData getInstance()
78     {
79         if (instance == null) instance = new UninstallData();
80         return instance;
81     }
82
83     /**
84      * Adds a file to the data.
85      *
86      * @param path The file to add.
87      */

88     public synchronized void addFile(String JavaDoc path)
89     {
90         filesList.add(path);
91     }
92
93     /**
94      * Returns the files list.
95      *
96      * @return The files list.
97      */

98     public List JavaDoc getFilesList()
99     {
100         return filesList;
101     }
102
103     /**
104      * Adds an executable to the data.
105      *
106      * @param file The executable file.
107      */

108     public synchronized void addExecutable(ExecutableFile file)
109     {
110         executablesList.add(file);
111     }
112
113     /**
114      * Returns the executables list.
115      *
116      * @return The executables list.
117      */

118     public List JavaDoc getExecutablesList()
119     {
120         return executablesList;
121     }
122
123     /**
124      * Returns the uninstaller jar filename.
125      *
126      * @return The uninstaller jar filename.
127      */

128     public synchronized String JavaDoc getUninstallerJarFilename()
129     {
130         return uninstallerJarFilename;
131     }
132
133     /**
134      * Sets the uninstaller jar filename.
135      *
136      * @param name The uninstaller jar filename.
137      */

138     public synchronized void setUninstallerJarFilename(String JavaDoc name)
139     {
140         uninstallerJarFilename = name;
141     }
142
143     /**
144      * Returns the path to the uninstaller.
145      *
146      * @return The uninstaller filename path.
147      */

148     public String JavaDoc getUninstallerPath()
149     {
150         return uninstallerPath;
151     }
152
153     /**
154      * Sets the uninstaller path.
155      *
156      * @param path The uninstaller path.
157      */

158     public void setUninstallerPath(String JavaDoc path)
159     {
160         uninstallerPath = path;
161     }
162
163     /**
164      * Returns additional uninstall data like uninstaller listener list.
165      *
166      * @return additional uninstall data
167      */

168     public Map JavaDoc getAdditionalData()
169     {
170         return additionalData;
171     }
172
173     /**
174      * Sets additional uninstall data like uninstaller listener list.
175      *
176      * @param name key for the additional uninstall data
177      * @param value the additional uninstall data
178      */

179     public void addAdditionalData(String JavaDoc name, Object JavaDoc value)
180     {
181         additionalData.put(name, value);
182     }
183
184     /**
185      * Adds the given File to delete several Shortcuts as Root for the given Users.
186      *
187      * @param aRootUninstallScript The Script to exec as Root at uninstall.
188      */

189     public void addRootUninstallScript( String JavaDoc aRootUninstallScript )
190     {
191         rootScript = new String JavaDoc( aRootUninstallScript==null?"":aRootUninstallScript );
192     }
193     
194     /**
195      * Returns the root data.
196      *
197      * @return root data
198      */

199     public String JavaDoc getRootScript()
200     {
201         return rootScript;
202     }
203     
204     
205
206 }
207
Popular Tags