}
}
static public void validate(String queueName) throws QueueFatalException {
if (queueName == null) {
throw new QueueFatalException("Queue name cannot be null");
}
if (queueName.equals("")) {
throw new QueueFatalException("Queue name cannot be an empty string");
}
// name can only contain a-z, A-Z, 0-9, or .-_ (not as the first character)
for (int i = 0; i < queueName.length(); i++) {
char c = queueName.charAt(i);
if ('a' <= c && c <= 'z') {
// do nothing
} else if ('A' <= c && c <= 'Z') {
// do nothing
} else if ('0' <= c && c <= '9') {
// do nothing
} else if (c == '+') {
// do nothing
} else if (i != 0 && (c == '.' || c == '-' || c == '_')) {
// do nothing
} else {
throw new QueueFatalException("Invalid character [" + c + "] in queue name [" + queueName + "]");
}
}
}