Debian Codegraph @

net/sf/saxon/om/EmptyAtomicSequence.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.om;
9
10 import net.sf.saxon.tree.iter.AtomicIterator;
11 import net.sf.saxon.tree.iter.EmptyIterator;
12 import net.sf.saxon.value.AtomicValue;
13
14 import java.util.Collections;
15 import java.util.Iterator;
16
17 /**
18 * An implementation of AtomicSequence that contains no items.
19 */
20
21 public enum EmptyAtomicSequence implements AtomicSequence {
22
23 INSTANCE;
24
25 public static EmptyAtomicSequence getInstance() {
26 return INSTANCE;
27 }
28
29 public AtomicValue head() {
30 return null;
31 }
32
33 public AtomicIterator iterate() {
34 return EmptyIterator.OfAtomic.THE_INSTANCE;
35 }
36
37 public AtomicValue itemAt(int n) {
38 return null;
39 }
40
41 public int getLength() {
42 return 0;
43 }
44
45 /**
46 * Get the canonical lexical representation as defined in XML Schema. This is not always the same
47 * as the result of casting to a string according to the XPath rules.
48 *
49 * @return the canonical lexical representation if defined in XML Schema; otherwise, the result
50 * of casting to string according to the XPath 2.0 rules
51 */
52 public CharSequence getCanonicalLexicalRepresentation() {
53 return "";
54 }
55
56 /**
57 * Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
58 * The default implementation is written to compare sequences of atomic values.
59 * This method is overridden for AtomicValue and its subclasses.
60 * <p>In the case of data types that are partially ordered, the returned Comparable extends the standard
61 * semantics of the compareTo() method by returning the value {@link net.sf.saxon.om.SequenceTool#INDETERMINATE_ORDERING} when there
62 * is no defined order relationship between two given values.</p>
63 *
64 * @return a Comparable that follows XML Schema comparison rules
65 */
66 public Comparable getSchemaComparable() {
67 return null;
68 }
69
70 public CharSequence getStringValueCS() {
71 return "";
72 }
73
74 public String getStringValue() {
75 return "";
76 }
77
78 /**
79 * Get a subsequence of the value
80 *
81 * @param start the index of the first item to be included in the result, counting from zero.
82 * A negative value is taken as zero. If the value is beyond the end of the sequence, an empty
83 * sequence is returned
84 * @param length the number of items to be included in the result. Specify Integer.MAX_VALUE to
85 * get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence
86 * is returned. If the value goes off the end of the sequence, the result returns items up to the end
87 * of the sequence
88 * @return the required subsequence. If min is
89 */
90 public EmptyAtomicSequence subsequence(int start, int length) {
91 return this;
92 }
93
94 public boolean effectiveBooleanValue() {
95 return false;
96 }
97
98 /**
99 * Reduce the sequence to its simplest form. If the value is an empty sequence, the result will be
100 * EmptySequence.getInstance(). If the value is a single atomic value, the result will be an instance
101 * of AtomicValue. If the value is a single item of any other kind, the result will be an instance
102 * of SingletonItem. Otherwise, the result will typically be unchanged.
103 *
104 * @return the simplified sequence
105 */
106 public EmptyAtomicSequence reduce() {
107 return this;
108 }
109
110 /**
111 * Return a Java iterator over the atomic sequence.
112 * @return an Iterator.
113 */
114
115 public Iterator<AtomicValue> iterator() {
116 return Collections.<AtomicValue>emptyList().iterator();
117 }
118 }
119