if (counterName.contains(Counters.DELIMITER)) {
throw new EXistException("Invalid name for counter, character '"
+ Counters.DELIMITER + "' is not allowed.");
} else {
return new IntegerValue(counters.createCounter(counterName), Type.LONG);
}
} catch (EXistException e) {
logger.error(e.getMessage());
return Sequence.EMPTY_SEQUENCE;
}
} else if (getSignature().equals(createCounterAndInit)) {
try {
Long initValue = Long.parseLong(args[1].getStringValue());
if (counterName.contains(Counters.DELIMITER)) {
throw new EXistException("Invalid name for counter, character '"
+ Counters.DELIMITER + "' is not allowed.");
} else {
return new IntegerValue( counters.createCounter(counterName, initValue), Type.LONG);
}
} catch (EXistException e) {
logger.error(e.getMessage());
return Sequence.EMPTY_SEQUENCE;
}
} else {
try {
if (getSignature().equals(destroyCounter)) {
return new BooleanValue(counters.destroyCounter(counterName));
} else if (getSignature().equals(nextValue)) {
return new IntegerValue(counters.nextValue(counterName), Type.LONG);
} else {
return Sequence.EMPTY_SEQUENCE;
}