Debian Codegraph @

net/sf/saxon/functions/CodepointEqual.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.functions;
9
10 import net.sf.saxon.expr.Callable;
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.om.Sequence;
13 import net.sf.saxon.om.ZeroOrOne;
14 import net.sf.saxon.trans.XPathException;
15 import net.sf.saxon.value.BooleanValue;
16 import net.sf.saxon.value.StringValue;
17
18 /**
19 * Implements the XPath 2.0 fn:codepoint-equal() function.
20 *
21 * <p>Compares two strings using the Unicode codepoint collation. (The function was introduced
22 * specifically to allow URI comparison: URIs are promoted to strings when necessary.) </p>
23 */
24
25 public class CodepointEqual extends SystemFunction implements Callable {
26
27 public ZeroOrOne<BooleanValue> call(XPathContext context, Sequence[] arguments) throws XPathException {
28 StringValue op1 = (StringValue) arguments[0].head();
29 StringValue op2 = (StringValue) arguments[1].head();
30 if (op1 == null || op2 == null) {
31 return ZeroOrOne.empty();
32 }
33 return new ZeroOrOne<>(BooleanValue.get(op1.getStringValue().equals(op2.getStringValue())));
34 }
35
36 }
37