All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.browseengine.bobo.api.MappedFacetAccessible Maven / Gradle / Ivy

Go to download

Bobo is a Faceted Search implementation written purely in Java, an extension of Apache Lucene

The newest version!
package com.browseengine.bobo.api;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.browseengine.bobo.facets.impl.PathFacetIterator;

public class MappedFacetAccessible implements FacetAccessible, Serializable {

  /**
   *
   */
  private static final long serialVersionUID = 1L;

  private final HashMap _facetMap;
  private final BrowseFacet[] _facets;

  public MappedFacetAccessible(BrowseFacet[] facets) {
    _facetMap = new HashMap();
    for (BrowseFacet facet : facets) {
      _facetMap.put(facet.getValue(), facet);
    }
    _facets = facets;
  }

  @Override
  public BrowseFacet getFacet(String value) {
    return _facetMap.get(value);
  }

  @Override
  public int getFacetHitsCount(Object value) {
    BrowseFacet facet = _facetMap.get(value);
    if (facet != null) return facet.getFacetValueHitCount();
    return 0;
  }

  @Override
  public List getFacets() {
    return Arrays.asList(_facets);
  }

  @Override
  public void close() {
    // TODO Auto-generated method stub
  }

  @Override
  public FacetIterator iterator() {
    return new PathFacetIterator(Arrays.asList(_facets));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy