/**
 * 
 */
package com.browseengine.bobo.facets.impl;

import java.util.List;
import java.util.NoSuchElementException;

import com.browseengine.bobo.api.BrowseFacet;
import com.browseengine.bobo.api.FacetIterator;

/**
 * @author nnarkhed
 *
 */
public class PathFacetIterator extends FacetIterator {

	private BrowseFacet[] _facets;
	private int _index;
	
	public PathFacetIterator(List<BrowseFacet> facets) {
		_facets = facets.toArray(new BrowseFacet[facets.size()]);
		_index = -1;
		facet = null;
		count = 0;
	}
	
	/* (non-Javadoc)
	 * @see com.browseengine.bobo.api.FacetIterator#next()
	 */
	public Comparable next() {
		if((_index >= 0) && !hasNext())
			throw new NoSuchElementException("No more facets in this iteration");
		_index++;
		facet = _facets[_index].getValue();
		count = _facets[_index].getHitCount();
		return facet;
	}

	/* (non-Javadoc)
	 * @see java.util.Iterator#hasNext()
	 */
	public boolean hasNext() {
		return ( (_index >= 0) && (_index < (_facets.length-1)) );
	}

	/* (non-Javadoc)
	 * @see java.util.Iterator#remove()
	 */
	public void remove() {
		throw new UnsupportedOperationException("remove() method not supported for Facet Iterators");
	}

  /* (non-Javadoc)
   * @see com.browseengine.bobo.api.FacetIterator#next(int)
   */
  public Comparable next(int minHits)
  {
    while(++_index < _facets.length)
    {
      if(_facets[_index].getHitCount() >= minHits)
      {
        facet = _facets[_index].getValue();
        count = _facets[_index].getHitCount();
        return facet;
      }
    }
    facet = null;
    count = 0;
    return facet;  
  }

  /**
   * The string from here should be already formatted. No need to reformat.
   * @see com.browseengine.bobo.api.FacetIterator#format(java.lang.Object)
   */
  @Override
  public String format(Object val)
  {
    return (String)val;
  }
}

@@ -351,16 +351,90 @@
 ndex;%0A%09%0A
+%09/**%0A%09 * @param facets a value ascending sorted list of BrowseFacets%0A%09 */%0A
 %09public 
@@ -479,16 +479,16 @@
 cets) %7B%0A
-
 %09%09_facet
@@ -873,32 +873,42 @@
 cets%5B_index%5D.get
+FacetValue
 HitCount();%0A%09%09re
@@ -1451,32 +1451,42 @@
 cets%5B_index%5D.get
+FacetValue
 HitCount() %3E= mi
@@ -1540,24 +1540,24 @@
 getValue();%0A
-
         coun
@@ -1579,16 +1579,26 @@
 dex%5D.get
+FacetValue
 HitCount

comment on PathFacetIterator to make contract clear