1 17 package org.apache.commons.collections.primitives; 18 19 import org.apache.commons.collections.primitives.decorators.UnmodifiableByteIterator; 20 import org.apache.commons.collections.primitives.decorators.UnmodifiableByteList; 21 import org.apache.commons.collections.primitives.decorators.UnmodifiableByteListIterator; 22 23 34 public final class ByteCollections { 35 36 41 public static ByteList singletonByteList(byte value) { 42 ByteList list = new ArrayByteList(1); 44 list.add(value); 45 return UnmodifiableByteList.wrap(list); 46 } 47 48 53 public static ByteIterator singletonByteIterator(byte value) { 54 return singletonByteList(value).iterator(); 55 } 56 57 62 public static ByteListIterator singletonByteListIterator(byte value) { 63 return singletonByteList(value).listIterator(); 64 } 65 66 73 public static ByteList unmodifiableByteList(ByteList list) throws NullPointerException { 74 if(null == list) { 75 throw new NullPointerException (); 76 } 77 return UnmodifiableByteList.wrap(list); 78 } 79 80 87 public static ByteIterator unmodifiableByteIterator(ByteIterator iter) { 88 if(null == iter) { 89 throw new NullPointerException (); 90 } 91 return UnmodifiableByteIterator.wrap(iter); 92 } 93 94 101 public static ByteListIterator unmodifiableByteListIterator(ByteListIterator iter) { 102 if(null == iter) { 103 throw new NullPointerException (); 104 } 105 return UnmodifiableByteListIterator.wrap(iter); 106 } 107 108 113 public static ByteList getEmptyByteList() { 114 return EMPTY_BYTE_LIST; 115 } 116 117 122 public static ByteIterator getEmptyByteIterator() { 123 return EMPTY_BYTE_ITERATOR; 124 } 125 126 131 public static ByteListIterator getEmptyByteListIterator() { 132 return EMPTY_BYTE_LIST_ITERATOR; 133 } 134 135 139 public static final ByteList EMPTY_BYTE_LIST = unmodifiableByteList(new ArrayByteList(0)); 140 141 145 public static final ByteIterator EMPTY_BYTE_ITERATOR = unmodifiableByteIterator(EMPTY_BYTE_LIST.iterator()); 146 147 151 public static final ByteListIterator EMPTY_BYTE_LIST_ITERATOR = unmodifiableByteListIterator(EMPTY_BYTE_LIST.listIterator()); 152 } 153 | Popular Tags |