KickJava   Java API By Example, From Geeks To Geeks.

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


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 an attribute:: step in a path expression. */
8
9 public class AttributeAxis extends TreeScanner
10 {
11   public static AttributeAxis make (NodePredicate type)
12   {
13     AttributeAxis axis = new AttributeAxis();
14     axis.type = type;
15     return axis;
16   }
17
18   public void scan (AbstractSequence seq, int ipos, PositionConsumer out)
19   {
20     ipos = seq.firstAttributePos(ipos);
21     while (ipos != 0)
22       {
23     if (type.isInstancePos(seq, ipos))
24       out.writePosition(seq, ipos);
25         else if (seq.getNextKind(ipos) != Sequence.ATTRIBUTE_VALUE)
26           break;
27     ipos = seq.nextPos(ipos);
28       }
29   }
30 }
31
Popular Tags