switch(type){
case IRObject.iEntity : {
if(defaultstr.length()==0)return RNull.getRNull();
IREntity e = ef.findcreateRefEntity(false,RName.getRName(defaultstr));
if(e==null)throw new RulesException(
"ParsingError",
"EntityFactory.computeDefaultValue()",
"Entity Factory does not define an entity '"+defaultstr+"'");
return e;
}
case IRObject.iArray : {
if(defaultstr.length()==0) return new RArray(ef.getUniqueID(), true,false);
RArray rval;
try{
RArray v = (RArray) RString.compile(session, defaultstr, false); // We assume any values are surrounded by brackets, and regardless make
rval = v.get(0).getNonExecutable().rArrayValue(); // sure they are non-executable.
}catch(RulesException e){
throw new RulesException("ParsingError","EntityFactory.computeDefaultValue()","Bad format for an array. \r\n"+
"\r\nWe tried to interpret the string \r\n'"+defaultstr+"'\r\nas an array, but could not.\r\n"+e.toString());
}
return rval;
}
case IRObject.iString :
if(defaultstr.length()==0)return RNull.getRNull();
return RString.newRString(defaultstr);
case IRObject.iName :
if(defaultstr.length()==0)return RNull.getRNull();
return RName.getRName(defaultstr.trim(),false);
case IRObject.iBoolean : {
if(defaultstr.length()==0)return RNull.getRNull();
return RBoolean.getRBoolean(defaultstr);
}
case IRObject.iDouble : {
if(defaultstr.length()==0)return RNull.getRNull();
double value = Double.parseDouble(defaultstr);
return RDouble.getRDoubleValue(value);
}
case IRObject.iInteger : {
if(defaultstr.length()==0)return RNull.getRNull();
long value = Long.parseLong(defaultstr);
return RInteger.getRIntegerValue(value);
}
case IRObject.iTime : {
if(defaultstr.length()==0) return RNull.getRNull();
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");
try {
Date date = fmt.parse(defaultstr);
return RTime.getRTime(date);
} catch (ParseException e) {
throw new RulesException("Invalid Date Format","EntityFactory.computeDefaultValue","Only support dates in 'MM/dd/yyyy' form.");
}
}
case IRObject.iTable : {
RTable table = RTable.newRTable(ef, null, defaultstr, -1);
if(defaultstr.length()==0) return table;