FollowingSiblingAxis.java 715 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2003 Per M.A. Bothner.
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.kawa.xml;
  4. import gnu.lists.*;
  5. /** Used to implement a following-sibling:: step in a path expression. */
  6. public class FollowingSiblingAxis extends TreeScanner
  7. {
  8. public static FollowingSiblingAxis make (NodePredicate type)
  9. {
  10. FollowingSiblingAxis axis = new FollowingSiblingAxis();
  11. axis.type = type;
  12. return axis;
  13. }
  14. public void scan (AbstractSequence seq, int ipos, PositionConsumer out)
  15. {
  16. int limit = seq.endPos();
  17. for (;;)
  18. {
  19. ipos = seq.nextMatching(ipos, type, limit, false);
  20. if (ipos == 0)
  21. break;
  22. out.writePosition(seq, ipos);
  23. }
  24. }
  25. }