org.jfree.report.modules.output.pageable.base
public class: ReportStateList [javadoc |
source]
java.lang.Object
org.jfree.report.modules.output.pageable.base.ReportStateList
The ReportState list stores a report states for the beginning of every page.
The list is filled on repagination and read when a report or a page of the report
is printed.
Important: This list stores page start report states, not arbitary report states.
These ReportStates are special: they can be reproduced by calling processPage on the report.
Internally this list is organized as a list of WeakReferenceLists, where every WeakReferenceList
stores a certain number of page states. The first 20 states are stored in an ordinary
list with strong-references, so these states never get GarbageCollected (and so
they must never be restored by reprocessing them). The next 100 states are stored
in 4-element ReferenceLists, so if a reference is lost, only 4 states have to be
reprocessed. All other states are stored in 10-element lists.
| Constructor: |
public ReportStateList(PageableReportProcessor proc) throws OutputTargetException {
if (proc == null)
{
throw new NullPointerException("ReportProcessor null");
}
// this.report = report;
this.proc = proc;
dummyWriter = proc.getOutputTarget().createDummyWriter();
dummyWriter.open();
primaryStates = new ArrayList();
masterStates4 = new ArrayList();
masterStates10 = new ArrayList();
}
Creates a new reportstatelist. The list will be filled using the specified report
and output target. Filling of the list is done elsewhere. Parameters:
proc - the reportprocessor used to restore lost states (null not permitted).
Throws:
OutputTargetException - if there is a problem with the output target.
NullPointerException - if the report processor is null.
|
| Method from org.jfree.report.modules.output.pageable.base.ReportStateList Detail: |
public void add(ReportState state) {
if (state == null)
{
throw new NullPointerException();
}
if (state.isFinish())
{
throw new IllegalArgumentException();
}
// the first 20 Elements are stored directly into an ArrayList
if (size() < PRIMARY_MAX)
{
primaryStates.add(state);
this.size++;
}
// the next 100 Elements are stored into a list of 4-element weakReference
//list. So if an Element gets lost (GCd), only 4 states need to be replayed.
else if (size() < MASTER4_MAX)
{
final int secPos = size() - PRIMARY_MAX;
final int masterPos = getMasterPos(secPos, MASTERPOSITIONS_MED);
if (masterPos >= masterStates4.size())
{
final MasterList master = new MasterList(this, MASTERPOSITIONS_MED);
masterStates4.add(master);
master.add(state);
}
else
{
final MasterList master = (MasterList) masterStates4.get(masterPos);
master.add(state);
}
this.size++;
}
// all other Elements are stored into a list of 10-element weakReference
//list. So if an Element gets lost (GCd), 10 states need to be replayed.
else
{
final int thirdPos = size() - MASTER4_MAX;
final int masterPos = getMasterPos(thirdPos, MASTERPOSITIONS_MAX);
if (masterPos >= masterStates10.size())
{
final MasterList master = new MasterList(this, MASTERPOSITIONS_MAX);
masterStates10.add(master);
master.add(state);
}
else
{
final MasterList master = (MasterList) masterStates10.get(masterPos);
master.add(state);
}
this.size++;
}
}
Adds this report state to the end of the list. |
public void clear() {
masterStates10.clear();
masterStates4.clear();
primaryStates.clear();
this.size = 0;
}
Removes all elements in the list. |
public ReportState get(int index) {
if (index >= size() || index < 0)
{
throw new IndexOutOfBoundsException
("Index is invalid. Index was " + index + "; size was " + size());
}
if (index < PRIMARY_MAX)
{
return (ReportState) primaryStates.get(index);
}
else if (index < MASTER4_MAX)
{
index -= PRIMARY_MAX;
final MasterList master
= (MasterList) masterStates4.get(getMasterPos(index, MASTERPOSITIONS_MED));
return (ReportState) master.get(index);
}
else
{
index -= MASTER4_MAX;
final MasterList master
= (MasterList) masterStates10.get(getMasterPos(index, MASTERPOSITIONS_MAX));
return (ReportState) master.get(index);
}
}
Retrieves the element on position index in this list. |
protected OutputTarget getDummyWriter() {
return dummyWriter;
}
Returns the dummy output target. |
protected PageableReportProcessor getReportProcessor() {
return proc;
}
Returns the used report processor. |
public int size() {
return this.size;
}
Returns the number of elements in this list. |