Object
Report
Direct Known Subclasses:
AuthorityCodesReport, OperationParametersReport, Reports

public abstract class Report extends Object
Base class for tools generating reports as HTML pages. The reports are based on HTML templates with a few keywords to be replaced by user-provided values. The values associated to keywords can be specified in two ways: The set of keywords, and whether a user-provided value for a given keyword is mandatory or optional, is subclass-specific. However, most subclasses expect at least the following keywords:
Report properties
Key Remarks Meaning
TITLE Title of the web page to produce.
DATE automatic Date of report creation.
DESCRIPTION optional Description to write after the introductory paragraph.
OBJECTS.KIND Kind of objects listed in the page (e.g. "Operation Methods").
PRODUCT.NAME Name of the product for which the report is generated.
PRODUCT.VERSION Version of the product for which the report is generated.
PRODUCT.URL URL where more information is available about the product.
JAVADOC.GEOAPI predefinedBase URL of GeoAPI javadoc.
FILENAME predefinedName of the file to create if the write(File) argument is a directory.

How to use this class:

  • Create a Properties map with the values documented in the subclass to be instantiated. Default values exist for many keys, but those defaults may depend on the environment (information found in META-INF/MANIFEST.MF, etc). It is safer to specify values explicitly when they are known.
  • Create a new instance of the Report subclass with the above properties map given to the constructor.
  • All Report subclasses define at least one add(…) method for declaring the objects to include in the HTML page. At least one object or factory needs to be declared.
  • Invoke write(File).
Since:
3.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Properties
    The values to substitute to keywords in the HTML templates.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Report(Properties properties)
    Creates a new report generator using the given property values.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the locale to use for producing messages in the reports.
    protected void
    progress(int position, int count)
    Invoked when the report is making some progress.
    abstract File
    write(File destination)
    Generates the HTML report in the given file or directory.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • properties

      protected final Properties properties
      The values to substitute to keywords in the HTML templates. This map is initialized to a copy of the map given by the user at construction time, or to an empty map if the user gave a null map. Subclasses can freely add, edit or remove entries in this map.

      The list of expected entries and their default values (if any) are subclass-specific. See the subclass javadoc for a list of expected values.

  • Constructor Details

    • Report

      protected Report(Properties properties)
      Creates a new report generator using the given property values. The list of expected entries is subclass specific and shall be documented in their javadoc.
      Parameters:
      properties - the property values, or null for the default values.
  • Method Details

    • getLocale

      public Locale getLocale()
      Returns the locale to use for producing messages in the reports. The locale may be used for fetching the character sequences from InternationalString objects, for converting to lower-cases or for formatting numbers.

      The locale is fixed to English for now, but may become modifiable in a future version.

      Returns:
      the locale to use for formatting messages.
      See Also:
    • write

      public abstract File write(File destination) throws IOException
      Generates the HTML report in the given file or directory. If the given argument is a directory, then the path will be completed with the "FILENAME" properties value if any, or an implementation specific default filename otherwise.

      Note that the target directory must exist; this method does not create any new directory.

      Parameters:
      destination - the destination file or directory. If this file already exists, then its content will be overwritten without warning.
      Returns:
      the file to the HTML page generated by this report. This is usually the given destination argument, unless the destination was a directory.
      Throws:
      IOException - if an error occurred while writing the report.
    • progress

      protected void progress(int position, int count)
      Invoked when the report is making some progress. This is typically invoked from a add(…) method, since they are usually slower than write(File). Subclasses can override this method if they want to be notified about progress.
      Parameters:
      position - a number ranging from 0 to count. This is typically the number or rows created so far for the HTML table to write.
      count - the maximal expected value of position. Note that this value may change between different invocations if the report gets a better estimation about the number of rows to be created.