Class AssociationEnhancement
- java.lang.Object
-
- org.apache.lucene.facet.enhancements.association.AssociationEnhancement
-
- All Implemented Interfaces:
CategoryEnhancement
public class AssociationEnhancement extends Object implements CategoryEnhancement
ACategoryEnhancementfor adding associations data to the index (categories withAssociationPropertys).- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description AssociationEnhancement()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Category enhancements must overrideObject.equals(Object), as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement).ObjectextractCategoryTokenData(byte[] buffer, int offset, int length)Get the data of this enhancement from a category token payload.booleangeneratesCategoryList()Declarative method to indicate whether this enhancement generates separate category list.static AssociationPropertygetAssociationProperty(CategoryAttribute categoryAttribute)StringgetCategoryListTermText()Returns the text of this enhancement's category list term.CategoryListTokenizergetCategoryListTokenizer(org.apache.lucene.analysis.TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)Get theCategoryListTokenizerwhich generates the category list for this enhancement.byte[]getCategoryTokenBytes(CategoryAttribute categoryAttribute)Get the bytes to be added to the category token payload for this enhancement.Class<? extends CategoryProperty>getRetainableProperty()Get aCategoryPropertyclass to be retained when creatingCategoryParentsStream.inthashCode()static booleanisAssociationProperty(Class<? extends CategoryProperty> clazz)For a given class which extends a CategoryProperty, answers whether it is an instance of AssociationProperty (AP) or not.
-
-
-
Method Detail
-
isAssociationProperty
public static boolean isAssociationProperty(Class<? extends CategoryProperty> clazz)
For a given class which extends a CategoryProperty, answers whether it is an instance of AssociationProperty (AP) or not.
This method is a cheaper replacement for a call toinstanceof. It has two HashSets - one for classes which are an extension to AP and one for the classes which are not. Whenever a property class is introduced:- if it is known as a property class extending AP (contained in the validHashSet)- returns true
- if it is known as a property class NOT extending AP - returns false
- If it was not matched against both sets, it calls 'instanceof' to find out if it extends AP, puts it in the matching Set and returning true or false accordingly
-
generatesCategoryList
public boolean generatesCategoryList()
Description copied from interface:CategoryEnhancementDeclarative method to indicate whether this enhancement generates separate category list.- Specified by:
generatesCategoryListin interfaceCategoryEnhancement- Returns:
trueif generates category list, elsefalse.
-
getCategoryListTermText
public String getCategoryListTermText()
Description copied from interface:CategoryEnhancementReturns the text of this enhancement's category list term.- Specified by:
getCategoryListTermTextin interfaceCategoryEnhancement- Returns:
- The text of this enhancement's category list term.
-
getCategoryListTokenizer
public CategoryListTokenizer getCategoryListTokenizer(org.apache.lucene.analysis.TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)
Description copied from interface:CategoryEnhancementGet theCategoryListTokenizerwhich generates the category list for this enhancement. IfCategoryEnhancement.generatesCategoryList()returnsfalsethis method will not be called.- Specified by:
getCategoryListTokenizerin interfaceCategoryEnhancement- Parameters:
tokenizer- The input stream containing categories.indexingParams- The indexing params to use.taxonomyWriter- The taxonomy to add categories and get their ordinals.- Returns:
- A
CategoryListTokenizergenerating the category list for this enhancement, withtokenizeras it's input.
-
getCategoryTokenBytes
public byte[] getCategoryTokenBytes(CategoryAttribute categoryAttribute)
Description copied from interface:CategoryEnhancementGet the bytes to be added to the category token payload for this enhancement.NOTE: The returned array is copied, it is recommended to allocate a new one each time.
The bytes generated by this method are the input of
CategoryEnhancement.extractCategoryTokenData(byte[], int, int).- Specified by:
getCategoryTokenBytesin interfaceCategoryEnhancement- Parameters:
categoryAttribute- The attribute of the category.- Returns:
- The bytes to be added to the category token payload for this enhancement.
-
getAssociationProperty
public static AssociationProperty getAssociationProperty(CategoryAttribute categoryAttribute)
-
extractCategoryTokenData
public Object extractCategoryTokenData(byte[] buffer, int offset, int length)
Description copied from interface:CategoryEnhancementGet the data of this enhancement from a category token payload.The input bytes for this method are generated in
CategoryEnhancement.getCategoryTokenBytes(CategoryAttribute).- Specified by:
extractCategoryTokenDatain interfaceCategoryEnhancement- Parameters:
buffer- The payload buffer.offset- The offset of this enhancement's data in the buffer.length- The length of this enhancement's data (bytes).- Returns:
- An Object containing the data.
-
getRetainableProperty
public Class<? extends CategoryProperty> getRetainableProperty()
Description copied from interface:CategoryEnhancementGet aCategoryPropertyclass to be retained when creatingCategoryParentsStream.- Specified by:
getRetainablePropertyin interfaceCategoryEnhancement- Returns:
- the
CategoryPropertyclass to be retained when creatingCategoryParentsStream, ornullif there is no such property.
-
equals
public boolean equals(Object o)
Description copied from interface:CategoryEnhancementCategory enhancements must overrideObject.equals(Object), as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement).- Specified by:
equalsin interfaceCategoryEnhancement- Overrides:
equalsin classObject
-
-