Package org.apache.commons.collections.primitives

Examples of org.apache.commons.collections.primitives.ByteList


    protected ByteList makeEmptyByteList() {
        return new ArrayByteList();
    }
   
    protected ByteList makeFullByteList() {
        ByteList list = makeEmptyByteList();
        byte[] elts = getFullElements();
        for(int i=0;i<elts.length;i++) {
            list.add((byte)elts[i]);
        }
        return list;
    }
View Full Code Here


        return ListByteList.wrap(getList().subList(fromIndex,toIndex));
    }

    public boolean equals(Object obj) {
        if(obj instanceof ByteList) {
            ByteList that = (ByteList)obj;
            if(this == that) {
                return true;
            } else if(this.size() != that.size()) {
                return false;           
            } else {
                ByteIterator thisiter = iterator();
                ByteIterator thatiter = that.iterator();
                while(thisiter.hasNext()) {
                    if(thisiter.next() != thatiter.next()) {
                        return false;
                    }
                }
View Full Code Here

    // ------------------------------------------------------------------------

    protected abstract ByteList makeUnmodifiableByteList();

    protected ByteList makeByteList() {
        ByteList list = new ArrayByteList();
        for(byte i=0;i<10;i++) {
            list.add(i);
        }
        return list;
    }
View Full Code Here

    public final void testNotModifiable() throws Exception {
        assertListNotModifiable(makeUnmodifiableByteList());
    }

    public final void testSublistNotModifiable() throws Exception {
        ByteList list = makeUnmodifiableByteList();
        assertListNotModifiable(list.subList(0,list.size()-2));
    }
View Full Code Here

        ByteList list = makeUnmodifiableByteList();
        assertListNotModifiable(list.subList(0,list.size()-2));
    }
   
    public final void testIteratorNotModifiable() throws Exception {
        ByteList list = makeUnmodifiableByteList();
        assertIteratorNotModifiable(list.iterator());
        assertIteratorNotModifiable(list.subList(0,list.size()-2).iterator());
    }
View Full Code Here

        assertIteratorNotModifiable(list.iterator());
        assertIteratorNotModifiable(list.subList(0,list.size()-2).iterator());
    }
   
    public final void testListIteratorNotModifiable() throws Exception {
        ByteList list = makeUnmodifiableByteList();
        assertListIteratorNotModifiable(list.listIterator());
        assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator());
        assertListIteratorNotModifiable(list.listIterator(1));
        assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator(1));
    }
View Full Code Here

    public void testWrapNull() {
        assertNull(ListByteList.wrap(null));
    }
   
    public void testWrapSerializable() {
        ByteList list = ListByteList.wrap(new ArrayList());
        assertNotNull(list);
        assertTrue(list instanceof Serializable);
    }
View Full Code Here

        assertNotNull(list);
        assertTrue(list instanceof Serializable);
    }
   
    public void testWrapNonSerializable() {
        ByteList list = ListByteList.wrap(new AbstractList() {
            public Object get(int i) { throw new IndexOutOfBoundsException(); }
            public int size() { return 0; }
        });
        assertNotNull(list);
        assertTrue(!(list instanceof Serializable));
View Full Code Here


    // ------------------------------------------------------------------------
   
    public void testReadNonEmpty() throws Exception {
        ByteList list = new ArrayByteList();
        for(int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
            list.add((byte)i);
        }
      
        InputStream in = new ByteIteratorInputStream(list.iterator());
        for(int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
            assertEquals(0xFF&i,in.read());
        }
        assertEquals(-1,in.read());
        assertEquals(-1,in.read());
View Full Code Here

        assertEquals(-1,in.read());
        assertEquals(-1,in.read());
    }

    public void testReadEmpty() throws Exception {
        ByteList list = new ArrayByteList();
        InputStream in = new ByteIteratorInputStream(list.iterator());
        assertEquals(-1,in.read());
        assertEquals(-1,in.read());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.primitives.ByteList

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.