Methods Summary |
---|
private void | checkBeginWithDash(java.util.Set options)
List invalidOptions = new ArrayList();
Iterator it = options.iterator();
while (it.hasNext()) {
String option = it.next().toString();
if (!option.startsWith("-") &&
!(option.startsWith("\"-") && option.endsWith("\"")) )
{
invalidOptions.add(option);
}
}
if (invalidOptions.size() > 0) {
throw new InvalidJvmOptionsException(
getInvalidJvmOptionMsg(invalidOptions.toString()));
}
|
private void | checkForNullOptions(java.lang.String[] options)
if (null == options) {
throw new InvalidJvmOptionsException(getNullJvmOptionMsg());
}
for (int i = 0; i < options.length; i++) {
if (null == options[i]) {
throw new InvalidJvmOptionsException(getNullJvmOptionMsg());
}
}
|
private void | checkQuotes(java.util.Set options)
List invalidOptions = new ArrayList();
final Iterator it = options.iterator();
while (it.hasNext()) {
String option = it.next().toString();
if (!checkQuotes(option)) {
invalidOptions.add(option);
}
}
if (invalidOptions.size() > 0) {
throw new InvalidJvmOptionsException(
getIncorrectQuotesMsg(invalidOptions.toString()));
}
|
private boolean | checkQuotes(java.lang.String option)
int length = option.length();
int numQuotes = 0;
int index = 0;
while (index < length &&
(index = option.indexOf('\"", index)) != -1)
{
numQuotes++;
index++;
}
return ((numQuotes % 2) == 0);
|
private java.lang.String | getIncorrectQuotesMsg(java.lang.String invalidOptions)
return smh.getLocalString(getClass().getName() + ".incorrectQuotesInJvmOption",
"{0} - Invalid Jvm option. Check quotes",
new Object[] {invalidOptions});
|
private java.lang.String | getInvalidJvmOptionMsg(java.lang.String invalidOptions)
return smh.getLocalString(getClass().getName() + ".invalidJvmOption",
"{0} - Invalid Jvm option. Option must begin with -",
new Object[] {invalidOptions});
|
private java.lang.String | getNullJvmOptionMsg()
return smh.getLocalString(getClass().getName() + ".nullJvmOption",
"Null Jvm option", new Object[0]);
|
private java.util.Set | tokenizeJvmOptions(java.lang.String[] options)
final Set optionsSet = new LinkedHashSet();
final String DELIM = " \t";
for (int i = 0; i < options.length; i++) {
QuotedStringTokenizer strTok = new QuotedStringTokenizer(
options[i], DELIM);
while (strTok.hasMoreTokens()) {
optionsSet.add(strTok.nextToken());
}
}
return Collections.unmodifiableSet(optionsSet);
|
public static void | validateJvmOptions(java.lang.String[] jvmOptions, com.sun.enterprise.config.serverbeans.validation.Result result)
try {
instance.checkForNullOptions(jvmOptions);
Set optionsSet = instance.tokenizeJvmOptions(jvmOptions);
instance.checkBeginWithDash(optionsSet);
instance.checkQuotes(optionsSet);
}
catch (Exception e) {
result.failed(e.getMessage());
}
|