/********************************************** * Copyright (C) 2011 Lukas laag * This file is part of lib-gwt-file. * * lib-gwt-file is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * lib-gwt-file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with lib-gwt-file. If not, see http://www.gnu.org/licenses/ **********************************************/ package com.gwt.ui.client.gwtupld.file; import java.util.Iterator; import com.gwt.ui.client.gwtupld.file.impl.FileListImpl; public class FileList implements Iterable<File> { private FileListImpl impl; public FileList(FileListImpl impl) { this.impl = impl; } @Override public Iterator<File> iterator() { return new Iterator<File>() { private int index; @Override public boolean hasNext() { return index < getLength(); } @Override public File next() { return getItem(index++); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } /** * Returns the <code>index</code>th item in the collection. If <code>index</code> is greater than or equal to the number of nodes in the * list, this returns <code>null</code>. * * @param index Index into the collection. * @return The node at the <code>index</code>th position in the <code>FileList</code>, or <code>null</code> if that is not a valid * index. */ public final File getItem(int index) { return impl.getItem(index); } /** * The number of nodes in the list. The range of valid child node indices is 0 to <code>length-1</code> inclusive. */ public final int getLength() { return impl.getLength(); } }