Package org.apache.solr.analytics.util
Class FacetRangeGenerator<T extends Comparable<T>>
- java.lang.Object
-
- org.apache.solr.analytics.util.FacetRangeGenerator<T>
-
public abstract class FacetRangeGenerator<T extends Comparable<T>> extends Object
Calculates a set ofFacetRangeGenerator.FacetRange
s for a givenRangeFacet
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FacetRangeGenerator.FacetRange
-
Field Summary
Fields Modifier and Type Field Description protected SchemaField
field
protected RangeFacet
rangeFacet
-
Constructor Summary
Constructors Constructor Description FacetRangeGenerator(RangeFacet rangeFacet)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
addGap(T value, String gap)
Adds the String gap param to a low Range endpoint value to determine the corrisponding high Range endpoint value, throwing a useful exception if not possible.static FacetRangeGenerator<? extends Comparable<?>>
create(RangeFacet rangeFacet)
String
formatValue(T val)
Formats a Range endpoint for use as a range label name in the response.Object
getGap(String gap)
Parses a String param into a value that represents the gap and can be included in the response, throwing a useful exception if not possible.List<FacetRangeGenerator.FacetRange>
getRanges()
T
getValue(String rawval)
Parses a String param into an Range endpoint value throwing a useful exception if not possibleprotected abstract T
parseAndAddGap(T value, String gap)
Adds the String gap param to a low Range endpoint value to determine the corrisponding high Range endpoint value.protected Object
parseGap(String rawval)
Parses a String param into a value that represents the gap and can be included in the response.protected abstract T
parseVal(String rawval)
Parses a String param into an Range endpoint.
-
-
-
Field Detail
-
field
protected final SchemaField field
-
rangeFacet
protected final RangeFacet rangeFacet
-
-
Constructor Detail
-
FacetRangeGenerator
public FacetRangeGenerator(RangeFacet rangeFacet)
-
-
Method Detail
-
formatValue
public String formatValue(T val)
Formats a Range endpoint for use as a range label name in the response. Default Impl just uses toString()
-
getValue
public final T getValue(String rawval)
Parses a String param into an Range endpoint value throwing a useful exception if not possible
-
parseVal
protected abstract T parseVal(String rawval) throws ParseException
Parses a String param into an Range endpoint. Can throw a low level format exception as needed.- Throws:
ParseException
-
getGap
public final Object getGap(String gap)
Parses a String param into a value that represents the gap and can be included in the response, throwing a useful exception if not possible.Note: uses Object as the return type instead of T for things like Date where gap is just a DateMathParser string
-
parseGap
protected Object parseGap(String rawval) throws ParseException
Parses a String param into a value that represents the gap and can be included in the response. Can throw a low level format exception as needed.Default Impl calls parseVal
- Throws:
ParseException
-
addGap
public final T addGap(T value, String gap)
Adds the String gap param to a low Range endpoint value to determine the corrisponding high Range endpoint value, throwing a useful exception if not possible.
-
parseAndAddGap
protected abstract T parseAndAddGap(T value, String gap) throws ParseException
Adds the String gap param to a low Range endpoint value to determine the corrisponding high Range endpoint value. Can throw a low level format exception as needed.- Throws:
ParseException
-
getRanges
public List<FacetRangeGenerator.FacetRange> getRanges()
-
create
public static FacetRangeGenerator<? extends Comparable<?>> create(RangeFacet rangeFacet)
-
-