org.geotools.feature.visitor
Class AbstractCalcResult

java.lang.Object
  extended byorg.geotools.feature.visitor.AbstractCalcResult
All Implemented Interfaces:
CalcResult
Direct Known Subclasses:
AverageVisitor.AverageResult, BoundsVisitor.BoundsResult, CountVisitor.CountResult, MaxVisitor.MaxResult, MedianVisitor.MedianResult, MinVisitor.MinResult, SumVisitor.SumResult, UniqueVisitor.UniqueResult

public class AbstractCalcResult
extends java.lang.Object
implements CalcResult

An abstract implementation for CalcResults. Each subclass should implement its own getValue(), merge(), and constructor methods.

Since:
2.2.M2
Author:
Cory Horner, Refractions

Constructor Summary
AbstractCalcResult()
           
 
Method Summary
 java.lang.Object getValue()
          Actual answer
 boolean isCompatible(CalcResult targetResults)
          Returns true if the target results is a compatible type with the current results, with compatible meaning that the two results may be merged.
 CalcResult merge(CalcResult resultsToAdd)
          Returns the merged results of two CalcResult.
 java.lang.Object[] toArray()
          Access getValue as an array
 double toDouble()
          Access getValue as a double
 com.vividsolutions.jts.geom.Envelope toEnvelope()
          Access getValue as an envelope
 float toFloat()
          Access getValue as a float
 com.vividsolutions.jts.geom.Geometry toGeometry()
          Access getValue as a geometry
 int toInt()
          Access getValue as an int
 java.util.List toList()
          Access getValue as a list
 long toLong()
          Access getValue as a long
 java.util.Map toMap()
          Access getValue as a map
 com.vividsolutions.jts.geom.Point toPoint()
          Access getValue as a point
 java.util.Set toSet()
          Access getValue as a set
 java.lang.String toString()
          Access getValue as a string
 java.lang.String[] toStringArray()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractCalcResult

public AbstractCalcResult()
Method Detail

isCompatible

public boolean isCompatible(CalcResult targetResults)
Description copied from interface: CalcResult
Returns true if the target results is a compatible type with the current results, with compatible meaning that the two results may be merged.

Specified by:
isCompatible in interface CalcResult
Parameters:
targetResults - the second CalcResult Object
Returns:
true if the targetResults can be merged with the current results

merge

public CalcResult merge(CalcResult resultsToAdd)
Description copied from interface: CalcResult
Returns the merged results of two CalcResult. The way in which the results are merged is dependent on the type of the results added. A new instance is created containing the merged results.

For example: merging two min functions would return the smaller of the two values; merging a count and a sum would return an average.

Specified by:
merge in interface CalcResult
Parameters:
resultsToAdd -
Returns:
the merged results

getValue

public java.lang.Object getValue()
Description copied from interface: CalcResult
Actual answer

Specified by:
getValue in interface CalcResult
Returns:
the calculation result as a generic object

toInt

public int toInt()
Description copied from interface: CalcResult
Access getValue as an int

Specified by:
toInt in interface CalcResult
Returns:
the calculation result as a int (or 0 if not applicable)

toDouble

public double toDouble()
Description copied from interface: CalcResult
Access getValue as a double

Specified by:
toDouble in interface CalcResult
Returns:
the calculation result as a double (or 0 if not applicable)

toLong

public long toLong()
Description copied from interface: CalcResult
Access getValue as a long

Specified by:
toLong in interface CalcResult
Returns:
the calculation result as a long (or 0 if not applicable)

toFloat

public float toFloat()
Description copied from interface: CalcResult
Access getValue as a float

Specified by:
toFloat in interface CalcResult
Returns:
the calculation result as a float (or 0 if not applicable)

toGeometry

public com.vividsolutions.jts.geom.Geometry toGeometry()
Description copied from interface: CalcResult
Access getValue as a geometry

Specified by:
toGeometry in interface CalcResult
Returns:
the calculation result as a geometry (or null if not applicable)

toEnvelope

public com.vividsolutions.jts.geom.Envelope toEnvelope()
Description copied from interface: CalcResult
Access getValue as an envelope

Specified by:
toEnvelope in interface CalcResult
Returns:
the calculation result as an envelope (or null if not applicable)

toPoint

public com.vividsolutions.jts.geom.Point toPoint()
Description copied from interface: CalcResult
Access getValue as a point

Specified by:
toPoint in interface CalcResult
Returns:
the calculation result as a point (or null if not applicable)

toSet

public java.util.Set toSet()
Description copied from interface: CalcResult
Access getValue as a set

Specified by:
toSet in interface CalcResult
Returns:
the calculation result as a set (or null if not applicable)

toList

public java.util.List toList()
Description copied from interface: CalcResult
Access getValue as a list

Specified by:
toList in interface CalcResult
Returns:
the calculation result as a list (or null if not applicable)

toArray

public java.lang.Object[] toArray()
Description copied from interface: CalcResult
Access getValue as an array

Specified by:
toArray in interface CalcResult
Returns:
the calculation result as an array (or null if not applicable)

toStringArray

public java.lang.String[] toStringArray()

toMap

public java.util.Map toMap()
Description copied from interface: CalcResult
Access getValue as a map

Specified by:
toMap in interface CalcResult
Returns:
the calculation result as a map (or null if not applicable)

toString

public java.lang.String toString()
Description copied from interface: CalcResult
Access getValue as a string

Specified by:
toString in interface CalcResult


Copyright © GeoTools. All Rights Reserved.