Package org.opengis.test.report
Class Report
- 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:- Specified at construction time.
- Stored directly in the properties map by subclasses.
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
predefined Base URL of GeoAPI javadoc. FILENAME
predefined Name 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 inMETA-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 oneadd(…)
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 Properties
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 Locale
getLocale()
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.
-
-
-
Field Detail
-
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 anull
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 Detail
-
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, ornull
for the default values.
-
-
Method Detail
-
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 fromInternationalString
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:
InternationalString.toString(Locale)
,String.toLowerCase(Locale)
,NumberFormat.getNumberInstance(Locale)
-
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 aadd(…)
method, since they are usually slower thanwrite(File)
. Subclasses can override this method if they want to be notified about progress.- Parameters:
position
- a number ranging from 0 tocount
. This is typically the number or rows created so far for the HTML table to write.count
- the maximal expected value ofposition
. Note that this value may change between different invocations if the report gets a better estimation about the number of rows to be created.
-
-