public void checkConstraints(
final Enumeration localFacets, final Enumeration baseFacets)
throws SchemaException {
while (localFacets.hasMoreElements()) {
final Facet other = (Facet) localFacets.nextElement();
if (this == other) {
continue; // do not check against self
}
final String otherName = other.getName();
if (otherName.equals(Facet.MIN_INCLUSIVE)) {
// Schema Component Constraint: minInclusive and minExclusive
throw new SchemaException(
"It is an error for both minInclusive and minExclusive "
+ "to be specified for the same datatype.");
} else if (otherName.equals(Facet.MAX_INCLUSIVE)
&& getOwningType().isNumericType()
&& this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
// Schema Component Constraint: minExclusive < maxInclusive
throw new SchemaException(
"It is an error for the value specified "
+ "for minExclusive to be greater than "
+ "or equal to the value specified for "
+ "maxInclusive for the same datatype.");
}
}
if (baseFacets != null) {
while (baseFacets.hasMoreElements()) {
final Facet other = (Facet) baseFacets.nextElement();
final String otherName = other.getName();
// Schema Component Constraint: minExclusive valid restriction
// It is an error if any of the following conditions is true:
if (otherName.equals(Facet.MIN_EXCLUSIVE)
&& getOwningType().isNumericType()
&& this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
// [1]
throw new SchemaException(
"It is an error if the following condition is true: "
+ "minExclusive is among the members of {facets} of "
+ "{base type definition} and {value} is less than "
+ "the {value} of the parent minExclusive.");
} else if (otherName.equals(Facet.MAX_INCLUSIVE)
&& getOwningType().isNumericType()
&& this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
// [2]
throw new SchemaException(
"It is an error if the following condition is true: "
+ "maxInclusive is among the members of {facets} of "
+ "{base type definition} and {value} is greater than "
+ "the {value} of the parent maxInclusive.");
} else if (otherName.equals(Facet.MIN_INCLUSIVE)
&& getOwningType().isNumericType()
&& this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
// [3]
throw new SchemaException(
"It is an error if the following condition is true: "
+ "minInclusive is among the members of {facets} of "
+ "{base type definition} and {value} is less than "
+ "the {value} of the parent minInclusive.");
} else if (otherName.equals(Facet.MAX_EXCLUSIVE)
&& getOwningType().isNumericType()
&& this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
// [4]
throw new SchemaException(
"It is an error if the following condition is true: "
+ "maxExclusive is among the members of {facets} of "
+ "{base type definition} and {value} is greater than "