Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2006-2007 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.batch.item.support;
An org.springframework.batch.item.ItemReader that pulls data from a java.util.Iterator or java.lang.Iterable using the constructors.

Author(s):
Juliusz Brzostek
Dave Syer
public class IteratorItemReader<T> implements ItemReader<T> {

Internal iterator
	private final Iterator<T> iterator;

Construct a new reader from this iterable (could be a collection), by extracting an instance of java.util.Iterator from it.

Parameters:
iterable in instance of java.lang.Iterable
See also:
java.lang.Iterable.iterator()
	public IteratorItemReader(Iterable<T> iterable) {
		Assert.notNull(iterable"Iterable argument cannot be null!");
		this. = iterable.iterator();
	}

Construct a new reader from this iterator directly.

Parameters:
iterator an instance of java.util.Iterator
	public IteratorItemReader(Iterator<T> iterator) {
		Assert.notNull(iterator"Iterator argument cannot be null!");
		this. = iterator;
	}

Implementation of org.springframework.batch.item.ItemReader.read() that just iterates over the iterator provided.
			return .next();
		else
			return null// end of data
	}
New to GrepCode? Check out our FAQ X