Package org.apache.lucene.facet.index
Class CategoryContainer
- java.lang.Object
-
- 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 toCategoryDocumentBuilder.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
Fields Modifier and Type Field Description protected Map<CategoryPath,CategoryAttribute>map
-
Constructor Summary
Constructors Constructor Description CategoryContainer()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CategoryAttributeaddCategory(CategoryAttribute categoryAttribute)Add an entireCategoryAttribute.CategoryAttributeaddCategory(CategoryPath categoryPath)Add a category.CategoryAttributeaddCategory(CategoryPath categoryPath, CategoryProperty property)Add a category with a property.CategoryAttributeaddCategory(CategoryPath categoryPath, CategoryProperty... properties)Add a category with multiple properties.voidclear()Remove all categories.protected voiddeserializeCategoryAttribute(ObjectInputStream in)De-Serialize each of theCategoryAttributes from the givenObjectInputStream.booleanequals(Object o)CategoryAttributegetCategoryAttribute(CategoryPath categoryPath)Get theCategoryAttributethis container has for a certain category, ornullif the category is not in the container.inthashCode()Iterator<CategoryAttribute>iterator()voidmerge(CategoryContainer other)Add the categories from anotherCategoryContainerto this one.protected voidserializeCategoryAttribute(ObjectOutputStream out, CategoryAttribute ca)Serialize each of theCategoryAttributes to the givenObjectOutputStream.
NOTE:CategoryPropertys areSerializable, but do not assume that Lucene'sAttributes are as wellintsize()Get the number of categories in the container.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
map
protected transient Map<CategoryPath,CategoryAttribute> map
-
-
Method Detail
-
addCategory
public CategoryAttribute addCategory(CategoryPath categoryPath)
Add a category.- Parameters:
categoryPath- The path of the category.- Returns:
- The
CategoryAttributeof 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
CategoryAttributeof 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
CategoryAttributeof the category.
-
addCategory
public CategoryAttribute addCategory(CategoryAttribute categoryAttribute)
Add an entireCategoryAttribute.- Parameters:
categoryAttribute- TheCategoryAttributeto add.- Returns:
- The
CategoryAttributeof the category (could be different from the one provided).
-
getCategoryAttribute
public CategoryAttribute getCategoryAttribute(CategoryPath categoryPath)
Get theCategoryAttributethis container has for a certain category, ornullif the category is not in the container.- Parameters:
categoryPath- The category path of the requested category.
-
iterator
public Iterator<CategoryAttribute> iterator()
- Specified by:
iteratorin interfaceIterable<CategoryAttribute>
-
clear
public void clear()
Remove all categories.
-
merge
public void merge(CategoryContainer other)
Add the categories from anotherCategoryContainerto this one.
-
size
public int size()
Get the number of categories in the container.- Returns:
- The number of categories in the container.
-
serializeCategoryAttribute
protected void serializeCategoryAttribute(ObjectOutputStream out, CategoryAttribute ca) throws IOException
Serialize each of theCategoryAttributes to the givenObjectOutputStream.
NOTE:CategoryPropertys areSerializable, but do not assume that Lucene'sAttributes are as well- Throws:
IOException
-
deserializeCategoryAttribute
protected void deserializeCategoryAttribute(ObjectInputStream in) throws IOException, ClassNotFoundException
De-Serialize each of theCategoryAttributes from the givenObjectInputStream.- Throws:
IOExceptionClassNotFoundException
-
-