| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public boolean test(final QueryContext qc, final InputInfo ii, final long pos) |
| 111 | throws QueryException { |
| 112 | // single item |
| 113 | if(seqType().zeroOrOne()) return item(qc, info).test(qc, info, pos); |
| 114 | // empty sequence? |
| 115 | final Iter iter = iter(qc); |
| 116 | final Item item1 = iter.next(); |
| 117 | if(item1 == null) return false; |
| 118 | // sequence starting with node? |
| 119 | if(item1 instanceof GNode) return true; |
| 120 | // single item? |
| 121 | Item item2 = iter.next(); |
| 122 | if(item2 == null) return item1.test(qc, info, pos); |
| 123 | // positional sequence? |
| 124 | if(pos == 0 || !(item1 instanceof ANum)) throw testError(item1.append(item2, qc), false, info); |
| 125 | if(item1.test(qc, info, pos)) return true; |
| 126 | do { |
| 127 | if(!(item2 instanceof ANum)) throw testError(item1.append(item2, qc), true, info); |
| 128 | if(item2.test(qc, info, pos)) return true; |
| 129 | } while((item2 = iter.next()) != null); |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public final SeqType seqType() { |