if (other.isEmpty())
{return false;}
final int r = compareTo(collator, other);
if (operator != Constants.EQ && operator != Constants.NEQ){
if (getType() == Type.DURATION)
{throw new XPathException(ErrorCodes.XPTY0004,
"cannot compare unordered " + Type.getTypeName(getType()) + " to "
+ Type.getTypeName(other.getType()));}
if (other.getType()== Type.DURATION)
{throw new XPathException(ErrorCodes.XPTY0004,
"cannot compare " + Type.getTypeName(getType()) + " to unordered "
+ Type.getTypeName(other.getType()));}
if (Type.getCommonSuperType(getType(), other.getType()) == Type.DURATION)
{throw new XPathException(ErrorCodes.XPTY0004,
"cannot compare " + Type.getTypeName(getType()) + " to "
+ Type.getTypeName(other.getType()));}
}
switch (operator) {
case Constants.EQ :
return r == DatatypeConstants.EQUAL;
case Constants.NEQ :
return r != DatatypeConstants.EQUAL;
case Constants.LT :
return r == DatatypeConstants.LESSER;
case Constants.LTEQ :
return r == DatatypeConstants.LESSER || r == DatatypeConstants.EQUAL;
case Constants.GT :
return r == DatatypeConstants.GREATER;
case Constants.GTEQ :
return r == DatatypeConstants.GREATER || r == DatatypeConstants.EQUAL;
default :
throw new XPathException("Unknown operator type in comparison");
}
}