com.partnersoft.reports
Class DataRecordSourceReportBuilder

java.lang.Object
  extended by com.partnersoft.reports.DataRecordSourceReportBuilder

public class DataRecordSourceReportBuilder
extends java.lang.Object

Report Builder for DataRecordSources. Has helpers for parsing records and building html reports.

Copyright 2008 Partner Software

Author:
Rich Stepanski

Constructor Summary
DataRecordSourceReportBuilder(DataRecordSource data)
          Creates a new DataRecordSourceReportBuilder for the passed DataRecordSource.
DataRecordSourceReportBuilder(java.util.List<Naming> records)
          Creates a new DataRecordSourceReportBuilder for the passed list of Namings.
 
Method Summary
 java.lang.String buildHtmlReport(java.lang.String docName)
          Generates an html report containing a table with all fields
 java.lang.String buildHtmlReport(java.lang.String docName, int... fieldIndex)
          Generates an html report containing a table with only the field indexes passed as parameters.
 java.lang.String buildHtmlReport(java.lang.String docName, java.lang.String... fieldNames)
          Generates an html report containing a table with only the fields passed as parameters.
 java.lang.String buildHtmlTable()
          Generates an html table containing all fields
 java.lang.String buildHtmlTable(int... fieldIndex)
          Generates an html table with only the fields whose indexes were passed as parameters.
 java.lang.String buildHtmlTable(java.lang.String... fieldNames)
          Generates an html table containing only the fields passed as parameters.
 int countField(java.lang.String fieldName, java.lang.Object value)
          Returns the total # of occurrences of the passed field name with the passed value in the data record source.
 java.util.List<Naming> filterData(int... fieldIndex)
          Returns a list of Namings containing only the field indexes passed in.
 java.util.List<Naming> filterData(java.lang.String... fieldName)
          Returns a list of Namings containing only the fields passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRecordSourceReportBuilder

public DataRecordSourceReportBuilder(DataRecordSource data)
Creates a new DataRecordSourceReportBuilder for the passed DataRecordSource. Constructor will iterate through the record source and save a copy of the data for future use. Some DataRecordSources only allow single iterations.

Parameters:
data - - A DataRecordSource.

DataRecordSourceReportBuilder

public DataRecordSourceReportBuilder(java.util.List<Naming> records)
Creates a new DataRecordSourceReportBuilder for the passed list of Namings. Treats the passed list as it would an iterated DataRecordSource, with each Naming having the same key names.

Method Detail

filterData

public java.util.List<Naming> filterData(java.lang.String... fieldName)
Returns a list of Namings containing only the fields passed in. Returned Namings use field names for keys.

Parameters:
fieldName - - Any field name to include in returned value.
Returns:
Naming of records containing only passed field names.

filterData

public java.util.List<Naming> filterData(int... fieldIndex)
Returns a list of Namings containing only the field indexes passed in. Returned Namings use field names for keys.

Parameters:
fieldIndex - - Any field index to include in returned value.
Returns:
Naming of records containing only passed field indexes.

buildHtmlReport

public java.lang.String buildHtmlReport(java.lang.String docName,
                                        java.lang.String... fieldNames)
Generates an html report containing a table with only the fields passed as parameters.

Parameters:
docName - - String name to give to document.
fieldNames - - Field names to show in report.
Returns:
- String html for report.

buildHtmlReport

public java.lang.String buildHtmlReport(java.lang.String docName)
Generates an html report containing a table with all fields

Parameters:
docName - - String name to give to document.
Returns:
- String html for report.

buildHtmlReport

public java.lang.String buildHtmlReport(java.lang.String docName,
                                        int... fieldIndex)
Generates an html report containing a table with only the field indexes passed as parameters.

Parameters:
docName - - String name to give to document.
fieldIndex - - Field indexes to show in report.
Returns:
- String html for report.

buildHtmlTable

public java.lang.String buildHtmlTable(int... fieldIndex)
Generates an html table with only the fields whose indexes were passed as parameters.

Parameters:
fieldIndex - - Field indexes to show in report.
Returns:
- String html for table.

buildHtmlTable

public java.lang.String buildHtmlTable(java.lang.String... fieldNames)
Generates an html table containing only the fields passed as parameters.

Parameters:
fieldNames - - Field names to show in report.
Returns:
- String html for table.

buildHtmlTable

public java.lang.String buildHtmlTable()
Generates an html table containing all fields

Returns:
- String html for table.

countField

public int countField(java.lang.String fieldName,
                      java.lang.Object value)
Returns the total # of occurrences of the passed field name with the passed value in the data record source. Uses .equals() to compare.

Parameters:
fieldName - - Field name to look for.
value - - Value to track in records.
Returns:
- Total # of times field name equals value.