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 * 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
020package com.izforge.izpack.installer;
021
022import java.util.ArrayList;
023import java.util.HashMap;
024import java.util.List;
025import java.util.Map;
026
027import com.izforge.izpack.ExecutableFile;
028
029/**
030 * Holds uninstallation data. Implemented as a singleton.
031 * 
032 * @author Julien Ponge created October 27, 2002
033 */
034public class UninstallData
035{
036
037    /** The uninstall data object. */
038    private static UninstallData instance = null;
039
040    /** The files list. */
041    private List filesList;
042
043    /** The executables list. */
044    private List executablesList;
045
046    /** The uninstaller jar filename. */
047    private String uninstallerJarFilename;
048
049    /** The uninstaller path. */
050    private String uninstallerPath;
051
052    /** Additional uninstall data like uninstaller listener list. */
053    private Map additionalData;
054
055    /** The constructor. */
056    private UninstallData()
057    {
058        filesList = new ArrayList();
059        executablesList = new ArrayList();
060        additionalData = new HashMap();
061    }
062
063    /**
064     * Returns the instance (it is a singleton).
065     * 
066     * @return The instance.
067     */
068    public synchronized static UninstallData getInstance()
069    {
070        if (instance == null) instance = new UninstallData();
071        return instance;
072    }
073
074    /**
075     * Adds a file to the data.
076     * 
077     * @param path The file to add.
078     */
079    public synchronized void addFile(String path)
080    {
081        filesList.add(path);
082    }
083
084    /**
085     * Returns the files list.
086     * 
087     * @return The files list.
088     */
089    public List getFilesList()
090    {
091        return filesList;
092    }
093
094    /**
095     * Adds an executable to the data.
096     * 
097     * @param file The executable file.
098     */
099    public synchronized void addExecutable(ExecutableFile file)
100    {
101        executablesList.add(file);
102    }
103
104    /**
105     * Returns the executables list.
106     * 
107     * @return The executables list.
108     */
109    public List getExecutablesList()
110    {
111        return executablesList;
112    }
113
114    /**
115     * Returns the uninstaller jar filename.
116     * 
117     * @return The uninstaller jar filename.
118     */
119    public synchronized String getUninstallerJarFilename()
120    {
121        return uninstallerJarFilename;
122    }
123
124    /**
125     * Sets the uninstaller jar filename.
126     * 
127     * @param name The uninstaller jar filename.
128     */
129    public synchronized void setUninstallerJarFilename(String name)
130    {
131        uninstallerJarFilename = name;
132    }
133
134    /**
135     * Returns the path to the uninstaller.
136     * 
137     * @return The uninstaller filename path.
138     */
139    public String getUninstallerPath()
140    {
141        return uninstallerPath;
142    }
143
144    /**
145     * Sets the uninstaller path.
146     * 
147     * @param path The uninstaller path.
148     */
149    public void setUninstallerPath(String path)
150    {
151        uninstallerPath = path;
152    }
153
154    /**
155     * Returns additional uninstall data like uninstaller listener list.
156     * 
157     * @return additional uninstall data
158     */
159    public Map getAdditionalData()
160    {
161        return additionalData;
162    }
163
164    /**
165     * Sets additional uninstall data like uninstaller listener list.
166     * 
167     * @param name key for the additional uninstall data
168     * @param value the additional uninstall data
169     */
170    public void addAdditionalData(String name, Object value)
171    {
172        additionalData.put(name, value);
173    }
174
175}