Debian Codegraph @

net/sf/saxon/functions/StringToCodepoints.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.XPathContext;
11 import net.sf.saxon.om.Sequence;
12 import net.sf.saxon.om.SequenceTool;
13 import net.sf.saxon.trans.XPathException;
14 import net.sf.saxon.value.EmptySequence;
15 import net.sf.saxon.value.Int64Value;
16 import net.sf.saxon.value.IntegerValue;
17 import net.sf.saxon.value.StringValue;
18
19 /**
20 * This class supports the function string-to-codepoints()
21 */
22
23 public class StringToCodepoints extends SystemFunction {
24
25 /**
26 * For an expression that returns an integer or a sequence of integers, get
27 * a lower and upper bound on the values of the integers that may be returned, from
28 * static analysis. The default implementation returns null, meaning "unknown" or
29 * "not applicable". Other implementations return an array of two IntegerValue objects,
30 * representing the lower and upper bounds respectively. The values
31 * UNBOUNDED_LOWER and UNBOUNDED_UPPER are used by convention to indicate that
32 * the value may be arbitrarily large. The values MAX_STRING_LENGTH and MAX_SEQUENCE_LENGTH
33 * are used to indicate values limited by the size of a string or the size of a sequence.
34 *
35 * @return the lower and upper bounds of integer values in the result, or null to indicate
36 * unknown or not applicable.
37 */
38 @Override
39 public IntegerValue[] getIntegerBounds() {
40 return new IntegerValue[]{Int64Value.PLUS_ONE, Int64Value.makeIntegerValue(1114111)};
41 }
42
43 public Sequence<Int64Value> call(XPathContext context, Sequence[] arguments) throws XPathException {
44 StringValue val = (StringValue)arguments[0].head();
45 if (val == null) {
46 return EmptySequence.getInstance();
47 }
48 return SequenceTool.toLazySequence(val.iterateCharacters());
49 }
50
51 }
52