KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > functions > CodepointEqual


1 package net.sf.saxon.functions;
2 import net.sf.saxon.expr.XPathContext;
3 import net.sf.saxon.om.Item;
4 import net.sf.saxon.trans.XPathException;
5 import net.sf.saxon.value.AtomicValue;
6 import net.sf.saxon.value.BooleanValue;
7
8 /**
9 * XPath 2.0 codepint-equal() function.
10 * Compares two strings using the unicode codepoint collation. (The function was introduced
11  * specifically to allow URI comparison: URIs are promoted to strings when necessary.)
12 */

13
14 public class CodepointEqual extends CollatingFunction {
15
16     /**
17     * Evaluate the expression
18     */

19
20     public Item evaluateItem(XPathContext context) throws XPathException {
21         AtomicValue op1 = (AtomicValue)argument[0].evaluateItem(context);
22         if (op1 == null) {
23             return null;
24         }
25         AtomicValue op2 = (AtomicValue)argument[1].evaluateItem(context);
26         if (op2 == null) {
27             return null;
28         }
29
30         return BooleanValue.get(op1.getStringValue().equals(op2.getStringValue()));
31     }
32
33 }
34
35 //
36
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
37
// you may not use this file except in compliance with the License. You may obtain a copy of the
38
// License at http://www.mozilla.org/MPL/
39
//
40
// Software distributed under the License is distributed on an "AS IS" basis,
41
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
42
// See the License for the specific language governing rights and limitations under the License.
43
//
44
// The Original Code is: all this file.
45
//
46
// The Initial Developer of the Original Code is Michael Kay
47
//
48
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
49
//
50
// Contributor(s): none.
51
//
52
Popular Tags