1 17 package org.apache.commons.collections.primitives; 18 19 import org.apache.commons.collections.primitives.decorators.UnmodifiableCharIterator; 20 import org.apache.commons.collections.primitives.decorators.UnmodifiableCharList; 21 import org.apache.commons.collections.primitives.decorators.UnmodifiableCharListIterator; 22 23 34 public final class CharCollections { 35 36 41 public static CharList singletonCharList(char value) { 42 CharList list = new ArrayCharList(1); 44 list.add(value); 45 return UnmodifiableCharList.wrap(list); 46 } 47 48 53 public static CharIterator singletonCharIterator(char value) { 54 return singletonCharList(value).iterator(); 55 } 56 57 62 public static CharListIterator singletonCharListIterator(char value) { 63 return singletonCharList(value).listIterator(); 64 } 65 66 73 public static CharList unmodifiableCharList(CharList list) throws NullPointerException { 74 if(null == list) { 75 throw new NullPointerException (); 76 } 77 return UnmodifiableCharList.wrap(list); 78 } 79 80 87 public static CharIterator unmodifiableCharIterator(CharIterator iter) { 88 if(null == iter) { 89 throw new NullPointerException (); 90 } 91 return UnmodifiableCharIterator.wrap(iter); 92 } 93 94 101 public static CharListIterator unmodifiableCharListIterator(CharListIterator iter) { 102 if(null == iter) { 103 throw new NullPointerException (); 104 } 105 return UnmodifiableCharListIterator.wrap(iter); 106 } 107 108 113 public static CharList getEmptyCharList() { 114 return EMPTY_CHAR_LIST; 115 } 116 117 122 public static CharIterator getEmptyCharIterator() { 123 return EMPTY_CHAR_ITERATOR; 124 } 125 126 131 public static CharListIterator getEmptyCharListIterator() { 132 return EMPTY_CHAR_LIST_ITERATOR; 133 } 134 135 139 public static final CharList EMPTY_CHAR_LIST = unmodifiableCharList(new ArrayCharList(0)); 140 141 145 public static final CharIterator EMPTY_CHAR_ITERATOR = unmodifiableCharIterator(EMPTY_CHAR_LIST.iterator()); 146 147 151 public static final CharListIterator EMPTY_CHAR_LIST_ITERATOR = unmodifiableCharListIterator(EMPTY_CHAR_LIST.listIterator()); 152 } 153 | Popular Tags |