jimm.datavision
Class Group

java.lang.Object
  extended by jimm.datavision.Group
All Implemented Interfaces:
Writeable

public class Group
extends java.lang.Object
implements Writeable

A group uses a Selectable object to define record grouping. A group may contain multiple header and footer sections.

Author:
Jim Menard, jimm@io.com

Field Summary
protected  boolean firstValue
           
protected  SectionArea footers
           
protected  SectionArea headers
           
protected  boolean newValue
           
protected  int recordCount
           
protected  Report report
           
protected  Selectable selectable
           
static int SORT_ASCENDING
          Sort records by the group's selectable in ascending order (the default).
static int SORT_DESCENDING
          Sort records by the group's selectable in descending order.
protected  int sortOrder
           
protected  java.lang.Object value
           
 
Constructor Summary
Group(Report report, Selectable selectable)
          Constructor.
 
Method Summary
 boolean contains(Section s)
          Returns true if the specified section is inside this group, either as a header or a footer.
static Group create(Report report, Selectable selectable)
          Creates a new group and gives it a header section containing a selectable field and an empty footer section.
 SectionArea footers()
          Returns the footers.
 void forceFooterOutput()
          Layout engines need to call this method when a group's footer is being output not because this group has a new value but because some previous group's value changed and we want to output this group's footer.
 int getRecordCount()
          Returns the number of records in the group so far.
 Selectable getSelectable()
          Returns the selectable used by this group.
 java.lang.String getSelectableName()
           
 int getSortOrder()
          Returns the sort order (either SORT_ASCENDING or SORT_DESCENDING).
 java.lang.Object getValue()
          Returns the value of this group's selectable.
 SectionArea headers()
          Returns the headers.
 boolean isFirstValue()
          Returns true when this is the first value ever seen by the group during a report run.
 boolean isNewValue()
          Returns true when the value of the selectable has changed.
 void reloadSelectable(DataSource dataSource)
          Reloads reference to selectable.
 void reset()
          Called by a report when it starts running, this method prepares the group for use.
 void setSelectable(Selectable newSelectable)
          Sets the selectable used by this group.
 void setSortOrder(int newSortOrder)
          Sets the sort order.
 void setValue(Report report)
          Sets the group value that is returned by getValue.
static java.lang.String sortOrderIntToString(int order)
           
static int sortOrderStringToInt(java.lang.String order)
           
 void updateCounter()
           
 void writeXML(XMLWriter out)
          Writes this group as an XML tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SORT_ASCENDING

public static final int SORT_ASCENDING
Sort records by the group's selectable in ascending order (the default).

See Also:
Constant Field Values

SORT_DESCENDING

public static final int SORT_DESCENDING
Sort records by the group's selectable in descending order.

See Also:
Constant Field Values

report

protected Report report

headers

protected SectionArea headers

footers

protected SectionArea footers

selectable

protected Selectable selectable

sortOrder

protected int sortOrder

value

protected java.lang.Object value

newValue

protected boolean newValue

firstValue

protected boolean firstValue

recordCount

protected int recordCount
Constructor Detail

Group

public Group(Report report,
             Selectable selectable)
Constructor.

Parameters:
report - a report
selectable - a selectable thingie
Method Detail

create

public static Group create(Report report,
                           Selectable selectable)
Creates a new group and gives it a header section containing a selectable field and an empty footer section.

Parameters:
report - a report
selectable - a selectable object
Returns:
a new group with a header section containing a column field and an empty footer section

sortOrderIntToString

public static java.lang.String sortOrderIntToString(int order)

sortOrderStringToInt

public static int sortOrderStringToInt(java.lang.String order)

getSelectable

public Selectable getSelectable()
Returns the selectable used by this group.

Returns:
a selectable

setSelectable

public void setSelectable(Selectable newSelectable)
Sets the selectable used by this group.

Parameters:
newSelectable - the new selectable

reloadSelectable

public void reloadSelectable(DataSource dataSource)
Reloads reference to selectable.


getSelectableName

public java.lang.String getSelectableName()

getSortOrder

public int getSortOrder()
Returns the sort order (either SORT_ASCENDING or SORT_DESCENDING).

Returns:
either SORT_ASCENDING or SORT_DESCENDING

setSortOrder

public void setSortOrder(int newSortOrder)
Sets the sort order.

Parameters:
newSortOrder - either SORT_ASCENDING or SORT_DESCENDING

getValue

public java.lang.Object getValue()
Returns the value of this group's selectable. Only valid while the report is running.

Returns:
the value of the selectable; undefined when the report is not running

setValue

public void setValue(Report report)
Sets the group value that is returned by getValue. This method should only be called by the report while it is running.

Parameters:
report - the report from which we retrieve our selectable's value

updateCounter

public void updateCounter()

isNewValue

public boolean isNewValue()
Returns true when the value of the selectable has changed.

Returns:
true when the value of the selectable has changed

getRecordCount

public int getRecordCount()
Returns the number of records in the group so far.

Returns:
the number of records in the group so far

forceFooterOutput

public void forceFooterOutput()
Layout engines need to call this method when a group's footer is being output not because this group has a new value but because some previous group's value changed and we want to output this group's footer.

See Also:
LayoutEngine.groupFooters(boolean)

isFirstValue

public boolean isFirstValue()
Returns true when this is the first value ever seen by the group during a report run.

Returns:
true if this is the first value ever seen

headers

public SectionArea headers()
Returns the headers.

Returns:
the headers section area

footers

public SectionArea footers()
Returns the footers.

Returns:
the footers section area

contains

public boolean contains(Section s)
Returns true if the specified section is inside this group, either as a header or a footer.

Parameters:
s - a section
Returns:
true if the section is within this group

reset

public void reset()
Called by a report when it starts running, this method prepares the group for use.


writeXML

public void writeXML(XMLWriter out)
Writes this group as an XML tag. Asks each section to write itself as well.

Specified by:
writeXML in interface Writeable
Parameters:
out - a writer that knows how to write XML