root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / compiler / PackInfo.java @ 15280
History | View | Annotate | Download (7.01 KB)
1 |
/*
|
---|---|
2 |
* $Id: PackInfo.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2001-2004 Julien Ponge
|
5 |
*
|
6 |
* File : PackagerPack.java
|
7 |
* Description : Packs a "Pack's" files into the installer
|
8 |
* Author's email : mchenryc@acm.org
|
9 |
*
|
10 |
* This program is free software; you can redistribute it and/or
|
11 |
* modify it under the terms of the GNU General Public License
|
12 |
* as published by the Free Software Foundation; either version 2
|
13 |
* of the License, or any later version.
|
14 |
*
|
15 |
* This program is distributed in the hope that it will be useful,
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
* GNU General Public License for more details.
|
19 |
*
|
20 |
* You should have received a copy of the GNU General Public License
|
21 |
* along with this program; if not, write to the Free Software
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
23 |
*/
|
24 |
package com.izforge.izpack.compiler; |
25 |
|
26 |
import java.io.File; |
27 |
import java.io.FileNotFoundException; |
28 |
import java.util.ArrayList; |
29 |
import java.util.HashMap; |
30 |
import java.util.List; |
31 |
import java.util.Map; |
32 |
import java.util.Set; |
33 |
|
34 |
import com.izforge.izpack.ExecutableFile; |
35 |
import com.izforge.izpack.Pack; |
36 |
import com.izforge.izpack.PackFile; |
37 |
import com.izforge.izpack.ParsableFile; |
38 |
import com.izforge.izpack.UpdateCheck; |
39 |
|
40 |
/**
|
41 |
* Temporary holding place for Pack information as the Packager is built. The
|
42 |
* packager is used by the compiler to collect info about an installer, and
|
43 |
* finally create the actual installer files.
|
44 |
*
|
45 |
* @author Chadwick McHenry
|
46 |
*/
|
47 |
public class PackInfo |
48 |
{ |
49 |
/** The pack object serialized in the installer. */
|
50 |
private Pack pack;
|
51 |
|
52 |
/** The color of the node. This is used for the dependency graph algorithms */
|
53 |
public int colour; |
54 |
|
55 |
/** white colour*/
|
56 |
public final static int WHITE = 0; |
57 |
/** grey colour*/
|
58 |
public final static int GREY = 1; |
59 |
/** black colour*/
|
60 |
public final static int BLACK = 2; |
61 |
|
62 |
/** Files of the Pack. */
|
63 |
private Map files = new HashMap(); |
64 |
|
65 |
/** Parsables files in this Pack. */
|
66 |
private List parsables = new ArrayList(); |
67 |
|
68 |
/** Executable files in this Pack. */
|
69 |
private List executables = new ArrayList(); |
70 |
|
71 |
/** Update check specifications in this Pack. */
|
72 |
private List updateChecks = new ArrayList(); |
73 |
|
74 |
/** Constructor with required info. */
|
75 |
protected PackInfo(String name, String id, String description, boolean required, boolean loose) |
76 |
{ |
77 |
pack = new Pack( name, id, description, null,null, required, true, loose); |
78 |
colour = PackInfo.WHITE; |
79 |
} |
80 |
|
81 |
/* **********************************************************************
|
82 |
* Attributes of the Pack
|
83 |
* **********************************************************************/
|
84 |
|
85 |
public void setDependencies(List dependencies) |
86 |
{ |
87 |
pack.dependencies = dependencies; |
88 |
} |
89 |
public void setOsConstraints(List osConstraints) |
90 |
{ |
91 |
pack.osConstraints = osConstraints; |
92 |
} |
93 |
|
94 |
public List getOsConstraints(List osConstraints) |
95 |
{ |
96 |
return pack.osConstraints;
|
97 |
} |
98 |
|
99 |
public void setPreselected(boolean preselected) |
100 |
{ |
101 |
pack.preselected = preselected; |
102 |
} |
103 |
|
104 |
public boolean isPreselected() |
105 |
{ |
106 |
return pack.preselected;
|
107 |
} |
108 |
|
109 |
public Pack getPack()
|
110 |
{ |
111 |
return pack;
|
112 |
} |
113 |
|
114 |
/* **********************************************************************
|
115 |
* Public methods to add data to the Installer being packed
|
116 |
* **********************************************************************/
|
117 |
|
118 |
/**
|
119 |
* Add a file or directory to be installed.
|
120 |
*
|
121 |
* @param file the file or basedir to be installed.
|
122 |
* @param targetfile path file will be installed to.
|
123 |
* @param osList the target operation system(s) of this pack.
|
124 |
* @param override what to do if the file already exists when installing
|
125 |
*
|
126 |
* @throws FileNotFoundException if the file specified does not exist. The
|
127 |
* file is not read until the {@link Packager#createInstaller} is invoked,
|
128 |
* thus a FileNotFoundEception will occur then, if the file is deleted
|
129 |
* in between.
|
130 |
*/
|
131 |
/* public void addFile(File file, String targetfile, List osList, int override)
|
132 |
throws FileNotFoundException
|
133 |
{
|
134 |
addFile( file,targetfile, osList, override, null);
|
135 |
}
|
136 |
|
137 |
|
138 |
/**
|
139 |
* Add a file or directory to be installed.
|
140 |
*
|
141 |
* @param file the file or basedir to be installed.
|
142 |
* @param targetfile path file will be installed to.
|
143 |
* @param osList the target operation system(s) of this pack.
|
144 |
* @param override what to do if the file already exists when installing
|
145 |
* @param additionals Map which contains additional data
|
146 |
*
|
147 |
* @throws FileNotFoundException if the file specified does not exist. The
|
148 |
* file is not read until the {@link Packager#createInstaller} is invoked,
|
149 |
* thus a FileNotFoundEception will occur then, if the file is deleted
|
150 |
* in between.
|
151 |
*/
|
152 |
public void addFile(File file, String targetfile, List osList, |
153 |
int override, Map additionals) throws FileNotFoundException |
154 |
{ |
155 |
if (! file.exists())
|
156 |
throw new FileNotFoundException(file.toString()); |
157 |
|
158 |
PackFile packFile = new PackFile(file, targetfile, osList,
|
159 |
override, additionals); |
160 |
files.put(packFile, file); |
161 |
} |
162 |
|
163 |
/** Set of PackFile objects for this Pack. */
|
164 |
public Set getPackFiles() |
165 |
{ |
166 |
return files.keySet();
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* The file described by the specified PackFile. Returns <tt>null</tt> if the
|
171 |
* PackFile did not come from the set returned by {@link #getPackFiles()}.
|
172 |
*/
|
173 |
public File getFile(PackFile packFile) |
174 |
{ |
175 |
return (File) files.get(packFile); |
176 |
} |
177 |
|
178 |
/**
|
179 |
* Parsable files have variables substituted after installation.
|
180 |
*/
|
181 |
public void addParsable(ParsableFile parsable) |
182 |
{ |
183 |
parsables.add(parsable); |
184 |
} |
185 |
|
186 |
/** List of parsables for this Pack. */
|
187 |
public List getParsables() |
188 |
{ |
189 |
return parsables;
|
190 |
} |
191 |
|
192 |
/**
|
193 |
* Executables files have their executable flag set, may be executed, and
|
194 |
* optionally, deleted when finished executing.
|
195 |
*/
|
196 |
public void addExecutable(ExecutableFile executable) |
197 |
{ |
198 |
executables.add(executable); |
199 |
} |
200 |
|
201 |
/** List of parsables for this Pack. */
|
202 |
public List getExecutables() |
203 |
{ |
204 |
return executables;
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* Executables files have their executable flag set, may be executed, and
|
209 |
* optionally, deleted when finished executing.
|
210 |
*/
|
211 |
public void addUpdateCheck(UpdateCheck updateCheck) |
212 |
{ |
213 |
updateChecks.add(updateCheck); |
214 |
} |
215 |
|
216 |
/** List of update checks for this Pack. */
|
217 |
public List getUpdateChecks() |
218 |
{ |
219 |
return updateChecks;
|
220 |
} |
221 |
/**
|
222 |
* The packs that this file depends on
|
223 |
*/
|
224 |
public void addDependency(String dependency) |
225 |
{ |
226 |
if(pack.dependencies == null) |
227 |
{ |
228 |
pack.dependencies = new ArrayList(); |
229 |
} |
230 |
pack.dependencies.add(dependency); |
231 |
} |
232 |
public List getDependencies() |
233 |
{ |
234 |
return pack.dependencies;
|
235 |
} |
236 |
public String toString() |
237 |
{ |
238 |
return pack.name;
|
239 |
} |
240 |
} |