1 package net.sf.saxon.value; 2 3 import net.sf.saxon.om.SequenceIterator; 4 import net.sf.saxon.om.Item; 5 import net.sf.saxon.om.NamePool; 6 import net.sf.saxon.expr.XPathContext; 7 import net.sf.saxon.expr.RangeExpression; 8 import net.sf.saxon.expr.StaticProperty; 9 import net.sf.saxon.expr.ExpressionTool; 10 import net.sf.saxon.trans.XPathException; 11 import net.sf.saxon.type.ItemType; 12 import net.sf.saxon.type.Type; 13 14 import java.io.PrintStream ; 15 16 20 21 public class IntegerRange extends Value { 22 23 public long start; 24 public long end; 25 26 public IntegerRange(long start, long end) { 27 this.start = start; 28 this.end = end; 29 } 30 31 public long getStart() { 32 return start; 33 } 34 35 public long getEnd() { 36 return end; 37 } 38 39 44 45 public int getImplementationMethod() { 46 return ITERATE_METHOD; 47 } 48 49 63 64 public SequenceIterator iterate(XPathContext context) throws XPathException { 65 return new RangeExpression.RangeIterator(start, end); 66 } 67 68 73 74 public ItemType getItemType() { 75 return Type.INTEGER_TYPE; 76 } 77 78 81 82 public int getCardinality() { 83 return StaticProperty.ALLOWS_MANY; 84 } 85 86 91 92 public Item itemAt(int n) throws XPathException { 93 if (n < 0 || n > (end-start)) { 94 return null; 95 } 96 return new IntegerValue(start + n); 97 } 98 99 102 103 public int getLength() throws XPathException { 104 return (int)(end - start + 1); 105 } 106 107 110 111 public void display(int level, NamePool pool, PrintStream out) { 112 System.err.println(ExpressionTool.indent(level) + start + " to " + end); 113 } 114 } 115 116 | Popular Tags |