1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: FilteredStepIterator.java,v 1.9 2004/02/16 22:54:59 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.dom;
  20. import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
  21. /**
  22. * Extends a StepIterator by adding the ability to filter nodes. It
  23. * uses filters similar to those of a FilterIterator.
  24. * @author Jacek Ambroziak
  25. * @author Santiago Pericas-Geertsen
  26. * @author Morten Jorgensen
  27. */
  28. public final class FilteredStepIterator extends StepIterator {
  29. private Filter _filter;
  30. public FilteredStepIterator(DTMAxisIterator source,
  31. DTMAxisIterator iterator,
  32. Filter filter) {
  33. super(source, iterator);
  34. _filter = filter;
  35. }
  36. public int next() {
  37. int node;
  38. while ((node = super.next()) != END) {
  39. if (_filter.test(node)) {
  40. return returnNode(node);
  41. }
  42. }
  43. return node;
  44. }
  45. }