Creates an iterator which will traverse through the reader a line at a time.

@param self a Reader object
@return an Iterator for the Reader
@see java.io.BufferedReader#readLine()
@since 1.5.0
14078
public static Iterator<String> iterator(Reader self) {
        final BufferedReader bufferedReader;
        if (self instanceof BufferedReader)
            bufferedReader = (BufferedReader) self;
        else
            bufferedReader = new BufferedReader(self);
        return new Iterator<String>() {
            String nextVal /* = null */;
            boolean nextMustRead = true;
            boolean hasNext = true;

            public boolean hasNext() {
                if (nextMustRead && hasNext) {
                    try {
                        nextVal = readNext();
                        nextMustRead = false;
                    } catch (IOException e) {
                        hasNext = false;
                    }
                }
                return hasNext;
            }

            public String next() {
                String retval = null;
                if (nextMustRead) {
                    try {
                        retval = readNext();
                    } catch (IOException e) {
                        hasNext = false;
                    }
                } else
                    retval = nextVal;
                nextMustRead = true;
                return retval;
            }

            private String readNext() throws IOException {
                String nv = bufferedReader.readLine();
                if (nv == null)
                    hasNext = false;
                return nv;
            }

            public void remove() {
                throw new UnsupportedOperationException("Cannot remove() from a Reader Iterator");
            }
        };
    }
160262
public Iterator<BplusTree.TreeEntry<K, V>> iterator() {
		return new TreeIterator<BplusTree.TreeEntry<K, V>>(this);
	}
412886
public Iterator<A> iterator() {
        return new Iterator<A>() {
            List<A> elems = ListBuffer.this.elems;
            public boolean hasNext() {
                return !elems.isEmpty();
            }
            public A next() {
                if (elems.isEmpty())
                    throw new NoSuchElementException();
                A elem = elems.head;
                elems = elems.tail;
                return elem;
            }
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
304110
public static <T> Iterator<T> each(Iterator<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) {
        while (self.hasNext()) {
            Object arg = self.next();
            closure.call(arg);
        }
        return self;
    }
225273
public static List<String> toList(CharSequence self) {
        String s = self.toString();
        int size = s.length();
        List<String> answer = new ArrayList<String>(size);
        for (int i = 0; i < size; i++) {
            answer.add(s.substring(i, i + 1));
        }
        return answer;
    }
1104613
public static Stream<Integer> stream(int[] self) {
        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
    }
659041
public String readLine() throws IOException
  {
    CharBuffer cb = _cb;

    if (cb == null) {
      cb = _cb = new CharBuffer();
    }
    else {
      cb.length(0);
    }

    String result;

    if (readLine(cb, true)) {
      result = cb.toString();
      cb.length(0);
    }
    else if (cb.length() == 0)
      result = null;
    else {
      result = cb.toString();
      cb.length(0);
    }

    return result;
  }
703500
public static String denormalize(final CharSequence self) {
        final String s = self.toString();
        // Don't do this in static initializer because we may never be needed.
        // TODO: Put this lineSeparator property somewhere everyone can use it.
        if (lineSeparator == null) {
            final StringWriter sw = new StringWriter(2);
            try {
                // We use BufferedWriter rather than System.getProperty because
                // it has the security manager rigamarole to deal with the possible exception.
                final BufferedWriter bw = new BufferedWriter(sw);
                bw.newLine();
                bw.flush();
                lineSeparator = sw.toString();
            } catch (IOException ioe) {
                // This shouldn't happen, but this is the same default used by
                // BufferedWriter on a security exception.
                lineSeparator = "\n";
            }
        }

        final int len = s.length();

        if (len < 1) {
            return s;
        }

        final StringBuilder sb = new StringBuilder((110 * len) / 100);

        int i = 0;

        while (i < len) {
            final char ch = s.charAt(i++);

            switch (ch) {
                case '\r':
                    sb.append(lineSeparator);

                    // Eat the following LF if any.
                    if ((i < len) && (s.charAt(i) == '\n')) {
                        ++i;
                    }

                    break;

                case '\n':
                    sb.append(lineSeparator);
                    break;

                default:
                    sb.append(ch);
                    break;
            }
         }

        return sb.toString();
    }
1103164
public static <T> Iterator<T> tail(Iterator<T> self) {
        if (!self.hasNext()) {
            throw new NoSuchElementException("Cannot access tail() for an empty Iterator");
        }
        self.next();
        return self;
    }
856229
public Iterator iterator()
        {
        Query readAll = m_em.createQuery(
                createReadAllQuery(m_entityClass.getSimpleName()));
        return new JpaIterator(readAll, m_batchSize);
        }
691077
public static <T> T max(Iterator<T> self) {
        return max((Iterable<T>)toList(self));
    }
745131
public Iterator<E> iterator() {
		
		final Iterator<E> it = new Iterator<E>() {

			@Override
			public boolean hasNext() {
				
				return (index < size()); 
			}

			@Override
			public E next() {
				final E elem = get(index++);
				
				if (index >= size() && nextLink != null) {
					getNextPage();
				}
				
				return elem;
			}

			@Override
			public void remove() {
				// TODO Auto-generated method stub
			}
		};
		return it;

		// return super.iterator();
	}
329736
public static int size(Iterator self) {
        int count = 0;
        while (self.hasNext()) {
            self.next();
            count++;
        }
        return count;
    }
1167787
public Reader getReader() throws IOException {
        if (this.charset != null) {
            return new InputStreamReader(this.resource.getInputStream(), this.charset);
        } else if (this.encoding != null) {
            return new InputStreamReader(this.resource.getInputStream(), this.encoding);
        } else {
            return new InputStreamReader(this.resource.getInputStream());
        }
    }
1011771
public static Iterator iterator(final ListModel self) {
        return new Iterator() {
            private int index = 0;

            public boolean hasNext() {
                return index < self.getSize();
            }

            public Object next() {
                return self.getElementAt(index++);
            }

            public void remove() {
                throw new UnsupportedOperationException("LisModel is immutable.");
            }
        };
    }
1136626
public static List<String> readLines(InputStream input) throws IOException {
        final InputStreamReader reader = new InputStreamReader(input);
        return readLines(reader);
    }
888320
public static Iterator<Component> iterator(final JTabbedPane self) {
        return new Iterator<Component>() {
            private int index = 0;

            public boolean hasNext() {
                return index > -1 && index < self.getTabCount();
            }

            public Component next() {
                return self.getComponentAt(index++);
            }

            public void remove() {
                if (hasNext()) self.removeTabAt(index--);
            }
        };
    }