package greenfoot.importer.scratch;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;


| An array (well, collection) of ScratchObjects. | | This needs its own class, rather than using ScratchPrimitive, because resolve | calls must recurse into the array in case there are object-references in the array | (in fact, this is almost always the case). | | It is possible for entries in the array to be null, although the array | itself should not be null. | | @author neil | class ScratchObjectArray extends ScratchObject implements Iterable<ScratchObject>{ private ScratchObject[] value; public ScratchObjectArray(ScratchObject[] value) { this.value = value; } @Override public ScratchObject[] getValue() { return value; } @Override public ScratchObject resolve(ArrayList<ScratchObject> objects) { for (int i = 0; i < value.length; i++) { if (value[i] != null) { value[i] = value[i].resolve(objects); } } return this; } @Override public Iterator iterator() { return Arrays.asList(value).iterator(); } }

.   ScratchObjectArray
.   getValue
.   resolve
.   iterator




45 neLoCode + 7 LoComm