Package org.geotools.feature.visitor
Class SumVisitor
- Object
-
- SumVisitor
-
- All Implemented Interfaces:
FeatureVisitor
,FeatureAttributeVisitor
,FeatureCalc
- Direct Known Subclasses:
SumAreaVisitor
public class SumVisitor extends Object implements FeatureCalc, FeatureAttributeVisitor
Calculates the Sum of an attribute (of a FeatureVisitor)- Since:
- 2.2.M2
- Author:
- Cory Horner, Refractions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SumVisitor.SumResult
protected static interface
SumVisitor.SumStrategy
-
Constructor Summary
Constructors Constructor Description SumVisitor(int attributeTypeIndex, SimpleFeatureType type)
SumVisitor(String attrName, SimpleFeatureType type)
SumVisitor(Expression expr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression
getExpression()
List<Expression>
getExpressions()
List of expressions used by visitor.CalcResult
getResult()
Returns the result of the calculation as a handy object which can be merged and modified.Optional<List<Class>>
getResultType(List<Class> inputTypes)
Returns the expected output type given the input type.Object
getSum()
void
init(SimpleFeatureCollection collection)
void
reset()
protected void
setStrategy(SumVisitor.SumStrategy strategy)
void
setValue(Object newSum)
void
visit(Feature feature)
Visit the provided feature.void
visit(SimpleFeature feature)
-
-
-
Constructor Detail
-
SumVisitor
public SumVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterException
- Throws:
IllegalFilterException
-
SumVisitor
public SumVisitor(String attrName, SimpleFeatureType type) throws IllegalFilterException
- Throws:
IllegalFilterException
-
SumVisitor
public SumVisitor(Expression expr) throws IllegalFilterException
- Throws:
IllegalFilterException
-
-
Method Detail
-
setStrategy
protected void setStrategy(SumVisitor.SumStrategy strategy)
-
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()
-
getSum
public Object getSum()
-
setValue
public void setValue(Object newSum)
-
reset
public void reset()
-
getResult
public CalcResult getResult()
Description copied from interface:FeatureCalc
Returns the result of the calculation as a handy object which can be merged and modified.- Specified by:
getResult
in interfaceFeatureCalc
- Returns:
- the results of the calculation
-
-