commands, ...
This commit is contained in:
parent
66421e806e
commit
75f91dbf4c
44 changed files with 1035 additions and 631 deletions
|
@ -10,24 +10,24 @@ public class LongParser extends DefaultingParser {
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
public Long parse(ScriptEnvironment env, String input) {
|
||||
public Long parse(CommandEnvironment env, String input) {
|
||||
long value;
|
||||
try {
|
||||
value = Long.parseLong(input);
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
throw new ScriptException("Ungültige Ganzzahl '%s'", input);
|
||||
throw new RunException("Ungültige Ganzzahl '%s'", input);
|
||||
}
|
||||
if(this.min != null && value < this.min)
|
||||
if(this.max != null)
|
||||
throw new ScriptException("Die Zahl muss im Bereich %d .. %d liegen, habe %d", this.min, this.max, value);
|
||||
throw new RunException("Die Zahl muss im Bereich %d .. %d liegen, habe %d", this.min, this.max, value);
|
||||
else
|
||||
throw new ScriptException("Die Zahl muss mindestens %d betragen, habe %d", this.min, value);
|
||||
throw new RunException("Die Zahl muss mindestens %d betragen, habe %d", this.min, value);
|
||||
if(this.max != null && value > this.max)
|
||||
if(this.min != null)
|
||||
throw new ScriptException("Die Zahl muss im Bereich %d .. %d liegen, habe %d", this.min, this.max, value);
|
||||
throw new RunException("Die Zahl muss im Bereich %d .. %d liegen, habe %d", this.min, this.max, value);
|
||||
else
|
||||
throw new ScriptException("Die Zahl darf höchstens %d betragen, habe %d", this.max, value);
|
||||
throw new RunException("Die Zahl darf höchstens %d betragen, habe %d", this.max, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue