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

com.browseengine.bobo.api.BoboBrowser 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.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.browseengine.bobo.facets.FacetHandler;

public class BoboBrowser extends MultiBoboBrowser {
  /**
   * @param reader BoboMultiReader
   * @throws IOException
   */
  public BoboBrowser(BoboMultiReader reader) throws IOException {
    super(createBrowsables(reader.getSubReaders()));
  }

  public static List gatherSubReaders(List readerList) {
    List subReaderList = new ArrayList();
    for (BoboMultiReader reader : readerList) {
      for (BoboSegmentReader subReader : reader.getSubReaders()) {
        subReaderList.add(subReader);
      }
    }
    return subReaderList;
  }

  public static Browsable[] createBrowsables(List readerList) {
    BoboSubBrowser[] browsables = new BoboSubBrowser[readerList.size()];
    for (int i = 0; i < readerList.size(); ++i) {
      browsables[i] = new BoboSubBrowser(readerList.get(i));
    }
    return browsables;
  }

  /**
   * Gets a set of facet names
   *
   * @return set of facet names
   */
  @Override
  public Set getFacetNames() {
    if (_subBrowsers.length == 0) {
      return null;
    }
    return _subBrowsers[0].getFacetNames();
  }

  @Override
  public FacetHandler getFacetHandler(String name) {
    if (_subBrowsers.length == 0) {
      return null;
    }
    return _subBrowsers[0].getFacetHandler(name);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy