/* (non-Javadoc) * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.UNTYPED_ATOMIC)) return Collations.compare(collator, value, ((UntypedAtomicValue) other).value) < 0 ? this : other; else return Collations.compare(collator, value, other.getStringValue()) < 0 ? this : other; }
/* (non-Javadoc) * @see org.exist.xquery.value.AtomicValue#compareTo(int, org.exist.xquery.value.AtomicValue) */ public boolean compareTo(Collator collator, int operator, AtomicValue other) throws XPathException { if (other.isEmpty()) return false; if (Type.subTypeOf(other.getType(), Type.STRING) || Type.subTypeOf(other.getType(), Type.UNTYPED_ATOMIC)) { int cmp = Collations.compare(collator, value, other.getStringValue()); switch (operator) { case Constants.EQ: return cmp == 0; case Constants.NEQ: return cmp != 0; case Constants.LT: return cmp < 0; case Constants.LTEQ: return cmp <= 0; case Constants.GT: return cmp > 0; case Constants.GTEQ: return cmp >= 0; default: throw new XPathException("Type error: cannot apply operand to string value"); } } throw new XPathException( "Type error: operands are not comparable; expected xdt:untypedAtomic; got " + Type.getTypeName(other.getType())); }
/* (non-Javadoc) * @see org.exist.xquery.value.AtomicValue#compareTo(org.exist.xquery.value.AtomicValue) */ public int compareTo(Collator collator, AtomicValue other) throws XPathException { return Collations.compare(collator, value, other.getStringValue()); }