case '8':
case '9':
case '0':
break LOOP;
default:
throw new CommandSyntaxException("Invalid field: " + text);
}
i--;
}
text = text.substring(0, i + 1);
i = text.indexOf('.');
if (i == 0) {
throw new CommandSyntaxException("Field offset cannot be empty");
}
if (i == (text.length() - 1)) {
throw new CommandSyntaxException("Character offset cannot be empty if '.' is given");
}
try {
if (i == -1) {
field.field = Integer.parseInt(text) - 1;
field.offset = end ? -1 : 0;
} else {
field.field = Integer.parseInt(text.substring(0, i)) - 1;
field.offset = Integer.parseInt(text.substring(i + 1)) - 1;
}
} catch (NumberFormatException e) {
throw new CommandSyntaxException("Invalid number: " + text);
}
if (field.field < 0) {
throw new CommandSyntaxException("Field offset cannot be less than one: " + field.field);
}
if (field.offset < 0 && !end) {
throw new CommandSyntaxException("Start character offset cannot be less than one: " + field.offset);
}
if (field.offset < -1 && end) {
throw new CommandSyntaxException("End character offset cannot be less than zero");
}
return field;
}