KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > launch4j > ant > AntConfig


1 /*
2     Launch4j (http://launch4j.sourceforge.net/)
3     Cross-platform Java application wrapper for creating Windows native executables.
4
5     Copyright (C) 2004, 2006 Grzegorz Kowal
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */

21
22 /*
23  * Created on May 24, 2005
24  */

25 package net.sf.launch4j.ant;
26
27 import java.io.File JavaDoc;
28 import java.util.ArrayList JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.apache.tools.ant.BuildException;
32
33 import net.sf.launch4j.config.Config;
34 import net.sf.launch4j.config.Splash;
35 import net.sf.launch4j.config.VersionInfo;
36
37 /**
38  * @author Copyright (C) 2005 Grzegorz Kowal
39  */

40 public class AntConfig extends Config {
41     private final List JavaDoc wrappedHeaderObjects = new ArrayList JavaDoc();
42     private final List JavaDoc wrappedLibs = new ArrayList JavaDoc();
43     private final List JavaDoc wrappedVariables = new ArrayList JavaDoc();
44
45     public void setJarPath(String JavaDoc path) {
46         setJar(new File JavaDoc(path));
47     }
48
49     public void addObj(StringWrapper obj) {
50         wrappedHeaderObjects.add(obj);
51     }
52
53     public void addLib(StringWrapper lib) {
54         wrappedLibs.add(lib);
55     }
56     
57     public void addVar(StringWrapper var) {
58         wrappedVariables.add(var);
59     }
60
61     // __________________________________________________________________________________
62

63     public void addClassPath(AntClassPath classPath) {
64         checkNull(getClassPath(), "classPath");
65         setClassPath(classPath);
66     }
67
68     public void addJre(AntJre jre) {
69         checkNull(getJre(), "jre");
70         setJre(jre);
71     }
72
73     public void addSplash(Splash splash) {
74         checkNull(getSplash(), "splash");
75         setSplash(splash);
76     }
77
78     public void addVersionInfo(VersionInfo versionInfo) {
79         checkNull(getVersionInfo(), "versionInfo");
80         setVersionInfo(versionInfo);
81     }
82
83     // __________________________________________________________________________________
84

85     public void unwrap() {
86         setHeaderObjects(StringWrapper.unwrap(wrappedHeaderObjects));
87         setLibs(StringWrapper.unwrap(wrappedLibs));
88         setVariables(StringWrapper.unwrap(wrappedVariables));
89         if (getClassPath() != null) {
90             ((AntClassPath) getClassPath()).unwrap();
91         }
92         if (getJre() != null) {
93             ((AntJre) getJre()).unwrap();
94         }
95     }
96
97     private void checkNull(Object JavaDoc o, String JavaDoc name) {
98         if (o != null) {
99             throw new BuildException(
100                     Messages.getString("AntConfig.duplicate.element")
101                     + ": "
102                     + name);
103         }
104     }
105 }
106
Popular Tags