package org.eclipse.scanning.points;

import java.util.Iterator;

import org.eclipse.scanning.api.points.IPosition;
import org.eclipse.scanning.api.points.models.ArrayModel;
import org.eclipse.scanning.points.ScanPointGeneratorFactory.JythonObjectFactory;

class ArrayIterator extends AbstractScanPointIterator {

	private ArrayModel model;
	int index = 0;

	public ArrayIterator(ArrayGenerator gen) {
		this.model= gen.getModel();
		
        JythonObjectFactory arrayGeneratorFactory = ScanPointGeneratorFactory.JArrayGeneratorFactory();

        String name = model.getName();
        double[] points = model.getPositions();
        
        @SuppressWarnings("unchecked")
		Iterator<IPosition> iterator = (Iterator<IPosition>) arrayGeneratorFactory.createObject(
				name, "mm", points);
        pyIterator = iterator;
	}

	@Override
	public boolean hasNext() {
		return pyIterator.hasNext();
	}

	@Override
	public IPosition next() {
		return pyIterator.next();
	}

	public void remove() {
		throw new UnsupportedOperationException("remove");
	}
}

@@ -31,16 +31,41 @@
 oints;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -83,16 +83,16 @@
 erator;%0A
-
 %0Aimport 
@@ -273,16 +273,47 @@
 Factory;
+%0Aimport org.python.core.PyList;
 %0A%0Aclass 
@@ -601,84 +601,137 @@
     
-String name = model.getName();%0A        double%5B%5D points = model.getPositions(
+double%5B%5D points = model.getPositions();        %0A        PyList names =  new PyList(Arrays.asList(new String%5B%5D %7B model.getName()%7D)
 );%0A 
@@ -872,16 +872,16 @@
 ct(%0A
-
 %09%09%09%09name
 , %22m
@@ -876,16 +876,17 @@
 %09%09%09%09name
+s
 , %22mm%22, 

fix for creating iterator for array generator, names must be a list