int length = fDVs[fValidationDV].getDataLength(ob);
// maxLength
if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
if ( length > fMaxLength ) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' exceeds maximum length facet of '"+fMaxLength+"'");
}
}
//minLength
if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
if ( length < fMinLength ) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' is less than minimum length facet of '"+fMinLength+"'" );
}
}
//length
if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
if ( length != fLength ) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' is not equal to length facet '"+fLength+"'");
}
}
//enumeration
if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
boolean present = false;
for (int i = 0; i < fEnumeration.size(); i++) {
if (isEqual(ob, fEnumeration.elementAt(i))) {
present = true;
break;
}
}
if(!present){
throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
new Object [] {content});
}
}
//fractionDigits
if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
int scale = fDVs[fValidationDV].getFractionDigits(ob);
if (scale > fFractionDigits) {
throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
new Object[] {
"'" + content + "'" + " with fractionDigits = '"+ scale +"'",
"'" + fFractionDigits + "'"
});
}
}
//totalDigits
if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
int totalDigits = fDVs[fValidationDV].getTotalDigits(ob);
if (totalDigits > fTotalDigits) {
throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.TOTALDIGITS_EXCEEDED],
new Object[] {
"'" + content + "'" + " with totalDigits = '"+ totalDigits +"'",
"'" + fTotalDigits + "'"
});
}
}
// REVISIT this part for error reporting
boolean minOk = true;
boolean maxOk = true;
String upperBound="";
String lowerBound="";
String lowerBoundIndicator = "";
String upperBoundIndicator = "";
int compare;
//maxinclusive
if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMaxInclusive);
maxOk = (compare == -1 || compare == 0);
upperBound = fMaxInclusive.toString();
if ( upperBound != null ) {
upperBoundIndicator = "<=";
}
else {
upperBound="";
}
}
//maxExclusive
if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMaxExclusive );
maxOk = (compare == -1);
upperBound = fMaxExclusive.toString();
if ( upperBound != null ) {
upperBoundIndicator = "<";
}
else {
upperBound = "";
}
}
//minInclusive
if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMinInclusive);
minOk = (compare == 1 || compare == 0);
lowerBound = fMinInclusive.toString();
if ( lowerBound != null ) {
lowerBoundIndicator = "<=";
}
else {
lowerBound = "";
}
}
//minExclusive
if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMinExclusive);
minOk = (compare == 1);
lowerBound = fMinExclusive.toString();
if ( lowerBound != null ) {
lowerBoundIndicator = "<";
}
else {
lowerBound = "";
}
}
if ( !(minOk && maxOk) ){
throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.OUT_OF_BOUNDS],
new Object [] { ob.toString(), lowerBound, upperBound, lowerBoundIndicator, upperBoundIndicator});
}
}