1. /*
  2. * $Header: /home/cvs/jakarta-commons/primitives/src/java/org/apache/commons/collections/primitives/ByteListIterator.java,v 1.1 2003/10/13 22:46:51 scolebourne Exp $
  3. * ====================================================================
  4. * The Apache Software License, Version 1.1
  5. *
  6. * Copyright (c) 2003 The Apache Software Foundation. All rights
  7. * reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in
  18. * the documentation and/or other materials provided with the
  19. * distribution.
  20. *
  21. * 3. The end-user documentation included with the redistribution, if
  22. * any, must include the following acknowledgement:
  23. * "This product includes software developed by the
  24. * Apache Software Foundation (http://www.apache.org/)."
  25. * Alternately, this acknowledgement may appear in the software itself,
  26. * if and wherever such third-party acknowledgements normally appear.
  27. *
  28. * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  29. * Foundation" must not be used to endorse or promote products derived
  30. * from this software without prior written permission. For written
  31. * permission, please contact apache@apache.org.
  32. *
  33. * 5. Products derived from this software may not be called "Apache"
  34. * nor may "Apache" appear in their names without prior written
  35. * permission of the Apache Software Foundation.
  36. *
  37. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  38. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  39. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  40. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  41. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  43. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  44. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  45. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  46. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  47. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  48. * SUCH DAMAGE.
  49. * ====================================================================
  50. *
  51. * This software consists of voluntary contributions made by many
  52. * individuals on behalf of the Apache Software Foundation. For more
  53. * information on the Apache Software Foundation, please see
  54. * <http://www.apache.org/>.
  55. *
  56. */
  57. package org.apache.commons.collections.primitives;
  58. /**
  59. * A bi-directional iterator over <code>byte</code> values.
  60. *
  61. * @see org.apache.commons.collections.primitives.adapters.ByteListIteratorListIterator
  62. * @see org.apache.commons.collections.primitives.adapters.ListIteratorByteListIterator
  63. *
  64. * @since Commons Collections 2.2
  65. * @version $Revision: 1.1 $ $Date: 2003/10/13 22:46:51 $
  66. *
  67. * @author Rodney Waldhoff
  68. */
  69. public interface ByteListIterator extends ByteIterator {
  70. /**
  71. * Inserts the specified element into my underlying collection
  72. * (optional operation).
  73. * The element is inserted immediately before the next element
  74. * that would have been returned by {@link #next}, if any,
  75. * and immediately after the next element that would have been
  76. * returned by {@link #previous}, if any.
  77. * <p/>
  78. * The new element is inserted immediately before the implied
  79. * cursor. A subsequent call to {@link #previous} will return
  80. * the added element, a subsequent call to {@link #next} will
  81. * be unaffected. This call increases by one the value that
  82. * would be returned by a call to {@link #nextIndex} or
  83. * {@link #previousIndex}.
  84. *
  85. * @param element the value to be inserted
  86. *
  87. * @throws UnsupportedOperationException when this operation is not
  88. * supported
  89. * @throws IllegalArgumentException if some aspect of the specified element
  90. * prevents it from being added
  91. */
  92. void add(byte element);
  93. /**
  94. * Returns <code>true</code> iff I have more elements
  95. * when traversed in the forward direction.
  96. * (In other words, returns <code>true</code> iff
  97. * a call to {@link #next} will return an element
  98. * rather than throwing an exception.
  99. *
  100. * @return <code>true</code> iff I have more elements when
  101. * traversed in the forward direction
  102. */
  103. boolean hasNext();
  104. /**
  105. * Returns <code>true</code> iff I have more elements
  106. * when traversed in the reverse direction.
  107. * (In other words, returns <code>true</code> iff
  108. * a call to {@link #previous} will return an element
  109. * rather than throwing an exception.
  110. *
  111. * @return <code>true</code> iff I have more elements when
  112. * traversed in the reverse direction
  113. */
  114. boolean hasPrevious();
  115. /**
  116. * Returns the next element in me when traversed in the
  117. * forward direction.
  118. *
  119. * @return the next element in me
  120. * @throws NoSuchElementException if there is no next element
  121. */
  122. byte next();
  123. /**
  124. * Returns the index of the element that would be returned
  125. * by a subsequent call to {@link #next}, or the number
  126. * of elements in my iteration if I have no next element.
  127. *
  128. * @return the index of the next element in me
  129. */
  130. int nextIndex();
  131. /**
  132. * Returns the next element in me when traversed in the
  133. * reverse direction.
  134. *
  135. * @return the previous element in me
  136. * @throws NoSuchElementException if there is no previous element
  137. */
  138. byte previous();
  139. /**
  140. * Returns the index of the element that would be returned
  141. * by a subsequent call to {@link #previous}, or
  142. * <code>-1</code> if I have no previous element.
  143. *
  144. * @return the index of the previous element in me
  145. */
  146. int previousIndex();
  147. /**
  148. * Removes from my underlying collection the last
  149. * element returned by {@link #next} or {@link #previous}
  150. * (optional operation).
  151. *
  152. * @throws UnsupportedOperationException if this operation is not
  153. * supported
  154. * @throws IllegalStateException if neither {@link #next} nor
  155. * {@link #previous} has yet been called, or
  156. * {@link #remove} or {@link #add} has already been called since
  157. * the last call to {@link #next} or {@link #previous}.
  158. */
  159. void remove();
  160. /**
  161. * Replaces in my underlying collection the last
  162. * element returned by {@link #next} or {@link #previous}
  163. * with the specified value (optional operation).
  164. *
  165. * @param element the value to replace the last returned element with
  166. * @throws UnsupportedOperationException if this operation is not
  167. * supported
  168. * @throws IllegalStateException if neither {@link #next} nor
  169. * {@link #previous} has yet been called, or
  170. * {@link #remove} or {@link #add} has already been called since
  171. * the last call to {@link #next} or {@link #previous}.
  172. * @throws IllegalArgumentException if some aspect of the specified element
  173. * prevents it from being added
  174. */
  175. void set(byte element);
  176. }