org.apache.lucene.facet.index
Class CategoryContainer

java.lang.Object
  extended by org.apache.lucene.facet.index.CategoryContainer
All Implemented Interfaces:
Serializable, Iterable<CategoryAttribute>

public class CategoryContainer
extends Object
implements Iterable<CategoryAttribute>, Serializable

A container to add categories which are to be introduced to CategoryDocumentBuilder.setCategories(Iterable). Categories can be added with Properties.

See Also:
Serialized Form
WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
protected  Map<CategoryPath,CategoryAttribute> map
           
 
Constructor Summary
CategoryContainer()
          Constructor.
 
Method Summary
 CategoryAttribute addCategory(CategoryAttribute categoryAttribute)
          Add an entire CategoryAttribute.
 CategoryAttribute addCategory(CategoryPath categoryPath)
          Add a category.
 CategoryAttribute addCategory(CategoryPath categoryPath, CategoryProperty... properties)
          Add a category with multiple properties.
 CategoryAttribute addCategory(CategoryPath categoryPath, CategoryProperty property)
          Add a category with a property.
 void clear()
          Remove all categories.
protected  void deserializeCategoryAttribute(ObjectInputStream in)
          De-Serialize each of the CategoryAttributes from the given ObjectInputStream.
 boolean equals(Object o)
           
 CategoryAttribute getCategoryAttribute(CategoryPath categoryPath)
          Get the CategoryAttribute this container has for a certain category, or null if the category is not in the container.
 int hashCode()
           
 Iterator<CategoryAttribute> iterator()
           
 void merge(CategoryContainer other)
          Add the categories from another CategoryContainer to this one.
protected  void serializeCategoryAttribute(ObjectOutputStream out, CategoryAttribute ca)
          Serialize each of the CategoryAttributes to the given ObjectOutputStream.
NOTE: CategoryPropertys are Serializable, but do not assume that Lucene's Attributes are as well
 int size()
          Get the number of categories in the container.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected transient Map<CategoryPath,CategoryAttribute> map
Constructor Detail

CategoryContainer

public CategoryContainer()
Constructor.

Method Detail

addCategory

public CategoryAttribute addCategory(CategoryPath categoryPath)
Add a category.

Parameters:
categoryPath - The path of the category.
Returns:
The CategoryAttribute of the category.

addCategory

public CategoryAttribute addCategory(CategoryPath categoryPath,
                                     CategoryProperty property)
Add a category with a property.

Parameters:
categoryPath - The path of the category.
property - The property to associate to the category.
Returns:
The CategoryAttribute of the category.

addCategory

public CategoryAttribute addCategory(CategoryPath categoryPath,
                                     CategoryProperty... properties)
Add a category with multiple properties.

Parameters:
categoryPath - The path of the category.
properties - The properties to associate to the category.
Returns:
The CategoryAttribute of the category.

addCategory

public CategoryAttribute addCategory(CategoryAttribute categoryAttribute)
Add an entire CategoryAttribute.

Parameters:
categoryAttribute - The CategoryAttribute to add.
Returns:
The CategoryAttribute of the category (could be different from the one provided).

getCategoryAttribute

public CategoryAttribute getCategoryAttribute(CategoryPath categoryPath)
Get the CategoryAttribute this container has for a certain category, or null if the category is not in the container.

Parameters:
categoryPath - The category path of the requested category.

iterator

public Iterator<CategoryAttribute> iterator()
Specified by:
iterator in interface Iterable<CategoryAttribute>

clear

public void clear()
Remove all categories.


merge

public void merge(CategoryContainer other)
Add the categories from another CategoryContainer to this one.


size

public int size()
Get the number of categories in the container.

Returns:
The number of categories in the container.

toString

public String toString()
Overrides:
toString in class Object

serializeCategoryAttribute

protected void serializeCategoryAttribute(ObjectOutputStream out,
                                          CategoryAttribute ca)
                                   throws IOException
Serialize each of the CategoryAttributes to the given ObjectOutputStream.
NOTE: CategoryPropertys are Serializable, but do not assume that Lucene's Attributes are as well

Throws:
IOException

deserializeCategoryAttribute

protected void deserializeCategoryAttribute(ObjectInputStream in)
                                     throws IOException,
                                            ClassNotFoundException
De-Serialize each of the CategoryAttributes from the given ObjectInputStream.

Throws:
IOException
ClassNotFoundException

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object