01: package com.jamonapi;
02:
03: import java.util.*;
04: import com.jamonapi.utils.*;
05:
06: /** Buffer used to keep the last N recent array values based on the comparator. Note the Comparator must
07: * be thread safe. It can also stored the last n recent values of ToArray objects. By using various Comparators
08: * you can determine what should stay in the buffer and what should be removed. JAMon comes with a number of buffers
09: * based on this class.
10: * @author steve souza
11: *
12: */
13:
14: public class NExtremeArrayBufferHolder extends NExtremeBufferHolder {
15:
16: /** Constructor that takes a JAMonArrayComparator that can be used to determine
17: * when values should be removed from and added to the array. This can be used to
18: * decide what to do to values in the buffer based on multiple columns.
19: * @param comparator
20: */
21: public NExtremeArrayBufferHolder(JAMonArrayComparator comparator) {
22: super (true);
23: setComparator(comparator);
24: }
25:
26: /** Pass true for natural order, and false for reverse order and column number in Object[] to compare starting at 0 */
27: public NExtremeArrayBufferHolder(boolean naturalOrder,
28: int colToCompare) {
29: super (new JAMonArrayComparator(colToCompare, naturalOrder));
30: }
31:
32: /** Note the only valid Comparator to be passed is JAMonArrayComparator */
33: public void setComparator(Comparator comparator) {
34: if (comparator instanceof JAMonArrayComparator)
35: super .setComparator(comparator);
36: }
37:
38: /** Factory method that returns a usable copy of this object */
39: public BufferHolder copy() {
40: return new NExtremeArrayBufferHolder(
41: (JAMonArrayComparator) getComparator());
42: }
43:
44: }
|