return sb.toString();
}
public static Range valueOf(String var) throws ExprException {
if (var == null) {
throw new ExprException("Invalid empty variable name");
}
String namespace = null;
int ni = var.indexOf('!');
if (ni != -1) {
namespace = var.substring(0, ni);
if (!namespace.startsWith("'") &&
!GridReference.isValidVariable(namespace)) {
throw new ExprException("Invalid namespace: " + namespace);
}
var = var.substring(ni + 1);
}
String dim1Name = null;
GridReference dim1 = null;
String dim2Name = null;
GridReference dim2 = null;
int di = var.indexOf(':');
if (di != -1) {
dim1Name = var.substring(0, di);
dim1 = GridReference.valueOf(dim1Name);
if (dim1 == null && !GridReference.isValidVariable(dim1Name)) {
throw new ExprException("Invalid variable: " + dim1Name);
}
dim2Name = var.substring(di + 1);
dim2 = GridReference.valueOf(dim2Name);
if (dim2 == null && !GridReference.isValidVariable(dim2Name)) {
throw new ExprException("Invalid variable: " + dim2Name);
}
} else {
dim1Name = var;
dim1 = GridReference.valueOf(var);
if (dim1 == null && !GridReference.isValidVariable(dim1Name)) {
throw new ExprException("Invalid variable: " + dim1Name);
}
}
return new Range(namespace, dim1Name, dim1, dim2Name, dim2);