Class AssociationEnhancement
- java.lang.Object
-
- org.apache.lucene.facet.enhancements.association.AssociationEnhancement
-
- All Implemented Interfaces:
CategoryEnhancement
public class AssociationEnhancement extends Object implements CategoryEnhancement
ACategoryEnhancement
for adding associations data to the index (categories withAssociationProperty
s).- 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 boolean
equals(Object o)
Category enhancements must overrideObject.equals(Object)
, as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement)
.Object
extractCategoryTokenData(byte[] buffer, int offset, int length)
Get the data of this enhancement from a category token payload.boolean
generatesCategoryList()
Declarative method to indicate whether this enhancement generates separate category list.static AssociationProperty
getAssociationProperty(CategoryAttribute categoryAttribute)
String
getCategoryListTermText()
Returns the text of this enhancement's category list term.CategoryListTokenizer
getCategoryListTokenizer(TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)
Get theCategoryListTokenizer
which 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 aCategoryProperty
class to be retained when creatingCategoryParentsStream
.int
hashCode()
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.
-
-
-
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:CategoryEnhancement
Declarative method to indicate whether this enhancement generates separate category list.- Specified by:
generatesCategoryList
in interfaceCategoryEnhancement
- Returns:
true
if generates category list, elsefalse
.
-
getCategoryListTermText
public String getCategoryListTermText()
Description copied from interface:CategoryEnhancement
Returns the text of this enhancement's category list term.- Specified by:
getCategoryListTermText
in interfaceCategoryEnhancement
- Returns:
- The text of this enhancement's category list term.
-
getCategoryListTokenizer
public CategoryListTokenizer getCategoryListTokenizer(TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)
Description copied from interface:CategoryEnhancement
Get theCategoryListTokenizer
which generates the category list for this enhancement. IfCategoryEnhancement.generatesCategoryList()
returnsfalse
this method will not be called.- Specified by:
getCategoryListTokenizer
in 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
CategoryListTokenizer
generating the category list for this enhancement, withtokenizer
as it's input.
-
getCategoryTokenBytes
public byte[] getCategoryTokenBytes(CategoryAttribute categoryAttribute)
Description copied from interface:CategoryEnhancement
Get 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:
getCategoryTokenBytes
in 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:CategoryEnhancement
Get the data of this enhancement from a category token payload.The input bytes for this method are generated in
CategoryEnhancement.getCategoryTokenBytes(CategoryAttribute)
.- Specified by:
extractCategoryTokenData
in 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:CategoryEnhancement
Get aCategoryProperty
class to be retained when creatingCategoryParentsStream
.- Specified by:
getRetainableProperty
in interfaceCategoryEnhancement
- Returns:
- the
CategoryProperty
class to be retained when creatingCategoryParentsStream
, ornull
if there is no such property.
-
equals
public boolean equals(Object o)
Description copied from interface:CategoryEnhancement
Category enhancements must overrideObject.equals(Object)
, as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement)
.- Specified by:
equals
in interfaceCategoryEnhancement
- Overrides:
equals
in classObject
-
-