Class CategoryAttributeImpl
- java.lang.Object
-
- org.apache.lucene.util.AttributeImpl
-
- org.apache.lucene.facet.index.attributes.CategoryAttributeImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,CategoryAttribute
,Attribute
public final class CategoryAttributeImpl extends AttributeImpl implements CategoryAttribute
An implementation ofCategoryAttribute
.- 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 CategoryPath
categoryPath
The category path instance.protected HashMap<Class<? extends CategoryProperty>,CategoryProperty>
properties
A map of properties associated to the current category path.-
Fields inherited from class org.apache.lucene.util.AttributeImpl
enableBackwards
-
-
Constructor Summary
Constructors Constructor Description CategoryAttributeImpl()
Construct an empty CategoryAttributeImpl.CategoryAttributeImpl(CategoryPath categoryPath)
Construct a CategoryAttributeImpl with the given CategoryPath.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProperty(CategoryProperty property)
Add a property.void
clear()
Clears the values in this AttributeImpl and resets it to its default value.void
clearProperties()
Clear all properties.CategoryAttribute
clone()
Shallow clone.void
copyTo(AttributeImpl target)
Copies the values from this Attribute into the passed-in target attribute.boolean
equals(Object o)
CategoryPath
getCategoryPath()
Returns the category path value.CategoryProperty
getProperty(Class<? extends CategoryProperty> propertyClass)
Get a property of a certain property class.CategoryProperty
getProperty(Collection<Class<? extends CategoryProperty>> propertyClasses)
Get a property of one of given property classes.Set<Class<? extends CategoryProperty>>
getPropertyClasses()
Get all the active property classes.int
hashCode()
void
remove(Class<? extends CategoryProperty> propertyClass)
Remove an property of a certain property class.void
set(CategoryAttribute other)
Set the content of thisCategoryAttribute
from anotherCategoryAttribute
object.void
setCategoryPath(CategoryPath cp)
Sets the category path value of this attribute.-
Methods inherited from class org.apache.lucene.util.AttributeImpl
reflectAsString, reflectWith, toString
-
-
-
-
Field Detail
-
categoryPath
protected CategoryPath categoryPath
The category path instance.
-
properties
protected HashMap<Class<? extends CategoryProperty>,CategoryProperty> properties
A map of properties associated to the current category path.
-
-
Constructor Detail
-
CategoryAttributeImpl
public CategoryAttributeImpl()
Construct an empty CategoryAttributeImpl.
-
CategoryAttributeImpl
public CategoryAttributeImpl(CategoryPath categoryPath)
Construct a CategoryAttributeImpl with the given CategoryPath.- Parameters:
categoryPath
- The category path to use.
-
-
Method Detail
-
set
public void set(CategoryAttribute other)
Description copied from interface:CategoryAttribute
Set the content of thisCategoryAttribute
from anotherCategoryAttribute
object.- Specified by:
set
in interfaceCategoryAttribute
- Parameters:
other
- TheCategoryAttribute
to take the content from.
-
getCategoryPath
public CategoryPath getCategoryPath()
Returns the category path value.- Specified by:
getCategoryPath
in interfaceCategoryAttribute
- Returns:
- The category path last assigned to this attribute, or null if none has been assigned.
-
setCategoryPath
public void setCategoryPath(CategoryPath cp)
Description copied from interface:CategoryAttribute
Sets the category path value of this attribute.- Specified by:
setCategoryPath
in interfaceCategoryAttribute
- Parameters:
cp
- A category path. May not be null.
-
addProperty
public void addProperty(CategoryProperty property) throws UnsupportedOperationException
Description copied from interface:CategoryAttribute
Add a property. The property can be later retrieved usingCategoryAttribute.getProperty(Class)
with this property class .
Adding multiple properties of the same class is forbidden.- Specified by:
addProperty
in interfaceCategoryAttribute
- Parameters:
property
- The property to add.- Throws:
UnsupportedOperationException
- When attempting to add a property of a class that was added before and merge is prohibited.
-
getProperty
public CategoryProperty getProperty(Class<? extends CategoryProperty> propertyClass)
Description copied from interface:CategoryAttribute
Get a property of a certain property class.- Specified by:
getProperty
in interfaceCategoryAttribute
- Parameters:
propertyClass
- The required property class.- Returns:
- The property of the given class, or null if no such property exists.
-
getProperty
public CategoryProperty getProperty(Collection<Class<? extends CategoryProperty>> propertyClasses)
Description copied from interface:CategoryAttribute
Get a property of one of given property classes.- Specified by:
getProperty
in interfaceCategoryAttribute
- Parameters:
propertyClasses
- The property classes.- Returns:
- A property matching one of the given classes, or null if no such property exists.
-
copyTo
public void copyTo(AttributeImpl target)
Description copied from class:AttributeImpl
Copies the values from this Attribute into the passed-in target attribute. The target implementation must support all the Attributes this implementation supports.- Specified by:
copyTo
in classAttributeImpl
-
clone
public CategoryAttribute clone()
Description copied from class:AttributeImpl
Shallow clone. Subclasses must override this if they need to clone any members deeply,- Specified by:
clone
in interfaceCategoryAttribute
- Overrides:
clone
in classAttributeImpl
- Returns:
- A clone of this
CategoryAttribute
.
-
clear
public void clear()
Description copied from class:AttributeImpl
Clears the values in this AttributeImpl and resets it to its default value. If this implementation implements more than one Attribute interface it clears all.- Specified by:
clear
in interfaceCategoryAttribute
- Specified by:
clear
in classAttributeImpl
-
clearProperties
public void clearProperties()
Description copied from interface:CategoryAttribute
Clear all properties.- Specified by:
clearProperties
in interfaceCategoryAttribute
-
getPropertyClasses
public Set<Class<? extends CategoryProperty>> getPropertyClasses()
Description copied from interface:CategoryAttribute
Get all the active property classes.- Specified by:
getPropertyClasses
in interfaceCategoryAttribute
- Returns:
- A set containing the active property classes, or
null
if there are no properties.
-
remove
public void remove(Class<? extends CategoryProperty> propertyClass)
Description copied from interface:CategoryAttribute
Remove an property of a certain property class.- Specified by:
remove
in interfaceCategoryAttribute
- Parameters:
propertyClass
- The required property class.
-
-