|
Commons Collections example source code file (BoundedBuffer.java)
The Commons Collections BoundedBuffer.java source code/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.collections.buffer;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.collections.BoundedCollection;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferOverflowException;
import org.apache.commons.collections.BufferUnderflowException;
import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
/**
* Decorates another <code>Buffer to ensure a fixed maximum size.
* <p>
* Note: This class should only be used if you need to add bounded
* behaviour to another buffer. If you just want a bounded buffer then
* you should use {@link BoundedFifoBuffer} or {@link CircularFifoBuffer}.
* <p>
* The decoration methods allow you to specify a timeout value.
* This alters the behaviour of the add methods when the buffer is full.
* Normally, when the buffer is full, the add method will throw an exception.
* With a timeout, the add methods will wait for up to the timeout period
* to try and add the elements.
*
* @author James Carman
* @author Stephen Colebourne
* @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
* @since Commons Collections 3.2
*/
public class BoundedBuffer extends SynchronizedBuffer implements BoundedCollection {
/** The serialization version. */
private static final long serialVersionUID = 1536432911093974264L;
/** The maximum size. */
private final int maximumSize;
/** The timeout milliseconds. */
private final long timeout;
/**
* Factory method to create a bounded buffer.
* <p>
* When the buffer is full, it will immediately throw a
* <code>BufferOverflowException on calling
Other Commons Collections examples (source code examples)Here is a short list of links related to this Commons Collections BoundedBuffer.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.