private void checkFacets(ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
Object ob = validatedInfo.actualValue;
String content = validatedInfo.normalizedValue;
short type = validatedInfo.actualValueType;
ShortList itemType = validatedInfo.itemValueTypes;
// For QName and NOTATION types, we don't check length facets
if (fValidationDV != DV_QNAME && fValidationDV != DV_NOTATION) {
int length = fDVs[fValidationDV].getDataLength(ob);
// maxLength
if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
if ( length > fMaxLength ) {
throw new InvalidDatatypeValueException("cvc-maxLength-valid",
new Object[]{content, Integer.toString(length), Integer.toString(fMaxLength), fTypeName});
}
}
//minLength
if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
if ( length < fMinLength ) {
throw new InvalidDatatypeValueException("cvc-minLength-valid",
new Object[]{content, Integer.toString(length), Integer.toString(fMinLength), fTypeName});
}
}
//length
if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
if ( length != fLength ) {
throw new InvalidDatatypeValueException("cvc-length-valid",
new Object[]{content, Integer.toString(length), Integer.toString(fLength), fTypeName});
}
}
}
//enumeration
if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
boolean present = false;
final int enumSize = fEnumerationSize;
final short primitiveType1 = convertToPrimitiveKind(type);
for (int i = 0; i < enumSize; i++) {
final short primitiveType2 = convertToPrimitiveKind(fEnumeration[i].actualValueType);
if ((primitiveType1 == primitiveType2 ||
primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT)
&& fEnumeration[i].actualValue.equals(ob)) {
if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
ShortList enumItemType = fEnumeration[i].itemValueTypes;
final int typeList1Length = itemType != null ? itemType.getLength() : 0;
final int typeList2Length = enumItemType != null ? enumItemType.getLength() : 0;
if (typeList1Length == typeList2Length) {
int j;
for (j = 0; j < typeList1Length; ++j) {
final short primitiveItem1 = convertToPrimitiveKind(itemType.item(j));
final short primitiveItem2 = convertToPrimitiveKind(enumItemType.item(j));
if (primitiveItem1 != primitiveItem2) {
if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
continue;
}