Package org.geotools.feature.visitor
Class AverageVisitor
- Object
-
- AverageVisitor
-
- All Implemented Interfaces:
FeatureVisitor,FeatureAttributeVisitor,FeatureCalc
public class AverageVisitor extends Object implements FeatureCalc, FeatureAttributeVisitor
Calculates the Average- Since:
- 2.2.M2
- Author:
- Cory Horner, Refractions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAverageVisitor.AverageResult
-
Constructor Summary
Constructors Constructor Description AverageVisitor(int attributeTypeIndex, SimpleFeatureType type)Constructor class for the AverageVisitor using AttributeDescriptor IDAverageVisitor(String attrName, SimpleFeatureType type)Constructor class for the AverageVisitor using AttributeDescriptor NameAverageVisitor(Expression expr)Constructor class for the AverageVisitor using an expression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetAverage()Returns the average from the visitor's currentExpressiongetExpression()List<Expression>getExpressions()List of expressions used by visitor.CalcResultgetResult()Returns a CalcResult object (containing the Average)Optional<List<Class>>getResultType(List<Class> inputTypes)Returns the expected output type given the input type.voidinit(SimpleFeatureCollection collection)voidreset()Resets the "Average" strategy patternvoidsetValue(int newCount, Object newSum)voidsetValue(Object newAverage)voidvisit(Feature feature)Visit the provided feature.voidvisit(SimpleFeature feature)
-
-
-
Constructor Detail
-
AverageVisitor
public AverageVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterExceptionConstructor class for the AverageVisitor using AttributeDescriptor ID- Parameters:
attributeTypeIndex- integer representing the AttributeDescriptortype- FeatureType- Throws:
IllegalFilterException
-
AverageVisitor
public AverageVisitor(String attrName, SimpleFeatureType type) throws IllegalFilterException
Constructor class for the AverageVisitor using AttributeDescriptor Name- Parameters:
attrName- string respresenting the AttributeDescriptortype- FeatureType- Throws:
IllegalFilterException
-
AverageVisitor
public AverageVisitor(Expression expr) throws IllegalFilterException
Constructor class for the AverageVisitor using an expression- Throws:
IllegalFilterException
-
-
Method Detail
-
init
public void init(SimpleFeatureCollection collection)
-
getExpressions
public List<Expression> getExpressions()
Description copied from interface:FeatureAttributeVisitorList of expressions used by visitor.- Specified by:
getExpressionsin interfaceFeatureAttributeVisitor
-
getResultType
public Optional<List<Class>> getResultType(List<Class> inputTypes)
Description copied from interface:FeatureAttributeVisitorReturns the expected output type given the input type.- Specified by:
getResultTypein interfaceFeatureAttributeVisitor- Parameters:
inputTypes- The type of the input expressions
-
visit
public void visit(SimpleFeature feature)
-
visit
public void visit(Feature feature)
Description copied from interface:FeatureVisitorVisit the provided feature.Please consult the documentation for the FeatureCollection you are visiting to learn more - the provided feature may be invalid, or read only.
- Specified by:
visitin interfaceFeatureVisitor
-
getExpression
public Expression getExpression()
-
getAverage
public Object getAverage()
Returns the average from the visitor's current- Returns:
- the average
-
reset
public void reset()
Resets the "Average" strategy pattern
-
getResult
public CalcResult getResult()
Returns a CalcResult object (containing the Average)- Specified by:
getResultin interfaceFeatureCalc- Returns:
- the results of the calculation
-
setValue
public void setValue(Object newAverage)
-
setValue
public void setValue(int newCount, Object newSum)
-
-