1 package net.sf.saxon.value; 2 import net.sf.saxon.expr.ExpressionTool; 3 import net.sf.saxon.expr.StaticProperty; 4 import net.sf.saxon.expr.XPathContext; 5 import net.sf.saxon.om.EmptyIterator; 6 import net.sf.saxon.om.NamePool; 7 import net.sf.saxon.om.SequenceIterator; 8 import net.sf.saxon.pattern.NoNodeTest; 9 import net.sf.saxon.type.ItemType; 10 11 import java.io.PrintStream ; 12 13 16 17 18 public final class EmptySequence extends Value { 19 20 private static EmptySequence THE_INSTANCE = new EmptySequence(); 22 23 24 27 28 private EmptySequence() {} 29 30 33 34 public static EmptySequence getInstance() { 35 return THE_INSTANCE; 36 } 37 38 42 43 public int getImplementationMethod() { 44 return EVALUATE_METHOD; 45 } 46 47 50 51 public SequenceIterator iterate(XPathContext context) { 52 return EmptyIterator.getInstance(); 53 } 54 55 58 59 public ItemType getItemType() { 60 return NoNodeTest.getInstance(); 61 } 62 63 66 67 public int getCardinality() { 68 return StaticProperty.EMPTY; 69 } 70 71 76 77 public int getSpecialProperties() { 78 return StaticProperty.ORDERED_NODESET | 79 StaticProperty.SINGLE_DOCUMENT_NODESET | 80 StaticProperty.CONTEXT_DOCUMENT_NODESET; 81 } 82 83 87 88 public final int getLength() { 89 return 0; 90 } 91 95 96 public boolean equals(Object other) { 97 if (!(other instanceof EmptySequence)) { 98 throw new ClassCastException ("Cannot compare " + other.getClass() + " to empty sequence"); 99 } 100 return true; 101 } 102 103 public int hashCode() { 104 return 42; 105 } 106 107 111 112 116 119 120 public boolean effectiveBooleanValue(XPathContext context) { 121 return false; 122 } 123 124 127 128 public void display(int level, NamePool pool, PrintStream out) { 129 out.println(ExpressionTool.indent(level) + "()" ); 130 } 131 132 } 133 134 | Popular Tags |