/*
 * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
 *
 * This library 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 2 of the License, or (at your option) any later version.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.mandarax.util;

import org.mandarax.kernel.ClauseSetException;

/**
 * Iterator for clauses.
 * In this abstract class compatiblity methods with <code>java.util.Enumeration</code>
 * and <code>java.util.Iterator</code> were defined. Since the ClauseIterator method throw now
 * an ClauseSetException, this compatibility is not longer maintained!
 * The respective methods from Iterator and Enumeration are marked as depreceted and should not be marked. 
 * For compatibility, we keep this class alive and implement this methods.
 * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
 * @version 3.3.1 <9 August 2004>
 * @since 1.0
 */
public abstract class AbstractClauseIterator implements ClauseIterator {

	/**
	 * Constructor.
	 */
	protected AbstractClauseIterator() {
		super();
	}

	/**
	 * Indicates whether there are more elements.
	 * Duplicates the functionality of <code>hasMoreClauses()</code> in order to implement
	 * the <code>java.util.Enumeration</code> interface.
	 * @return true if there are more clauses, false otherwise
	 * @deprecated read class comment for details
	 */
	public boolean hasMoreElements() {
		try {
			return hasMoreClauses();
		}
		catch (Exception x) {
			return false;
		}
	}

	/**
	 * Indicates whether there are more elements.
	 * Duplicates the functionality of <code>hasMoreClauses()</code> in order to implement
	 * the <code>java.util.Iterator</code> interface.
	 * @return true if there are more clauses, false otherwise
	 * @deprecated read class comment for details
	 */
	public boolean hasNext() {
		try {
			return hasMoreClauses();
		}
		catch (Exception x) {
			return false;
		}
	}

	/**
	 * Get the next element.
	 * Duplicates the functionality of <code>nextClause()</code> in order to implement
	 * the <code>java.util.Iterator</code> interface.
	 * @return the next clause
	 * @deprecated read class comment for details
	 */
	public Object next() {
		try {
			return nextClause();
		}
		catch (ClauseSetException x) {
			return null;
		}
	}

	/**
	 * Get the next element.
	 * Duplicates the functionality of <code>nextClause()</code> in order to implement
	 * the <code>java.util.Enumeration</code> interface.
	 * @return the next clause
	 * @deprecated read class comment for details
	 */
	public Object nextElement() {
		try {
			return nextClause();
		}
		catch (ClauseSetException x) {
			return null;
		}
	}

	/**
	 * Remove an element. Not supported, throws a <code>UnsupportedOperationException</code>.
	 * @deprecated read class comment for details
	 */
	public void remove() {
		throw new UnsupportedOperationException();
	}
	/**
     * Close the iterator and release all resources.
     * By default, do nothing.
     */
    public void close(){}
}
