* @throws ResultException If the specified string doesn't match the appropriate
* value format.
*/
public void set(String v) throws DmcValueException {
if (v == null){
throw(new DmcValueException("null value passed to EnumValue.set()"));
}
String value = v.replaceAll("\t", " ").trim();
int space = value.indexOf(" ");
if (space == -1)
throw(new DmcValueException("Missing enum value name: " + value + " - value should be of the form: int enum_val_name [description] <: label>"));
try {
id = Integer.valueOf(value.substring(0,space));
} catch (NumberFormatException e) {
throw(new DmcValueException("Invalid enum integer value: " + value + "\n" + e));
}
String remainder = value.substring(space+1).trim();
space = remainder.indexOf(" ");
if (space == -1)
throw(new DmcValueException("Missing enum description: " + value + " - value should be of the form: int enum_val_name [description] <: label>"));
String tmp = remainder.substring(0,space);
if (Character.isLetter(tmp.charAt(0))){
name = tmp.toUpperCase();
}
else{
throw(new DmcValueException("Enum value name must start with a character: " + tmp));
}
remainder = remainder.substring(space+1).trim();
int colon = remainder.indexOf(":");
if (colon == -1){
description = remainder.trim();
}
else{
description = remainder.substring(0,colon).trim();
if ( (colon+1) == remainder.length()){
throw(new DmcValueException("Missing label value: " + value + " - value should be of the form: int enum_val_name [description] <: label>"));
}
label = remainder.substring(colon+1).trim();
}