1 package org.jruby.util.string; 2 3 12 13 public class UcharIterator implements java.util.Iterator , java.io.Serializable { 14 private static final long serialVersionUID = -2821982911687539515L; 15 private Ustr u; 16 private int next; 17 18 24 public UcharIterator(byte[] s, int offset) { 25 u = new Ustr(s, offset); 26 u.prepareNext(); 27 next = u.nextChar(); 28 } 29 30 35 public boolean hasNext() { 36 return (next != 0); 37 } 38 39 47 public Object next() { 48 if (next == 0) 49 throw new java.util.NoSuchElementException ("Ran off end of array"); 50 Integer i = new Integer (next); 51 next = u.nextChar(); 52 return i; 53 } 54 55 62 public int nextChar() { 63 int i = next; 64 if (i != 0) 65 next = u.nextChar(); 66 return i; 67 } 68 69 74 public void remove() { 75 throw new UnsupportedOperationException ("UcharIterator doesn't remove"); 76 } 77 78 } 79 | Popular Tags |