Package org.opengis.test.report
Class AuthorityCodesReport
-
public class AuthorityCodesReport extends Report
Generates a list of object identified by authority codes for a given authority factory.This class recognizes the following property values. Note that default values are automatically generated for the
"COUNT.*"and"PERCENT.*"entries.Report properties Key Remarks Meaning TITLETitle of the web page to produce. DESCRIPTIONoptional Description to write after the introductory paragraph. OBJECTS.KINDKind of objects listed in the page (e.g. "Coordinate Reference Systems"). FACTORY.NAMEThe name of the authority factory. FACTORY.VERSIONThe version of the authority factory. FACTORY.VERSION.SUFFIXoptional An optional text to write after the factory version (in the main text only). PRODUCT.NAMEName of the product for which the report is generated. PRODUCT.VERSIONVersion of the product for which the report is generated. PRODUCT.VERSION.SUFFIXoptional An optional text to write after the product version (in the main text only). PRODUCT.URLURL where more information is available about the product. JAVADOC.GEOAPIpredefined Base URL of GeoAPI javadoc. COUNT.OBJECTSautomatic Number of identified objects. PERCENT.VALIDSautomatic Percentage of objects successfully created (i.e. having no error). PERCENT.ANNOTATEDautomatic Percentage of objects having an annotation. PERCENT.DEPRECATEDautomatic Percentage of deprecated objects. FILENAMEpredefined Name of the file to create if the write(File)argument is a directory.How to use this class:
- Create a
Propertiesmap with the values documented in the above table. Default values exist for many keys, but may depend on the environment. It is safer to specify values explicitly when they are known, except the automatic ones. - Create a new
AuthorityCodesReportwith the above properties map given to the constructor. - Invoke one of the
add(…)methods for the factory of identified objects to include in the HTML page. - Invoke
write(File).
- Since:
- 3.1
- Create a
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAuthorityCodesReport.RowA single row in the table produced byAuthorityCodesReport.
-
Field Summary
Fields Modifier and Type Field Description protected List<AuthorityCodesReport.Row>rowsThe list of objects identified by the codes declared by the authority factory.-
Fields inherited from class Report
properties
-
-
Constructor Summary
Constructors Constructor Description AuthorityCodesReport(Properties properties)Creates a new report generator using the given property values.
-
Method Summary
Modifier and Type Method Description voidadd(AuthorityFactory factory, Collection<String> codes)Adds the objects identified by the given codes.voidadd(CRSAuthorityFactory factory)Adds the Coordinate Reference Systems identified by all codes available from the given CRS authority factory.protected AuthorityCodesReport.RowcreateRow(String code, IdentifiedObject object)Creates a new row for the given authority code and identified object.protected AuthorityCodesReport.RowcreateRow(String code, FactoryException exception)Creates a new row for the given authority code and exception.protected AuthorityCodesReport.RownewRow()Returns a newAuthorityCodesReport.Rowinstance.protected voidsortRows()Sorts the rows before to write them.Filewrite(File destination)Formats the identified objects as a HTML page in the given file.
-
-
-
Field Detail
-
rows
protected final List<AuthorityCodesReport.Row> rows
The list of objects identified by the codes declared by the authority factory. Elements are added in this list by any of theaddmethods.
-
-
Constructor Detail
-
AuthorityCodesReport
public AuthorityCodesReport(Properties properties)
Creates a new report generator using the given property values. See the class javadoc for a list of expected values.- Parameters:
properties- the property values, ornullfor the default values.
-
-
Method Detail
-
add
public void add(CRSAuthorityFactory factory) throws FactoryException
Adds the Coordinate Reference Systems identified by all codes available from the given CRS authority factory. This method performs the following steps:- Get the list of available codes for type
CoordinateReferenceSystemwithAuthorityFactory.getAuthorityCodes(Class). - For each code, try to instantiate an object with
CRSAuthorityFactory.createCoordinateReferenceSystem(String), then:- In case of success, invoke
createRow(String, IdentifiedObject); - In case of failure, invoke
createRow(String, FactoryException).
- In case of success, invoke
- If the
createRow(…)method returned a non-null instance, add the created row to therowslist.
createRow(…)methods in order to customize the table content.- Parameters:
factory- the factory from which to get Coordinate Reference System instances.- Throws:
FactoryException- if a non-recoverable error occurred while querying the factory.
- Get the list of available codes for type
-
add
public void add(AuthorityFactory factory, Collection<String> codes) throws FactoryException
Adds the objects identified by the given codes. This method performs the following steps:- For each code, try to instantiate an object with
AuthorityFactory.createObject(String), then:- In case of success, invoke
createRow(String, IdentifiedObject); - In case of failure, invoke
createRow(String, FactoryException).
- In case of success, invoke
- If the
createRow(…)method returned a non-null instance, add the created row to therowslist.
createRow(…)methods in order to customize the table content.- Parameters:
factory- the factory from which to get the objects.codes- the authority codes of the objects to create.- Throws:
FactoryException- if a non-recoverable error occurred while querying the factory.
- For each code, try to instantiate an object with
-
newRow
protected AuthorityCodesReport.Row newRow()
Returns a newAuthorityCodesReport.Rowinstance. Subclasses can override this method if they wish to instantiate a subclass ofRow.- Returns:
- the new, initially empty,
Rowinstance.
-
createRow
protected AuthorityCodesReport.Row createRow(String code, IdentifiedObject object)
Creates a new row for the given authority code and identified object. Subclasses can override this method in order to customize the table content.- Parameters:
code- the authority code of the created object.object- the object created from the given authority code.- Returns:
- the created row, or
nullif the row should be ignored.
-
createRow
protected AuthorityCodesReport.Row createRow(String code, FactoryException exception)
Creates a new row for the given authority code and exception. Subclasses can override this method in order to customize the table content.- Parameters:
code- the authority code of the object to create.exception- the exception that occurred while creating the identified object.- Returns:
- the created row, or
nullif the row should be ignored.
-
sortRows
protected void sortRows()
Sorts the rows before to write them. The default implementation sort the rows by their natural ordering. Subclasses can override this method if they want to sort the rows otherwise, or if they want to add or remove rows before or after the sorting.
-
write
public File write(File destination) throws IOException
Formats the identified objects as a HTML page in the given file.- Specified by:
writein classReport- Parameters:
destination- the file to generate.- Returns:
- the given
destinationfile. - Throws:
IOException- if an error occurred while writing the report.
-
-