/************************************************************************ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: Iterator.java,v $ * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org 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 version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ package org.openoffice.xmerge.merger; /** * This is an interface used by the {@link * org.openoffice.xmerge.merger.DiffAlgorithm * DiffAlgorithm} and {@link * org.openoffice.xmerge.merger.MergeAlgorithm * MergeAlgorithm} to access a Document. * * @author smak */ public interface Iterator { /** * Move to next element in the sequence. * * @return The Object of the next element in the sequence. * If there is no next element, then return null. */ public Object next(); /** * Move to previous element in the sequence. * * @return The Object of the previous element in the sequence. * If there is no previous element, then return null. */ public Object previous(); /** * Move to the beginning of the sequence. * * @return The Object of the first element in the sequence. * If it is empty, then return null. */ public Object start(); /** * Move to the end of the sequence. * * @return The Object of the last element in the sequence. * If it is empty, then return null. */ public Object end(); /** * Return the current element Object content. * * @return The Object at current position. */ public Object currentElement(); /** * Return the total element count in the sequence. * * @return The total element count. */ public int elementCount(); /** * A method to allow the difference algorithm to test whether the * obj1 and obj2 in the * Iterator are considered equal. As not every * Object in the Iterator can implement its * own equal method, with this equivalent method, we can allow * flexibility for the Iterator to choose a custom way * to compare two objects. Two objects can even be compared based on * the position in the Iterator rather than by * the content via this option. * * @param obj1 The first Object. * @param obj2 The second Object. * * @return true if equal, false otherwise. */ public boolean equivalent(Object obj1, Object obj2); /** *

A method to force the Iterator to transverse the tree * again to refresh the content.

* *

It is used mainly for Iterator objects which take a snap * shot instead of dynamically transversing the tree. The current * position will be set to the beginning.

*/ public void refresh(); }