StringTokenizer parsedList = new StringTokenizer( content );
try {
int numberOfTokens = parsedList.countTokens();
if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
if (numberOfTokens > fMaxLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length ='"+ numberOfTokens + "' tokens"+
"' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
}
}
if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
if (numberOfTokens < fMinLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length ='"+ numberOfTokens+ "' tokens" +
"' is less than minimum length facet of '"+fMinLength+"' tokens." );
}
}
if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
if (numberOfTokens != fLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length ='"+ numberOfTokens+ "' tokens" +
"' is not equal to length facet of '"+fLength+"' tokens.");
}
}
if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
// Enumerations are defined in the value space so the contains method
// of vector doesn't really do the right thing, we really should check using compare
if (fEnumeration.contains( content ) == false)
throw new InvalidDatatypeValueException("Value '"+
content+"' must be one of "+fEnumeration);
}
try {
if (this.fDerivedByList) {
if( numberOfTokens == 0 ){
InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );
throw error;
}
while (parsedList.hasMoreTokens()) { //Check each token in list against base type
if (this.fBaseValidator != null) {//validate against parent type if any
this.fBaseValidator.validate( parsedList.nextToken(), state );
}
}
} else {
if (this.fBaseValidator != null) {//validate against parent type if any
this.fBaseValidator.validate( content, state );
}
}
} catch (InvalidDatatypeValueException ex) { //Keep bubbling up exception but change content to list content
//Unfortunately we need to throw a new Exception
InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );//Need Message
error.setKeyIntoReporter( ex.getKeyIntoReporter() );
throw error;//type message repacked with the List content message
}
} catch (NoSuchElementException e) {
e.printStackTrace();