Package org.apache.commons.collections15

Examples of org.apache.commons.collections15.BufferUnderflowException


        return false;
    }

    public void testBufferRemove() {
        resetEmpty();
        Buffer buffer = (Buffer) collection;
        try {
            buffer.remove();
            fail();
        } catch (UnsupportedOperationException ex) {
        }
    }
View Full Code Here


    public void testCircularFifoBufferCircular() {
        List list = new ArrayList();
        list.add("A");
        list.add("B");
        list.add("C");
        Buffer buf = new CircularFifoBuffer(list);

        assertEquals(true, buf.contains("A"));
        assertEquals(true, buf.contains("B"));
        assertEquals(true, buf.contains("C"));

        buf.add("D");

        assertEquals(false, buf.contains("A"));
        assertEquals(true, buf.contains("B"));
        assertEquals(true, buf.contains("C"));
        assertEquals(true, buf.contains("D"));

        assertEquals("B", buf.get());
        assertEquals("B", buf.remove());
        assertEquals("C", buf.remove());
        assertEquals("D", buf.remove());
    }
View Full Code Here

    }

    //----------------------------------------------------------------------- 
    public void testBufferEmpty() {
        resetEmpty();
        Buffer buffer = (Buffer) collection;

        assertEquals(0, buffer.size());
        assertEquals(true, buffer.isEmpty());
        try {
            buffer.get();
            fail();
        } catch (BufferUnderflowException ex) {
        }

        try {
            buffer.remove();
            fail();
        } catch (BufferUnderflowException ex) {
        }
    }
View Full Code Here

    public Collection makeCollection() {
        return SynchronizedBuffer.decorate(new UnboundedFifoBuffer());
    }

    public Collection makeFullCollection() {
        Buffer buffer = new UnboundedFifoBuffer();
        buffer.addAll(Arrays.asList(getFullElements()));
        return SynchronizedBuffer.decorate(buffer);
    }
View Full Code Here

    protected static class MyBuffer extends LinkedList implements Buffer {

        public Object get() {
            if (isEmpty())
                throw new BufferUnderflowException();
            return get(0);
        }
View Full Code Here

            return get(0);
        }

        public Object remove() {
            if (isEmpty())
                throw new BufferUnderflowException();
            return remove(0);
        }
View Full Code Here

     * @return the next element
     * @throws BufferUnderflowException if the buffer is empty
     */
    public E get() {
        if (isEmpty()) {
            throw new BufferUnderflowException();
        } else {
            return elements[1];
        }
    }
View Full Code Here

        synchronized (lock) {
            while (collection.isEmpty()) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    throw new BufferUnderflowException();
                }
            }
            return getBuffer().get();
        }
    }
View Full Code Here

        synchronized (lock) {
            while (collection.isEmpty()) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    throw new BufferUnderflowException();
                }
            }
            return getBuffer().remove();
        }
    }
View Full Code Here

     * @return the least recently inserted element
     * @throws BufferUnderflowException if the buffer is empty
     */
    public E get() {
        if (isEmpty()) {
            throw new BufferUnderflowException("The buffer is already empty");
        }

        return elements[start];
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections15.BufferUnderflowException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.