com.day.cq.search.facets.extractors
Class PropertyFacetExtractor

java.lang.Object
  extended by com.day.cq.search.facets.extractors.PropertyFacetExtractor
All Implemented Interfaces:
FacetExtractor
Direct Known Subclasses:
DistinctValuesFacetExtractor, PredefinedBucketsFacetExtractor

public abstract class PropertyFacetExtractor
extends Object
implements FacetExtractor

PropertyFacetExtractor is a base class for facet extractors that work on a certain property (incl. relative paths to properties in sub-nodes), specified by the parameter propertyRelPath in the constructor. In addition, subclasses can implement filter(List, ValueFactory) for further filtering of the list of values.

Since:
5.2

Field Summary
protected static List<Property> EMPTY_PROPERTY_LIST
          Empty list of properties.
protected  String propertyRelPath
          Relative path to the property that provides the value for the facet.
 
Constructor Summary
PropertyFacetExtractor(String propertyRelPath)
           
 
Method Summary
protected abstract  List<Value> filter(List<Value> values, ValueFactory vf)
          Filters the values by applying the filter of the definition associated with this facet.
protected  List<Value> getValues(Node node)
          Gets the values of this facet for the provided node.
 void handleNode(Node node)
          Called for each node of the result set.
protected abstract  void handleValue(Value value)
          Called for each value found in a node of the result and that matches the relative property path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.day.cq.search.facets.FacetExtractor
getFacet
 

Field Detail

EMPTY_PROPERTY_LIST

protected static final List<Property> EMPTY_PROPERTY_LIST
Empty list of properties.


propertyRelPath

protected final String propertyRelPath
Relative path to the property that provides the value for the facet.

Constructor Detail

PropertyFacetExtractor

public PropertyFacetExtractor(String propertyRelPath)
Method Detail

handleValue

protected abstract void handleValue(Value value)
                             throws RepositoryException
Called for each value found in a node of the result and that matches the relative property path. This can be multiple values per node as it could be a multi-value property or if multiple properties match the relative property path pattern.

Parameters:
value - a value to check in which bucket it fits
Throws:
RepositoryException

filter

protected abstract List<Value> filter(List<Value> values,
                                      ValueFactory vf)
                               throws RepositoryException
Filters the values by applying the filter of the definition associated with this facet.

Parameters:
values - the values to filter.
vf - the value factory.
Returns:
the filtered values.
Throws:
RepositoryException - if an error occurs while reading the values.

handleNode

public void handleNode(Node node)
                throws RepositoryException
Description copied from interface: FacetExtractor
Called for each node of the result set.

Specified by:
handleNode in interface FacetExtractor
Parameters:
node - node in the result
Throws:
RepositoryException - if access to the node failed, ie. one of the methods on node threw an exception

getValues

protected List<Value> getValues(Node node)
                         throws RepositoryException
Gets the values of this facet for the provided node.

Parameters:
node - the node.
Returns:
the values of this facet.
Throws:
RepositoryException - if an error occurs while reading from the node.


Copyright © 2009 Day Management AG. All Rights Reserved.