Long length = atomicType.getLength();
Long maxLength = atomicType.getMaxLength();
Long minLength = atomicType.getMinLength();
if (minLength != null && minLength.longValue() < 0) {
throw new LocSAXException("Negative value for minLength detected: " + minLength, getLocator());
}
if (maxLength != null) {
if (maxLength.longValue() < 0) {
throw new LocSAXException("Negative value for maxLength detected: " + maxLength, getLocator());
}
if (minLength != null) {
if (maxLength.longValue() < minLength.longValue()) {
throw new LocSAXException("MaxLength value of " + maxLength + " is smaller than minLength value of " + minLength,
getLocator());
}
if (maxLength.longValue() == minLength.longValue()) {
length = maxLength;
}
}
}
if (length != null) {
if (length.longValue() < 0) {
throw new LocSAXException("Negative value for length detected: " + length, getLocator());
}
if (maxLength != null) {
if (maxLength.longValue() < length.longValue()) {
throw new LocSAXException("MaxLength value of " + maxLength + " is smaller than length value of " + length,
getLocator());
}
maxLength = null; // Avoid unnecessary checks
}
if (minLength != null) {
if (minLength.longValue() > length.longValue()) {
throw new LocSAXException("MinLength value of " + minLength + " is larger than length value of " + length,
getLocator());
}
minLength = null; // Avoid unnecessary checks
}
}