use of ffx.potential.parameters.ForceField.ForceFieldInteger in project ffx by mjschnie.
the class ForceFieldFilter method parseKeyword.
private boolean parseKeyword(String[] tokens) {
String keyword = toEnumForm(tokens[0]);
try {
// Parse Keywords with a String value.
ForceFieldString ffString = ForceFieldString.valueOf(keyword);
int len = tokens.length;
if (len == 1) {
forceField.addForceFieldString(ffString, null);
} else if (len == 2) {
forceField.addForceFieldString(ffString, tokens[1]);
} else {
StringBuilder stringBuilder = new StringBuilder(tokens[1]);
for (int i = 2; i < len; i++) {
stringBuilder.append(" ");
stringBuilder.append(tokens[i]);
}
forceField.addForceFieldString(ffString, stringBuilder.toString());
}
} catch (Exception e) {
try {
// Parse Keywords with a Double value.
ForceFieldDouble ffDouble = ForceFieldDouble.valueOf(keyword);
double value = Double.parseDouble(tokens[1]);
forceField.addForceFieldDouble(ffDouble, value);
} catch (Exception e2) {
try {
// Parse Keywords with an Integer value.
ForceFieldInteger ffInteger = ForceFieldInteger.valueOf(keyword);
int value = Integer.parseInt(tokens[1]);
forceField.addForceFieldInteger(ffInteger, value);
} catch (Exception e3) {
try {
// Parse Keywords with a Boolean value.
ForceFieldBoolean ffBoolean = ForceFieldBoolean.valueOf(keyword);
boolean value = true;
if (tokens.length > 1 && tokens[0].toUpperCase().endsWith("TERM")) {
/**
* Handle the token "ONLY" specially to shut off all
* other terms.
*/
if (tokens[1].equalsIgnoreCase("ONLY")) {
for (ForceFieldBoolean term : ForceFieldBoolean.values()) {
if (term.toString().toUpperCase().endsWith("TERM")) {
forceField.addForceFieldBoolean(term, false);
}
}
} else if (tokens[1].equalsIgnoreCase("NONE")) {
/**
* Legacy support for the "NONE" token.
*/
value = false;
} else {
value = Boolean.parseBoolean(tokens[1]);
}
}
forceField.addForceFieldBoolean(ffBoolean, value);
forceField.log(keyword);
} catch (Exception e4) {
return false;
}
}
}
}
return true;
}
Aggregations