1 21 22 25 package net.sf.launch4j.ant; 26 27 import java.io.File ; 28 import java.util.ArrayList ; 29 import java.util.List ; 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 40 public class AntConfig extends Config { 41 private final List wrappedHeaderObjects = new ArrayList (); 42 private final List wrappedLibs = new ArrayList (); 43 private final List wrappedVariables = new ArrayList (); 44 45 public void setJarPath(String path) { 46 setJar(new File (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 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 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 o, String name) { 98 if (o != null) { 99 throw new BuildException( 100 Messages.getString("AntConfig.duplicate.element") 101 + ": " 102 + name); 103 } 104 } 105 } 106 | Popular Tags |