KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > launch4j > config > Jre


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 Apr 21, 2005
24  */

25 package net.sf.launch4j.config;
26
27 import java.util.List JavaDoc;
28
29 import net.sf.launch4j.binding.IValidatable;
30 import net.sf.launch4j.binding.Validator;
31
32 /**
33  * @author Copyright (C) 2005 Grzegorz Kowal
34  */

35 public class Jre implements IValidatable {
36
37     // 1.x config properties_____________________________________________________________
38
public static final String JavaDoc PATH = "jrepath";
39     public static final String JavaDoc MIN_VERSION = "javamin";
40     public static final String JavaDoc MAX_VERSION = "javamax";
41     public static final String JavaDoc ARGS = "jvmArgs";
42
43     // __________________________________________________________________________________
44
public static final String JavaDoc VERSION_PATTERN = "(\\d\\.){2}\\d(_\\d+)?";
45
46     private String JavaDoc path;
47     private String JavaDoc minVersion;
48     private String JavaDoc maxVersion;
49     private boolean dontUsePrivateJres;
50     private int initialHeapSize;
51     private int maxHeapSize;
52     private List JavaDoc options;
53
54     public void checkInvariants() {
55         Validator.checkOptString(minVersion, 10, VERSION_PATTERN,
56                 "jre.minVersion", Messages.getString("Jre.min.version"));
57         Validator.checkOptString(maxVersion, 10, VERSION_PATTERN,
58                 "jre.maxVersion", Messages.getString("Jre.max.version"));
59         if (Validator.isEmpty(path)) {
60             Validator.checkFalse(Validator.isEmpty(minVersion),
61                     "jre.path", Messages.getString("Jre.specify.jre.path.min.version"));
62         } else {
63             Validator.checkString(path, Validator.MAX_PATH,
64                     "jre.path", Messages.getString("Jre.embedded.path"));
65         }
66         if (!Validator.isEmpty(maxVersion)) {
67             Validator.checkFalse(Validator.isEmpty(minVersion),
68                     "jre.minVersion", Messages.getString("Jre.specify.min.version"));
69             Validator.checkTrue(minVersion.compareTo(maxVersion) < 0,
70                     "jre.maxVersion", Messages.getString("Jre.max.greater.than.min"));
71         }
72         Validator.checkTrue(initialHeapSize >= 0, "jre.initialHeapSize",
73                 Messages.getString("Jre.initial.heap"));
74         Validator.checkTrue(maxHeapSize == 0 || initialHeapSize <= maxHeapSize,
75                 "jre.maxHeapSize", Messages.getString("Jre.max.heap"));
76         Validator.checkOptStrings(options,
77                 Validator.MAX_ARGS,
78                 Validator.MAX_ARGS,
79                 "[^\"]*|([^\"]*\"[^\"]*\"[^\"]*)*",
80                 "jre.options",
81                 Messages.getString("Jre.jvm.options"),
82                 Messages.getString("Jre.jvm.options.unclosed.quotation"));
83
84         // Quoted variable references: "[^%]*|([^%]*\"([^%]*%[^%]+%[^%]*)+\"[^%]*)*"
85
Validator.checkOptStrings(options,
86                 Validator.MAX_ARGS,
87                 Validator.MAX_ARGS,
88                 "[^%]*|([^%]*([^%]*%[^%]+%[^%]*)+[^%]*)*",
89                 "jre.options",
90                 Messages.getString("Jre.jvm.options"),
91                 Messages.getString("Jre.jvm.options.variable"));
92     }
93
94     /** JVM options */
95     public List JavaDoc getOptions() {
96         return options;
97     }
98
99     public void setOptions(List JavaDoc options) {
100         this.options = options;
101     }
102
103     /** Max Java version (x.x.x) */
104     public String JavaDoc getMaxVersion() {
105         return maxVersion;
106     }
107
108     public void setMaxVersion(String JavaDoc maxVersion) {
109         this.maxVersion = maxVersion;
110     }
111
112     /** Min Java version (x.x.x) */
113     public String JavaDoc getMinVersion() {
114         return minVersion;
115     }
116
117     public void setMinVersion(String JavaDoc minVersion) {
118         this.minVersion = minVersion;
119     }
120
121     /** Include private JREs in search */
122     public boolean isDontUsePrivateJres() {
123         return dontUsePrivateJres;
124     }
125
126     public void setDontUsePrivateJres(boolean dontUsePrivateJres) {
127         this.dontUsePrivateJres = dontUsePrivateJres;
128     }
129
130     /** JRE path */
131     public String JavaDoc getPath() {
132         return path;
133     }
134
135     public void setPath(String JavaDoc path) {
136         this.path = path;
137     }
138
139     /** Initial heap size in MB */
140     public int getInitialHeapSize() {
141         return initialHeapSize;
142     }
143
144     public void setInitialHeapSize(int initialHeapSize) {
145         this.initialHeapSize = initialHeapSize;
146     }
147
148     /** Max heap size in MB */
149     public int getMaxHeapSize() {
150         return maxHeapSize;
151     }
152
153     public void setMaxHeapSize(int maxHeapSize) {
154         this.maxHeapSize = maxHeapSize;
155     }
156 }
157
Popular Tags