public boolean compareTo(Collator collator, int operator, AtomicValue other) throws XPathException {
switch (operator) {
case Constants.EQ :
{
if (!(DurationValue.class.isAssignableFrom(other.getClass())))
{throw new XPathException(ErrorCodes.XPTY0004, "invalid operand type: " + Type.getTypeName(other.getType()));}
//TODO : upgrade so that P365D is *not* equal to P1Y
boolean r = duration.equals(((DurationValue)other).duration);
//confirm strict equality to work around the JDK standard behaviour
if (r)
{r = r & areReallyEqual(getCanonicalDuration(), ((DurationValue)other).getCanonicalDuration());}
return r;
}
case Constants.NEQ :
{
if (!(DurationValue.class.isAssignableFrom(other.getClass())))
{throw new XPathException(ErrorCodes.XPTY0004, "invalid operand type: " + Type.getTypeName(other.getType()));}
//TODO : upgrade so that P365D is *not* equal to P1Y
boolean r = duration.equals(((DurationValue)other).duration);
//confirm strict equality to work around the JDK standard behaviour
if (r)
{r = r & areReallyEqual(getCanonicalDuration(), ((DurationValue)other).getCanonicalDuration());}
return !r;
}
case Constants.LT :
case Constants.LTEQ :
case Constants.GT :
case Constants.GTEQ :
throw new XPathException(ErrorCodes.XPTY0004, "" + Type.getTypeName(other.getType()) + " type can not be ordered");
default :
throw new IllegalArgumentException("Unknown comparison operator");
}
}