001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2001,2002 Olexij Tkatchenko
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021:
022: package com.izforge.izpack;
023:
024: import com.izforge.izpack.util.OsConstraint;
025:
026: import java.io.Serializable;
027: import java.util.ArrayList;
028: import java.util.List;
029:
030: /**
031: * Encloses information about a executable file. This class abstracts the way to do a system
032: * dependent postprocessing of installation.
033: *
034: * @author Olexij Tkatchenko <ot@parcs.de>
035: */
036:
037: public class ExecutableFile implements Serializable {
038:
039: static final long serialVersionUID = 4175489415984990405L;
040:
041: /** when to execute this file */
042: public final static int POSTINSTALL = 0;
043:
044: public final static int NEVER = 1;
045:
046: public final static int UNINSTALL = 2;
047:
048: /** type of a file */
049: public final static int BIN = 0;
050:
051: public final static int JAR = 1;
052:
053: /** what to do if execution fails */
054: public final static int ABORT = 0;
055:
056: public final static int WARN = 1;
057:
058: public final static int ASK = 2;
059:
060: public final static int IGNORE = 3;
061:
062: /** The file path */
063: public String path;
064:
065: /** Execution stage (NEVER, POSTINSTALL, UNINSTALL) */
066: public int executionStage;
067:
068: /** Main class of jar file */
069: public String mainClass;
070:
071: /** type (BIN|JAR) */
072: public int type;
073:
074: /** Failure handling (ABORT, WARN, ASK) */
075: public int onFailure;
076:
077: /** List of arguments */
078: public List<String> argList = null;
079:
080: /** List of operating systems to run on */
081: public List<OsConstraint> osList = null;
082:
083: /**
084: * Indicates the file should be kept after executing. Default is false for backward
085: * compatibility.
086: */
087: public boolean keepFile;
088:
089: /** condition for this executable */
090: private String condition = null;
091:
092: /** Constructs a new uninitialized instance. */
093: public ExecutableFile() {
094: this .path = null;
095: executionStage = NEVER;
096: mainClass = null;
097: type = BIN;
098: onFailure = ASK;
099: osList = new ArrayList<OsConstraint>();
100: argList = new ArrayList<String>();
101: keepFile = false;
102: }
103:
104: /**
105: * Constructs and initializes a new instance.
106: *
107: * @param path the file path
108: * @param executionStage when to execute
109: * @param onFailure what to do if execution fails
110: * @param osList list of operating systems to run on
111: */
112: public ExecutableFile(String path, int executionStage,
113: int onFailure, List<OsConstraint> osList, boolean keepFile) {
114: this .path = path;
115: this .executionStage = executionStage;
116: this .onFailure = onFailure;
117: this .osList = osList;
118: this .keepFile = keepFile;
119: }
120:
121: public ExecutableFile(String path, int type, String mainClass,
122: int executionStage, int onFailure, List<String> argList,
123: List<OsConstraint> osList, boolean keepFile) {
124: this .path = path;
125: this .mainClass = mainClass;
126: this .type = type;
127: this .executionStage = executionStage;
128: this .onFailure = onFailure;
129: this .argList = argList;
130: this .osList = osList;
131: this .keepFile = keepFile;
132: }
133:
134: public String toString() {
135: StringBuffer retval = new StringBuffer();
136: retval.append("path = ").append(path);
137: retval.append("\n");
138: retval.append("mainClass = ").append(mainClass);
139: retval.append("\n");
140: retval.append("type = ").append(type);
141: retval.append("\n");
142: retval.append("executionStage = ").append(executionStage);
143: retval.append("\n");
144: retval.append("onFailure = ").append(onFailure);
145: retval.append("\n");
146: retval.append("argList: ").append(argList);
147: retval.append("\n");
148: if (argList != null) {
149: for (String anArgList : argList) {
150: retval.append("\targ: ").append(anArgList);
151: retval.append("\n");
152: }
153: }
154: retval.append("\n");
155: retval.append("osList = ").append(osList);
156: retval.append("\n");
157: if (osList != null) {
158: for (OsConstraint anOsList : osList) {
159: retval.append("\tos: ").append(anOsList);
160: retval.append("\n");
161: }
162: }
163: retval.append("keepFile = ").append(keepFile);
164: retval.append("\n");
165: return retval.toString();
166: }
167:
168: /**
169: * @return the condition
170: */
171: public String getCondition() {
172: return this .condition;
173: }
174:
175: /**
176: * @param condition the condition to set
177: */
178: public void setCondition(String condition) {
179: this .condition = condition;
180: }
181:
182: public boolean hasCondition() {
183: return this.condition != null;
184: }
185: }
|