de.grogra.xl.util
Class AggregateStateImpl<T>

java.lang.Object
  extended by de.grogra.xl.util.AggregateStateImpl<T>
All Implemented Interfaces:
AggregateState, BooleanAggregateState, ByteAggregateState, CharAggregateState, DoubleAggregateState, FloatAggregateState, IntAggregateState, LongAggregateState, ObjectAggregateState<T>, ShortAggregateState

public final class AggregateStateImpl<T>
extends java.lang.Object
implements BooleanAggregateState, ByteAggregateState, ShortAggregateState, CharAggregateState, IntAggregateState, LongAggregateState, FloatAggregateState, DoubleAggregateState, ObjectAggregateState<T>

Utility class which implements all AggregateState interfaces and provides some general fields for storing state. Instances of this class are pooled so that heap traffic is reduced.

Author:
Ole Kniemeyer

Field Summary
 T aval
          This field contains the result if the type is a reference type.
 java.lang.Object aval1
          This field may be used freely by aggregate methods.
 java.lang.Object aval2
          This field may be used freely by aggregate methods.
 java.lang.Object aval3
          This field may be used freely by aggregate methods.
 java.lang.Object aval4
          This field may be used freely by aggregate methods.
 double dval
          This field contains the result if the type is double.
 double dval1
          This field may be used freely by aggregate methods.
 double dval2
          This field may be used freely by aggregate methods.
 double dval3
          This field may be used freely by aggregate methods.
 double dval4
          This field may be used freely by aggregate methods.
 float fval
          This field contains the result if the type is float.
 float fval1
          This field may be used freely by aggregate methods.
 float fval2
          This field may be used freely by aggregate methods.
 float fval3
          This field may be used freely by aggregate methods.
 float fval4
          This field may be used freely by aggregate methods.
 int ival
          This field contains the result if the type is boolean, byte, short, char, or int.
 int ival1
          This field may be used freely by aggregate methods.
 int ival2
          This field may be used freely by aggregate methods.
 int ival3
          This field may be used freely by aggregate methods.
 int ival4
          This field may be used freely by aggregate methods.
 long lval
          This field contains the result if the type is long.
 long lval1
          This field may be used freely by aggregate methods.
 long lval2
          This field may be used freely by aggregate methods.
 long lval3
          This field may be used freely by aggregate methods.
 long lval4
          This field may be used freely by aggregate methods.
 
Method Summary
static AggregateStateImpl<?> allocate()
           
 boolean getBooleanResult()
          Returns the result of the aggregation.
 byte getByteResult()
          Returns the result of the aggregation.
 char getCharResult()
          Returns the result of the aggregation.
 double getDoubleResult()
          Returns the result of the aggregation.
 float getFloatResult()
          Returns the result of the aggregation.
 int getIntResult()
          Returns the result of the aggregation.
 long getLongResult()
          Returns the result of the aggregation.
 T getObjectResult()
          Returns the result of the aggregation.
 short getShortResult()
          Returns the result of the aggregation.
 boolean isFinished()
          Returns true to indicate the invoker of the aggregate method that the computation of the aggregate value has been completed by the aggregate method, even if there are values left for aggregation.
 void setFinished()
          Sets the finished-flag to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aval

public T aval
This field contains the result if the type is a reference type.


aval1

public java.lang.Object aval1
This field may be used freely by aggregate methods.


aval2

public java.lang.Object aval2
This field may be used freely by aggregate methods.


aval3

public java.lang.Object aval3
This field may be used freely by aggregate methods.


aval4

public java.lang.Object aval4
This field may be used freely by aggregate methods.


dval

public double dval
This field contains the result if the type is double.


dval1

public double dval1
This field may be used freely by aggregate methods.


dval2

public double dval2
This field may be used freely by aggregate methods.


dval3

public double dval3
This field may be used freely by aggregate methods.


dval4

public double dval4
This field may be used freely by aggregate methods.


fval

public float fval
This field contains the result if the type is float.


fval1

public float fval1
This field may be used freely by aggregate methods.


fval2

public float fval2
This field may be used freely by aggregate methods.


fval3

public float fval3
This field may be used freely by aggregate methods.


fval4

public float fval4
This field may be used freely by aggregate methods.


ival

public int ival
This field contains the result if the type is boolean, byte, short, char, or int.


ival1

public int ival1
This field may be used freely by aggregate methods.


ival2

public int ival2
This field may be used freely by aggregate methods.


ival3

public int ival3
This field may be used freely by aggregate methods.


ival4

public int ival4
This field may be used freely by aggregate methods.


lval

public long lval
This field contains the result if the type is long.


lval1

public long lval1
This field may be used freely by aggregate methods.


lval2

public long lval2
This field may be used freely by aggregate methods.


lval3

public long lval3
This field may be used freely by aggregate methods.


lval4

public long lval4
This field may be used freely by aggregate methods.

Method Detail

allocate

public static AggregateStateImpl<?> allocate()

getBooleanResult

public boolean getBooleanResult()
Description copied from interface: BooleanAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getBooleanResult in interface BooleanAggregateState
Returns:
aggregated value

getByteResult

public byte getByteResult()
Description copied from interface: ByteAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getByteResult in interface ByteAggregateState
Returns:
aggregated value

getCharResult

public char getCharResult()
Description copied from interface: CharAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getCharResult in interface CharAggregateState
Returns:
aggregated value

getDoubleResult

public double getDoubleResult()
Description copied from interface: DoubleAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getDoubleResult in interface DoubleAggregateState
Returns:
aggregated value

getFloatResult

public float getFloatResult()
Description copied from interface: FloatAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getFloatResult in interface FloatAggregateState
Returns:
aggregated value

getIntResult

public int getIntResult()
Description copied from interface: IntAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getIntResult in interface IntAggregateState
Returns:
aggregated value

getLongResult

public long getLongResult()
Description copied from interface: LongAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getLongResult in interface LongAggregateState
Returns:
aggregated value

getObjectResult

public T getObjectResult()
Description copied from interface: ObjectAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getObjectResult in interface ObjectAggregateState<T>
Returns:
aggregated value

getShortResult

public short getShortResult()
Description copied from interface: ShortAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with its finished argument set to true.

Specified by:
getShortResult in interface ShortAggregateState
Returns:
aggregated value

isFinished

public boolean isFinished()
Description copied from interface: AggregateState
Returns true to indicate the invoker of the aggregate method that the computation of the aggregate value has been completed by the aggregate method, even if there are values left for aggregation. E.g., this is the case for a short circuit implementation of the boolean or where the result is known when the first true-value is encountered. The invoker must not invoke the aggregate method again.

Specified by:
isFinished in interface AggregateState
Returns:
true iff the final aggregated value is already known

setFinished

public void setFinished()
Sets the finished-flag to true. Subsequent invocations of isFinished() will return true.