KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > ExecutableFile


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  * Copyright 2001,2002 Olexij Tkatchenko
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.izforge.izpack;
23
24 import java.io.Serializable JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 /**
29  * Encloses information about a executable file. This class abstracts the way to do a system
30  * dependent postprocessing of installation.
31  *
32  * @author Olexij Tkatchenko <ot@parcs.de>
33  */

34
35 public class ExecutableFile implements Serializable JavaDoc
36 {
37
38     static final long serialVersionUID = 4175489415984990405L;
39
40     /** when to execute this file */
41     public final static int POSTINSTALL = 0;
42
43     public final static int NEVER = 1;
44
45     public final static int UNINSTALL = 2;
46
47     /** type of a file */
48     public final static int BIN = 0;
49
50     public final static int JAR = 1;
51
52     /** what to do if execution fails */
53     public final static int ABORT = 0;
54
55     public final static int WARN = 1;
56
57     public final static int ASK = 2;
58     
59     public final static int IGNORE = 3;
60
61     /** The file path */
62     public String JavaDoc path;
63
64     /** Execution stage (NEVER, POSTINSTALL, UNINSTALL) */
65     public int executionStage;
66
67     /** Main class of jar file */
68     public String JavaDoc mainClass;
69
70     /** type (BIN|JAR) */
71     public int type;
72
73     /** Failure handling (ABORT, WARN, ASK) */
74     public int onFailure;
75
76     /** List of arguments */
77     public List JavaDoc argList = null;
78
79     /** List of operating systems to run on */
80     public List JavaDoc osList = null;
81
82     /**
83      * Indicates the file should be kept after executing. Default is false for backward
84      * compatibility.
85      */

86     public boolean keepFile;
87
88     /** Constructs a new uninitialized instance. */
89     public ExecutableFile()
90     {
91         this.path = null;
92         executionStage = NEVER;
93         mainClass = null;
94         type = BIN;
95         onFailure = ASK;
96         osList = new ArrayList JavaDoc();
97         argList = new ArrayList JavaDoc();
98         keepFile = false;
99     }
100
101     /**
102      * Constructs and initializes a new instance.
103      *
104      * @param path the file path
105      * @param executionStage when to execute
106      * @param onFailure what to do if execution fails
107      * @param osList list of operating systems to run on
108      */

109     public ExecutableFile(String JavaDoc path, int executionStage, int onFailure, java.util.List JavaDoc osList,
110             boolean keepFile)
111     {
112         this.path = path;
113         this.executionStage = executionStage;
114         this.onFailure = onFailure;
115         this.osList = osList;
116         this.keepFile = keepFile;
117     }
118
119     public ExecutableFile(String JavaDoc path, int type, String JavaDoc mainClass, int executionStage,
120             int onFailure, java.util.List JavaDoc argList, java.util.List JavaDoc osList, boolean keepFile)
121     {
122         this.path = path;
123         this.mainClass = mainClass;
124         this.type = type;
125         this.executionStage = executionStage;
126         this.onFailure = onFailure;
127         this.argList = argList;
128         this.osList = osList;
129         this.keepFile = keepFile;
130     }
131
132     public String JavaDoc toString()
133     {
134         StringBuffer JavaDoc retval = new StringBuffer JavaDoc();
135         retval.append("path = ").append(path);
136         retval.append("\n");
137         retval.append("mainClass = ").append(mainClass);
138         retval.append("\n");
139         retval.append("type = ").append(type);
140         retval.append("\n");
141         retval.append("executionStage = ").append(executionStage);
142         retval.append("\n");
143         retval.append("onFailure = ").append(onFailure);
144         retval.append("\n");
145         retval.append("argList: ").append(argList);
146         retval.append("\n");
147         if (argList != null)
148         {
149             for (int i = 0; i < argList.size(); i++)
150             {
151                 retval.append("\targ: ").append(argList.get(i));
152                 retval.append("\n");
153             }
154         }
155         retval.append("\n");
156         retval.append("osList = ").append(osList);
157         retval.append("\n");
158         if (osList != null)
159         {
160             for (int i = 0; i < osList.size(); i++)
161             {
162                 retval.append("\tos: ").append(osList.get(i));
163                 retval.append("\n");
164             }
165         }
166         retval.append("keepFile = ").append(keepFile);
167         retval.append("\n");
168         return retval.toString();
169     }
170 }
171
Popular Tags