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

java.lang.Object
  extended by com.day.cq.search.facets.extractors.PropertyFacetExtractor
      extended by com.day.cq.search.facets.extractors.DistinctValuesFacetExtractor
All Implemented Interfaces:
FacetExtractor

public class DistinctValuesFacetExtractor
extends PropertyFacetExtractor

DistinctBucketsFacetExtractor automatically extracts buckets based on distinct values for given properties (or node paths) in the result.

Since:
5.2

Field Summary
 
Fields inherited from class com.day.cq.search.facets.extractors.PropertyFacetExtractor
EMPTY_PROPERTY_LIST, propertyRelPath
 
Constructor Summary
DistinctValuesFacetExtractor(String propertyRelPath, String nodePathFilter, Predicate predicateTemplate, String valueParameterName)
          Creates a new facet extractor with the given nodePathFilter.
 
Method Summary
 boolean equals(Object obj)
           
protected  List<Value> filter(List<Value> values, ValueFactory vf)
          Filters the values by applying the filter of the definition associated with this facet.
protected  String getBucketValue(String value)
          This allows subclasses to filter the bucket value.
 Facet getFacet()
          Called after the result set was scanned (and FacetExtractor.handleNode(Node) was called for each node in the result) to retrieve the final Facet object.
protected  void handleValue(Value value)
          Called for each value found in a node of the result and that matches the relative property path.
 int hashCode()
           
 
Methods inherited from class com.day.cq.search.facets.extractors.PropertyFacetExtractor
getValues, handleNode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistinctValuesFacetExtractor

public DistinctValuesFacetExtractor(String propertyRelPath,
                                    String nodePathFilter,
                                    Predicate predicateTemplate,
                                    String valueParameterName)
Creates a new facet extractor with the given nodePathFilter. The values for this facet are based on the property values referenced by propertyRelPath. A predicateTemplate must be given which for each detected bucket will be cloned and filled with the specific value of the bucket; the value will be placed in the parameter of the predicate given by valueParameterName.

Parameters:
propertyRelPath - a relative path that points to a property. The relative path is based on the path of the result nodes.
nodePathFilter - a regular expression to filter the property value or null to use the property value as is.
predicateTemplate - the predicate template, which will be cloned and filled with the specific value for each bucket
valueParameterName - name of the paramter in the predicateTemplate to set with the value for the bucket
Method Detail

getFacet

public Facet getFacet()
Description copied from interface: FacetExtractor
Called after the result set was scanned (and FacetExtractor.handleNode(Node) was called for each node in the result) to retrieve the final Facet object. Please note that this might be called without FacetExtractor.handleNode(Node) ever being called, if the result was empty.

Implementations can use the simple FacetImpl implementation of the Facet interface.

Returns:
an implementation of the Facet interface with all buckets found in the result or null if nothing was found in the result

handleValue

protected void handleValue(Value value)
                    throws RepositoryException
Description copied from class: PropertyFacetExtractor
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.

Specified by:
handleValue in class PropertyFacetExtractor
Parameters:
value - a value to check in which bucket it fits
Throws:
RepositoryException

getBucketValue

protected String getBucketValue(String value)
This allows subclasses to filter the bucket value. If this method returns null, the bucket will be ignored. This original implementation simply returns the given value.


filter

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

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

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2009 Day Management AG. All Rights Reserved.