View Javadoc
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.Node; 21 22 import com.icl.saxon.om.AxisEnumeration; 23 import com.icl.saxon.om.NodeInfo; 24 25 public class FollowingEnumeration implements AxisEnumeration { 26 27 private DescendantEnumeration descendants; 28 private Node currNode; 29 private Node nextNode; 30 31 public FollowingEnumeration( final AxisNode start ) { 32 33 this.currNode = start; 34 do { 35 this.currNode = this.currNode.getParentNode(); 36 if ( this.currNode == null ) { 37 return; 38 } 39 this.nextNode = this.currNode.getNextSibling(); 40 } while ( this.nextNode == null ); 41 42 this.getDescandants( (AxisNode)this.nextNode ); 43 } 44 45 public int getLastPosition() { 46 return 1; // not used 47 } 48 49 public boolean hasMoreElements() { 50 if ( nextNode != null ) { 51 return true; 52 } 53 54 if ( descendants == null ) { 55 return false; 56 } 57 58 if ( descendants.hasMoreElements() ) { 59 nextNode = (org.w3c.dom.Node)descendants.nextElement(); 60 return true; 61 } 62 63 if ( currNode == null ) { 64 return false; 65 } 66 67 nextNode = currNode.getFirstChild(); 68 if ( nextNode != null ) { 69 this.getDescandants( (AxisNode)nextNode ); 70 return true; 71 } 72 73 nextNode = currNode.getNextSibling(); 74 if ( nextNode != null ) { 75 this.getDescandants( (AxisNode)nextNode ); 76 return true; 77 } 78 79 do { 80 currNode = currNode.getParentNode(); 81 if ( currNode == null ) { 82 return false; 83 } 84 nextNode = currNode.getNextSibling(); 85 } while ( nextNode == null ); 86 87 this.getDescandants( (AxisNode)nextNode ); 88 return true; 89 } 90 91 public boolean isPeer() { 92 return false; 93 } 94 95 public boolean isReverseSorted() { 96 return true; 97 } 98 99 public boolean isSorted() { 100 return false; 101 } 102 103 public NodeInfo nextElement() { 104 if ( nextNode != null || hasMoreElements() ) { 105 currNode = nextNode; 106 nextNode = null; 107 return (NodeInfo)currNode; 108 } 109 return null; 110 } 111 112 protected final void getDescandants( final AxisNode node ) { 113 descendants = new DescendantEnumeration( node, false ); 114 } 115 } 116

This page was automatically generated by Maven