1 21 22 25 package net.sf.launch4j.config; 26 27 import java.util.List ; 28 29 import net.sf.launch4j.binding.IValidatable; 30 import net.sf.launch4j.binding.Validator; 31 32 35 public class Jre implements IValidatable { 36 37 public static final String PATH = "jrepath"; 39 public static final String MIN_VERSION = "javamin"; 40 public static final String MAX_VERSION = "javamax"; 41 public static final String ARGS = "jvmArgs"; 42 43 public static final String VERSION_PATTERN = "(\\d\\.){2}\\d(_\\d+)?"; 45 46 private String path; 47 private String minVersion; 48 private String maxVersion; 49 private boolean dontUsePrivateJres; 50 private int initialHeapSize; 51 private int maxHeapSize; 52 private List 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 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 95 public List getOptions() { 96 return options; 97 } 98 99 public void setOptions(List options) { 100 this.options = options; 101 } 102 103 104 public String getMaxVersion() { 105 return maxVersion; 106 } 107 108 public void setMaxVersion(String maxVersion) { 109 this.maxVersion = maxVersion; 110 } 111 112 113 public String getMinVersion() { 114 return minVersion; 115 } 116 117 public void setMinVersion(String minVersion) { 118 this.minVersion = minVersion; 119 } 120 121 122 public boolean isDontUsePrivateJres() { 123 return dontUsePrivateJres; 124 } 125 126 public void setDontUsePrivateJres(boolean dontUsePrivateJres) { 127 this.dontUsePrivateJres = dontUsePrivateJres; 128 } 129 130 131 public String getPath() { 132 return path; 133 } 134 135 public void setPath(String path) { 136 this.path = path; 137 } 138 139 140 public int getInitialHeapSize() { 141 return initialHeapSize; 142 } 143 144 public void setInitialHeapSize(int initialHeapSize) { 145 this.initialHeapSize = initialHeapSize; 146 } 147 148 149 public int getMaxHeapSize() { 150 return maxHeapSize; 151 } 152 153 public void setMaxHeapSize(int maxHeapSize) { 154 this.maxHeapSize = maxHeapSize; 155 } 156 } 157 | Popular Tags |