fFacetsDefined += DatatypeValidator.FACET_LENGTH;
String lengthValue = (String)facets.get(key);
try {
fLength = Integer.parseInt( lengthValue );
} catch (NumberFormatException nfe) {
throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
}
if ( fLength < 0 )
throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
} else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
String minLengthValue = (String)facets.get(key);
try {
fMinLength = Integer.parseInt( minLengthValue );
} catch (NumberFormatException nfe) {
throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' is invalid.");
}
} else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
String maxLengthValue = (String)facets.get(key);
try {
fMaxLength = Integer.parseInt( maxLengthValue );
} catch (NumberFormatException nfe) {
throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
}
} else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
fFacetsDefined += DatatypeValidator.FACET_PATTERN;
fPattern = (String)facets.get(key);
fRegex = new RegularExpression(fPattern, "X");
} else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
fEnumeration = (Vector)facets.get(key);
/* Per Schema CR - October 23 spec we don't have this facets in String datatype
} else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
fFacetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
fMaxInclusive = (String)facets.get(key);
} else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
fMaxExclusive = (String)facets.get(key);
} else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
fMinInclusive = (String)facets.get(key);
} else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
fFacetsDefined += DatatypeValidator.FACET_MINEXCLUSIVE;
fMinExclusive = (String)facets.get(key);
*/
} else if (key.equals(SchemaSymbols.ELT_WHITESPACE)) {
String whiteSpaceChoice = (String)facets.get(key);
fFacetsDefined += DatatypeValidator.FACET_WHITESPACE;
if ( whiteSpaceChoice.equals("preserve" ) ) {
fWhiteSpace = DatatypeValidator.WHITESPACE_PRESERVE;
} else if ( whiteSpaceChoice.equals("replace") ) {
fWhiteSpace = DatatypeValidator.WHITESPACE_REPLACE;
} else if ( whiteSpaceChoice.equals("collapse") ) {
fWhiteSpace = DatatypeValidator.WHITESPACE_COLLAPSE;
}
} else {
throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
}
}
if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
throw new InvalidDatatypeFacetException(
"It is an error for both length and maxLength to be members of facets." );
} else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
throw new InvalidDatatypeFacetException(
"It is an error for both length and minLength to be members of facets." );
}
}
if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
if ( fMinLength > fMaxLength ) {
throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
"'must be less than the value of maxLength = '" + fMaxLength + "'.");
}
}
isMaxExclusiveDefined = ((fFacetsDefined &
DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
isMaxInclusiveDefined = ((fFacetsDefined &
DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
isMinExclusiveDefined = ((fFacetsDefined &
DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
isMinInclusiveDefined = ((fFacetsDefined &
DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;
if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
throw new InvalidDatatypeFacetException(
"It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
}
if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
throw new InvalidDatatypeFacetException(
"It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
}
}// End of Facets Setting
}