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 class
AverageVisitor.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 Object
getAverage()
Returns the average from the visitor's currentExpression
getExpression()
List<Expression>
getExpressions()
List of expressions used by visitor.CalcResult
getResult()
Returns a CalcResult object (containing the Average)Optional<List<Class>>
getResultType(List<Class> inputTypes)
Returns the expected output type given the input type.void
init(SimpleFeatureCollection collection)
void
reset()
Resets the "Average" strategy patternvoid
setValue(int newCount, Object newSum)
void
setValue(Object newAverage)
void
visit(Feature feature)
Visit the provided feature.void
visit(SimpleFeature feature)
-
-
-
Constructor Detail
-
AverageVisitor
public AverageVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterException
Constructor 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:FeatureAttributeVisitor
List of expressions used by visitor.- Specified by:
getExpressions
in interfaceFeatureAttributeVisitor
-
getResultType
public Optional<List<Class>> getResultType(List<Class> inputTypes)
Description copied from interface:FeatureAttributeVisitor
Returns the expected output type given the input type.- Specified by:
getResultType
in 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:FeatureVisitor
Visit 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:
visit
in 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:
getResult
in interfaceFeatureCalc
- Returns:
- the results of the calculation
-
setValue
public void setValue(Object newAverage)
-
setValue
public void setValue(int newCount, Object newSum)
-
-