package com.oozinoz.util;

import java.util.*;

/*
 * Copyright (c) 2001 Steven J. Metsker.
 * 
 * Steve Metsker makes no representations or warranties about
 * the fitness of this software for any particular purpose, 
 * including the implied warranty of merchantability.
 *
 * Please use this software as you wish with the sole
 * restriction that you may not claim that you wrote it.
 */
 
/**
 * This is the abstract superclass of iterators that can
 * walk across leaf nodes and composite nodes in a
 * composite structure.
 * <p>
 * The depth of an iterator is, for the current iteration, 
 * the number of iterators above it. A typical iterator 
 * walks over a composite, iterating over each child. Each 
 * child, however, may also be a composite, so iterating 
 * over a child means iterating over a child's children. In 
 * a tree structure, the root iterator will at any point be 
 * iterating over one of its children. This child will be 
 * iterating over its children. This recurses down to 
 * component that is either a leaf or it a node that has 
 * been visited before. The depth of iteration, then, is 
 * the depth of a subiterator plus one.
 *
 * @author Steven J. Metsker
 *
 */
public abstract class ComponentIterator 
{


	protected Object node;
	protected boolean showInterior = true;
	protected Set visited = new HashSet();

/**
 * Create an iterator over a node in a composite.
 *
 * @param node the node to iterate over
 * @param visited a set to track visited nodes
 */
public ComponentIterator(Object node, Set visited)
{
	this.node = node;
	this.visited = visited;
}

/**
 * Return the current depth of the iteration
 *
 * @return the current depth of the iteration (that is, for
 *         the current node the number of nodes above it)
 */
public abstract int depth();

/**
 * Return true if there is another node to see
 *
 * @return true if there is another node to see
 */
public abstract boolean hasNext();

/**
 * Return the next node in the iteration
 *
 * @return the next node in the iteration
 */
public abstract Object next();

/**
 * Determine whether interior (non-leaf) nodes should
 * appear in iteration.
 *
 * @param boolean if true, interior nodes can be returned
 *                from next()
 */
public void setShowInterior(boolean showInterior)
{
	this.showInterior = showInterior;
}
}

@@ -45,1162 +45,8 @@
 *;%0A%0A
-/*%0A * Copyright (c) 2001 Steven J. Metsker.%0A * %0A * Steve Metsker makes no representations or warranties about%0A * the fitness of this software for any particular purpose, %0A * including the implied warranty of merchantability.%0A *%0A * Please use this software as you wish with the sole%0A * restriction that you may not claim that you wrote it.%0A */%0A %0A/**%0A * This is the abstract superclass of iterators that can%0A * walk across leaf nodes and composite nodes in a%0A * composite structure.%0A * %3Cp%3E%0A * The depth of an iterator is, for the current iteration, %0A * the number of iterators above it. A typical iterator %0A * walks over a composite, iterating over each child. Each %0A * child, however, may also be a composite, so iterating %0A * over a child means iterating over a child's children. In %0A * a tree structure, the root iterator will at any point be %0A * iterating over one of its children. This child will be %0A * iterating over its children. This recurses down to %0A * component that is either a leaf or it a node that has %0A * been visited before. The depth of iteration, then, is %0A * the depth of a subiterator plus one.%0A *%0A * @author Steven J. Metsker%0A *%0A */%0A
 publ

Update ComponentIterator.java