class DataMatcher {
public static boolean compareActualValues(Object value1, Object value2, int comparator,
XSSimpleTypeDecl type) {
TypeValidator typeValidator = type.getTypeValidator();
short ordered = type.getOrdered();
if (ordered == XSSimpleTypeDecl.ORDERED_FALSE) {
//if the type is not ordered then only equality can be tested
//delegate the test to the type
if (comparator == CompNode.EQ) {
return type.isEqual(value1, value2);
}
else if (comparator == CompNode.NE) {
return !type.isEqual(value1, value2);
}
else {
//only equality can be tested upon unordered types
return false;
}
}
//if the type is ordered then the corresponding TypeValidator should
//know how to compare the values
switch (comparator) {
case CompNode.EQ: return typeValidator.compare(value1, value2) == 0;
case CompNode.NE: return typeValidator.compare(value1, value2) != 0;
case CompNode.GT: return typeValidator.compare(value1, value2) > 0;
case CompNode.GE: return typeValidator.compare(value1, value2) >= 0;
case CompNode.LT: return typeValidator.compare(value1, value2) < 0;
case CompNode.LE: return typeValidator.compare(value1, value2) <= 0;
}
return false;
}