1 /*
2 * Copyright (C) 2002 Carsten Krebs (Team-Konzept GmbH & Co.KG)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 package com.teamkonzept.dom4jb.saxon;
19
20 import org.w3c.dom.NodeList;
21
22 import com.icl.saxon.om.AxisEnumeration;
23 import com.icl.saxon.om.NodeInfo;
24
25 public class DescendantEnumeration implements AxisEnumeration {
26 private NodeList axis;
27 private int idx;
28
29 protected DescendantEnumeration() { /* NOP */ }
30
31 public DescendantEnumeration( final AxisNode start,
32 final boolean includeSelf ) {
33 init( start, includeSelf );
34 }
35
36 private void init( final AxisNode start, final boolean includeSelf ) {
37 synchronized( start ) {
38 axis = start.getAxis();
39 idx = start.getPosition();
40 }
41 if ( axis == null ) {
42 axis =
43 new DescendantAxis(
44 new DescendantAxisIterator(
45 (com.teamkonzept.dom4jb.dom.Node) start));
46 idx = 0;
47 }
48 if ( !includeSelf ) {
49 idx++;
50 }
51 }
52
53 public int getLastPosition() {
54 return 1; // not used
55 }
56
57 public boolean hasMoreElements() {
58 return axis.item(idx) != null;
59 }
60
61 public boolean isPeer() {
62 return false;
63 }
64
65 public boolean isReverseSorted() {
66 return false;
67 }
68
69 public boolean isSorted() {
70 return true;
71 }
72
73 public NodeInfo nextElement() {
74 return (NodeInfo)axis.item( idx++ );
75 }
76
77 // debug
78 public int size() {
79 return axis.getLength();
80 }
81 }
This page was automatically generated by Maven