@@ -0,0 +1,2567 @@
+/*%0A * Copyright (c) 2013 Red Rainbow IT Solutions GmbH, Germany%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy of%0A * this software and associated documentation files (the %22Software%22), to deal in%0A * the Software without restriction, including without limitation the rights to%0A * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of%0A * the Software, and to permit persons to whom the Software is furnished to do so,%0A * subject to the following conditions:%0A * %0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A * %0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS%0A * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR%0A * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER%0A * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN%0A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%0A */%0A%0Apackage org.jeeventstore.core.store;%0A%0Aimport java.io.Serializable;%0Aimport java.util.Iterator;%0Aimport org.jeeventstore.core.ChangeSet;%0A%0A/**%0A * An iterator that iterates over all events in a series of %7B@link ChangeSet%7Ds.%0A * %0A * @author Alexander Langer%0A */%0Apublic class EventsIterator%3CT extends ChangeSet%3E implements Iterator%3CSerializable%3E %7B%0A%0A    private Iterator%3CT%3E cit;%0A    private Iterator%3CSerializable%3E it = null;%0A%0A    public EventsIterator(Iterator%3CT%3E cit) %7B%0A        this.cit = cit;%0A        advance();%0A    %7D%0A    %0A    private void advance() %7B%0A        if (it != null && it.hasNext())%0A            return;%0A        // now either it == null or it has no next%0A        do %7B%0A            // already reached the last change set?%0A            if (!cit.hasNext()) %7B%0A                it = null;%0A                return;%0A            %7D%0A            // no, another changeset is available.  Grab it.%0A            ChangeSet nextcs = cit.next();%0A            it = nextcs.events();%0A        %7D while (!it.hasNext()); // protect against ChangeSets w/o events%0A    %7D%0A%0A    @Override%0A    public boolean hasNext() %7B%0A        return it != null;%0A    %7D%0A%0A    @Override%0A    public Serializable next() %7B%0A        Serializable n = it.next();%0A        advance();%0A        return n;%0A    %7D%0A%0A    /**%0A     * %7B@link remove()%7D is not supported.%0A     */%0A    @Override%0A    public void remove() %7B%0A        throw new UnsupportedOperationException(%22Not supported.%22);%0A    %7D%0A    %0A%7D%0A

Add EventsIterator