KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > kawa > xml > FollowingAxis


1 // Copyright (c) 2003 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.kawa.xml;
5 import gnu.lists.*;
6
7 /** Used to implement a following:: step in a path expression. */
8
9 public class FollowingAxis extends TreeScanner
10 {
11   public static FollowingAxis make (NodePredicate type)
12   {
13     FollowingAxis axis = new FollowingAxis();
14     axis.type = type;
15     return axis;
16   }
17
18   public void scan (AbstractSequence seq, int ipos, PositionConsumer out)
19   {
20     int limit = seq.endPos();
21     ipos = seq.nextPos(ipos);
22     if (ipos != 0 && type.isInstancePos(seq, ipos))
23       out.writePosition(seq, ipos);
24     for (;;)
25       {
26     ipos = seq.nextMatching(ipos, type, limit, true);
27     if (ipos == 0)
28       break;
29     out.writePosition(seq, ipos);
30       }
31   }
32 }
33
Popular Tags