View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.collections;
    18
    19  import java.util.Collection;
    20
    21  /***
    22   * Defines a collection that allows objects to be removed in some well-defined order.
    23   * <p>
    24   * The removal order can be based on insertion order (eg, a FIFO queue or a
    25   * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator
    26   * (eg, a priority queue) or on any other well-defined ordering.
    27   * <p>
    28   * Note that the removal order is not necessarily the same as the iteration
    29   * order.  A <code>Buffer</code> implementation may have equivalent removal
    30   * and iteration orders, but this is not required.
    31   * <p>
    32   * This interface does not specify any behavior for
    33   * {@link Object#equals(Object)} and {@link Object#hashCode} methods.  It
    34   * is therefore possible for a <code>Buffer</code> implementation to also
    35   * also implement {@link java.util.List}, {@link java.util.Set} or
    36   * {@link Bag}.
    37   * <p>
    38   * <strong>Note:</strong> this class should be bytecode-identical to the
    39   * version in commons collections. This is required to allow backwards
    40   * compability with both previous versions of BeanUtils and also allow
    41   * coexistance with both collections 2.1 and 3.0.
    42   *
    43   * @since Commons Collections 2.1
    44   * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $
    45   *
    46   * @author Avalon
    47   * @author Berin Loritsch
    48   * @author Paul Jack
    49   * @author Stephen Colebourne
    50   */
    51  public interface Buffer extends Collection {
    52
    53      /***
    54       * Gets and removes the next object from the buffer.
    55       *
    56       * @return the next object in the buffer, which is also removed
    57       * @throws BufferUnderflowException if the buffer is already empty
    58       */
    59      Object remove();
    60
    61      /***
    62       * Gets the next object from the buffer without removing it.
    63       *
    64       * @return the next object in the buffer, which is not removed
    65       * @throws BufferUnderflowException if the buffer is empty
    66       */
    67      Object get();
    68
    69  }