01: package net.sf.saxon.functions;
02:
03: import net.sf.saxon.expr.XPathContext;
04: import net.sf.saxon.om.Item;
05: import net.sf.saxon.trans.XPathException;
06: import net.sf.saxon.value.AtomicValue;
07: import net.sf.saxon.value.BooleanValue;
08:
09: /**
10: * XPath 2.0 codepint-equal() function.
11: * Compares two strings using the unicode codepoint collation. (The function was introduced
12: * specifically to allow URI comparison: URIs are promoted to strings when necessary.)
13: */
14:
15: public class CodepointEqual extends CollatingFunction {
16:
17: /**
18: * Evaluate the expression
19: */
20:
21: public Item evaluateItem(XPathContext context)
22: throws XPathException {
23: AtomicValue op1 = (AtomicValue) argument[0]
24: .evaluateItem(context);
25: if (op1 == null) {
26: return null;
27: }
28: AtomicValue op2 = (AtomicValue) argument[1]
29: .evaluateItem(context);
30: if (op2 == null) {
31: return null;
32: }
33:
34: return BooleanValue.get(op1.getStringValue().equals(
35: op2.getStringValue()));
36: }
37:
38: }
39:
40: //
41: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
42: // you may not use this file except in compliance with the License. You may obtain a copy of the
43: // License at http://www.mozilla.org/MPL/
44: //
45: // Software distributed under the License is distributed on an "AS IS" basis,
46: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
47: // See the License for the specific language governing rights and limitations under the License.
48: //
49: // The Original Code is: all this file.
50: //
51: // The Initial Developer of the Original Code is Michael Kay
52: //
53: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
54: //
55: // Contributor(s): none.
56: //
|