1. /*
  2. * Copyright 1999-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. package org.apache.commons.collections.iterators;
  17. import java.util.ListIterator;
  18. /**
  19. * A proxy {@link ListIterator ListIterator} which delegates its
  20. * methods to a proxy instance.
  21. *
  22. * @deprecated Use AbstractListIteratorDecorator. Will be removed in v4.0
  23. * @since Commons Collections 2.0
  24. * @version $Revision: 1.9 $ $Date: 2004/02/18 00:59:50 $
  25. *
  26. * @author Rodney Waldhoff
  27. */
  28. public class ProxyListIterator implements ListIterator {
  29. /** Holds value of property "iterator". */
  30. private ListIterator iterator;
  31. // Constructors
  32. //-------------------------------------------------------------------------
  33. /**
  34. * Constructs a new <code>ProxyListIterator</code> that will not
  35. * function until {@link #setListIterator(ListIterator) setListIterator}
  36. * is invoked.
  37. */
  38. public ProxyListIterator() {
  39. super();
  40. }
  41. /**
  42. * Constructs a new <code>ProxyListIterator</code> that will use the
  43. * given list iterator.
  44. *
  45. * @param iterator the list iterator to use
  46. */
  47. public ProxyListIterator(ListIterator iterator) {
  48. super();
  49. this.iterator = iterator;
  50. }
  51. // ListIterator interface
  52. //-------------------------------------------------------------------------
  53. /**
  54. * Invokes the underlying {@link ListIterator#add(Object)} method.
  55. *
  56. * @throws NullPointerException if the underlying iterator is null
  57. */
  58. public void add(Object o) {
  59. getListIterator().add(o);
  60. }
  61. /**
  62. * Invokes the underlying {@link ListIterator#hasNext()} method.
  63. *
  64. * @throws NullPointerException if the underlying iterator is null
  65. */
  66. public boolean hasNext() {
  67. return getListIterator().hasNext();
  68. }
  69. /**
  70. * Invokes the underlying {@link ListIterator#hasPrevious()} method.
  71. *
  72. * @throws NullPointerException if the underlying iterator is null
  73. */
  74. public boolean hasPrevious() {
  75. return getListIterator().hasPrevious();
  76. }
  77. /**
  78. * Invokes the underlying {@link ListIterator#next()} method.
  79. *
  80. * @throws NullPointerException if the underlying iterator is null
  81. */
  82. public Object next() {
  83. return getListIterator().next();
  84. }
  85. /**
  86. * Invokes the underlying {@link ListIterator#nextIndex()} method.
  87. *
  88. * @throws NullPointerException if the underlying iterator is null
  89. */
  90. public int nextIndex() {
  91. return getListIterator().nextIndex();
  92. }
  93. /**
  94. * Invokes the underlying {@link ListIterator#previous()} method.
  95. *
  96. * @throws NullPointerException if the underlying iterator is null
  97. */
  98. public Object previous() {
  99. return getListIterator().previous();
  100. }
  101. /**
  102. * Invokes the underlying {@link ListIterator#previousIndex()} method.
  103. *
  104. * @throws NullPointerException if the underlying iterator is null
  105. */
  106. public int previousIndex() {
  107. return getListIterator().previousIndex();
  108. }
  109. /**
  110. * Invokes the underlying {@link ListIterator#remove()} method.
  111. *
  112. * @throws NullPointerException if the underlying iterator is null
  113. */
  114. public void remove() {
  115. getListIterator().remove();
  116. }
  117. /**
  118. * Invokes the underlying {@link ListIterator#set(Object)} method.
  119. *
  120. * @throws NullPointerException if the underlying iterator is null
  121. */
  122. public void set(Object o) {
  123. getListIterator().set(o);
  124. }
  125. // Properties
  126. //-------------------------------------------------------------------------
  127. /**
  128. * Getter for property iterator.
  129. * @return Value of property iterator.
  130. */
  131. public ListIterator getListIterator() {
  132. return iterator;
  133. }
  134. /**
  135. * Setter for property iterator.
  136. * @param iterator New value of property iterator.
  137. */
  138. public void setListIterator(ListIterator iterator) {
  139. this.iterator = iterator;
  140. }
  141. }