1. /*
  2. * Copyright 2003-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 org.apache.commons.collections.OrderedMapIterator;
  18. /**
  19. * Provides basic behaviour for decorating an ordered map iterator with extra functionality.
  20. * <p>
  21. * All methods are forwarded to the decorated map iterator.
  22. *
  23. * @since Commons Collections 3.0
  24. * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:50 $
  25. *
  26. * @author Stephen Colebourne
  27. */
  28. public class AbstractOrderedMapIteratorDecorator implements OrderedMapIterator {
  29. /** The iterator being decorated */
  30. protected final OrderedMapIterator iterator;
  31. //-----------------------------------------------------------------------
  32. /**
  33. * Constructor that decorates the specified iterator.
  34. *
  35. * @param iterator the iterator to decorate, must not be null
  36. * @throws IllegalArgumentException if the collection is null
  37. */
  38. public AbstractOrderedMapIteratorDecorator(OrderedMapIterator iterator) {
  39. super();
  40. if (iterator == null) {
  41. throw new IllegalArgumentException("OrderedMapIterator must not be null");
  42. }
  43. this.iterator = iterator;
  44. }
  45. /**
  46. * Gets the iterator being decorated.
  47. *
  48. * @return the decorated iterator
  49. */
  50. protected OrderedMapIterator getOrderedMapIterator() {
  51. return iterator;
  52. }
  53. //-----------------------------------------------------------------------
  54. public boolean hasNext() {
  55. return iterator.hasNext();
  56. }
  57. public Object next() {
  58. return iterator.next();
  59. }
  60. public boolean hasPrevious() {
  61. return iterator.hasPrevious();
  62. }
  63. public Object previous() {
  64. return iterator.previous();
  65. }
  66. public void remove() {
  67. iterator.remove();
  68. }
  69. public Object getKey() {
  70. return iterator.getKey();
  71. }
  72. public Object getValue() {
  73. return iterator.getValue();
  74. }
  75. public Object setValue(Object obj) {
  76. return iterator.setValue(obj);
  77. }
  78. }