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: ClonedNodeListIterator.java,v 1.2 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. import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
  22. /**
  23. * A ClonedNodeListIterator is returned by the cloneIterator() method
  24. * of a CachedNodeListIterator. Its next() method retrieves the nodes from
  25. * the cache of the CachedNodeListIterator.
  26. */
  27. public final class ClonedNodeListIterator extends DTMAxisIteratorBase {
  28. /**
  29. * Source for this iterator.
  30. */
  31. private CachedNodeListIterator _source;
  32. private int _index = 0;
  33. public ClonedNodeListIterator(CachedNodeListIterator source) {
  34. _source = source;
  35. }
  36. public void setRestartable(boolean isRestartable) {
  37. //_isRestartable = isRestartable;
  38. //_source.setRestartable(isRestartable);
  39. }
  40. public DTMAxisIterator setStartNode(int node) {
  41. return this;
  42. }
  43. public int next() {
  44. return _source.getNode(_index++);
  45. }
  46. public int getPosition() {
  47. return _index == 0 ? 1 : _index;
  48. }
  49. public int getNodeByPosition(int pos) {
  50. return _source.getNode(pos);
  51. }
  52. public DTMAxisIterator cloneIterator() {
  53. return _source.cloneIterator();
  54. }
  55. public DTMAxisIterator reset() {
  56. _index = 0;
  57. return this;
  58. }
  59. public void setMark() {
  60. _source.setMark();
  61. }
  62. public void gotoMark() {
  63. _source.gotoMark();
  64. }
  65. }