public RequestTypeWithOptions(String v) throws DmcValueException {
ArrayList<String> tokens = CheapSplitter.split(v.replaceAll("\t", " ").trim(), ' ', false, true);
if (tokens.size() < 2){
throw(new DmcValueException("Too few tokens. Value should be of the form: <request type> <function name> [className] [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS CENTRALERRORS]"));
}
requestType = tokens.get(0);
if (requestType.endsWith("Request")){
int pos = requestType.indexOf("Request");
requestType = requestType.substring(0, pos);
}
functionName = tokens.get(1);
int optionStart = 2;
if (requestType.equals("Set") || requestType.equals("Create")){
optionStart = 3;
if (tokens.size() < 3)
throw(new DmcValueException("Too few tokens for a " + requestType + "Request. Value should be of the form: <request type> <function name> <className> [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS CENTRALERRORS]"));
className = tokens.get(2);
if (RequestOptionEnum.get(className) != null)
throw(new DmcValueException("Missing class name for " + requestType + "Request. Value should be of the form: <request type> <function name> <className> [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS CENTRALERRORS]"));
}
if (tokens.size() > optionStart){
options = new HashSet<RequestOptionEnum>();
for(int i=optionStart; i<tokens.size(); i++){
RequestOptionEnum val = RequestOptionEnum.get(tokens.get(i));
if (val == null)
throw(new DmcValueException(tokens.get(i) + " is not a valid option."));
if ( (val == RequestOptionEnum.CACHE) || (val == RequestOptionEnum.EVENTS)){
if (!requestType.equals("Get"))
throw(new DmcValueException("The " + val + " option is only valid with GetRequests"));
}
options.add(val);
}
if ((options.size()==1) && options.contains(RequestOptionEnum.DMPERRORS)){