private class GenericFrame.AggregateHandler extends java.lang.Object implements Finalizable
AggregatorElements
associated with the enclosing
frame instance. An array of such elements is provided at construction
and is stored. The constructor registers a new instance with the
TransactionManager
at the nearest enclosing loop. Each
invocation of the enclosing frame's display
method causes
all associated accumulators to accumulate the data associated with that
pass of the loop. At the bottom of each iteration of the loop, this
object checks whether any of its managed accumulators is currently at
the last row in a break group. If so, sub-results are displayed. At
the end of loop, final results of all accumulators which support such a
result are displayed.Modifier and Type | Class and Description |
---|---|
private class |
GenericFrame.AggregateHandler.AggregatorElementComparator
A comparator implementation which compares
AggregatorElement s using only the weights of their
contained Accumulator instances. |
Modifier and Type | Field and Description |
---|---|
private java.util.LinkedHashSet<AggregatorElement> |
accums
All aggregator elements handled by this object
|
private java.util.Comparator<AggregatorElement> |
comparator
Comparator used to sort AggregatorElements
|
private boolean |
displayed
If
true then last operation was display() rather than
accumulate(). |
private java.util.List<AggregatorElement> |
fulls
Elements which need to be displayed on finished processing
|
private int |
lastDown
Number of lines in last DOWN call.
|
private java.util.List<AggregatorElement> |
subs
Elements which need to be displayed on next iteration
|
Constructor and Description |
---|
AggregateHandler(AggregatorElement[] accums)
Construct a new instance, detecting which of the given aggregator
elements must produce a "final" result line at loop termination.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
accumulate(FrameElement[] fe)
Get the current value for all data being accumulated and cause each
registered accumulator to accumulate these data.
|
void |
deleted()
Processes the deleted notification provided by the
ProcedureManager . |
private void |
display(java.util.List<AggregatorElement> accums)
Display aggregation results, either for a single break group, or for
the entire set of rows displayed by a display loop.
|
void |
finished()
Display full results (if any).
|
private int[] |
getIDs(java.util.List<AggregatorElement> accums,
boolean handleFulls)
Convert list of
AggregatorElement instances into array of
widget IDs. |
void |
iterate()
Display break group results (if any).
|
void |
notifyDown(int lines)
Frame calls this method to notify handler about last down() call.
|
void |
retry()
Processes the retry notification provided by the
TransactionManager . |
void |
verifyAccumulators(AggregatorElement[] elem)
Compare provided array of accumulator elements with set of known ones
and add ones which are not yet known.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initFailure
private java.util.LinkedHashSet<AggregatorElement> accums
private java.util.List<AggregatorElement> fulls
private java.util.List<AggregatorElement> subs
private java.util.Comparator<AggregatorElement> comparator
private int lastDown
private boolean displayed
true
then last operation was display() rather than
accumulate().AggregateHandler(AggregatorElement[] accums)
accums
- All aggregator elements to be managed by this handler.java.lang.IllegalStateException
- if no enclosing, looping block can be identified to which
to register this Finalizable
.public void notifyDown(int lines)
lines
- Number of lines passed to down().public void verifyAccumulators(AggregatorElement[] elem)
elem
- Array of AggregatorElement
instances to verify.void accumulate(FrameElement[] fe)
If this handler is not managing any aggregators, this method returns immediately.
fe
- Array of frame elements.public void iterate()
TransactionManager
at the top of the second and
subsequent loop iteration. This means that the handler has had a
chance to accumulate the current row's results.iterate
in interface Finalizable
public void retry()
TransactionManager
. This implementation does nothing.retry
in interface Finalizable
public void deleted()
ProcedureManager
.
This implementation does nothing.deleted
in interface Finalizable
public void finished()
TransactionManager
after the display loop terminates,
after the handler has had a chance to accumulate the final row's
results.
This method resets the enclosing frame's aggregate handler reference.
finished
in interface Finalizable
private int[] getIDs(java.util.List<AggregatorElement> accums, boolean handleFulls)
AggregatorElement
instances into array of
widget IDs.accums
- List of elements.handleFulls
- Flag which indicates processing of final results.private void display(java.util.List<AggregatorElement> accums)
accums
- List of aggregator elements to display.