[geotk] [JIRA] Created: (GEOTK-70) Need to recover from incomplete definition of referencing object from XML

Martin Desruisseaux (JIRA) jira at geomatys.com
Tue Dec 8 12:56:05 EST 2009


Need to recover from incomplete definition of referencing object from XML
-------------------------------------------------------------------------

                 Key: GEOTK-70
                 URL: http://jira.geotoolkit.org/browse/GEOTK-70
             Project: Geotoolkit
          Issue Type: Improvement
          Components: Referencing
    Affects Versions: 3.06
            Reporter: Martin Desruisseaux
            Assignee: Martin Desruisseaux
            Priority: Minor


Parsing a referencing objects from a XML stream with JAXB happen in two steps:

* The default constructor is invoked by JAXB, which initialize the datum and coordinate system fields to the {{NullReferencingObject}} object. Note that this is *not* the {{null}} value.
* JAXB invokes the various setter methods in order to give the final values to the datum and coordinate system fields.

However if some elements are missing in the XML stream, for example if a {{CoordinateReferenceSystem}} does not contain a {{Datum}} element, then the corresponding field is left to {{NullReferencingObject}}. Attempts to format the object produce the following exception:

{noformat}
org.geotoolkit.io.wkt.UnformattableObjectException: La classe 'NullReferencingObject' est illégale. Il doit s'agir d'une classe 'Formattable' ou dérivée.
    at org.geotoolkit.io.wkt.Formatter.unsupported(Formatter.java:466)
    at org.geotoolkit.io.wkt.Formatter.append(Formatter.java:441)
    at org.geotoolkit.referencing.crs.AbstractSingleCRS.formatDefaultWKT(AbstractSingleCRS.java:211)
    at org.geotoolkit.referencing.crs.DefaultVerticalCRS.formatWKT(DefaultVerticalCRS.java:215)
    at org.geotoolkit.io.wkt.Formatter.append(Formatter.java:381)
    at org.geotoolkit.io.wkt.FormattableObject.formatWKT(FormattableObject.java:260)
    at org.geotoolkit.io.wkt.FormattableObject.toString(FormattableObject.java:175)
    at java.lang.String.valueOf(String.java:2826)
{noformat}

The proposed fix is to implement the following package-private method, which would check if there is any remaining uninitialized field:

{code:java}
void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
    // Check datum and coordinate system fields here.
}
{code}

If uninitialized fields are found, the action to take (throw an exception or set default values) is still to be determined.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.geotoolkit.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


More information about the Geotoolkit mailing list