sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Desruisseaux (JIRA)" <>
Subject [jira] [Created] (SIS-166) Replace repetition of private getter/setters in CRS classes by @XmlElements annotation
Date Wed, 19 Mar 2014 20:49:43 GMT
Martin Desruisseaux created SIS-166:

             Summary: Replace repetition of private getter/setters in CRS classes by @XmlElements
                 Key: SIS-166
             Project: Spatial Information Systems
          Issue Type: Task
          Components: Referencing
    Affects Versions: 0.4
            Reporter: Martin Desruisseaux
            Priority: Minor

Some CRS implementation classes in {{}} package contain many
private getter and setter methods for coordinate system marshalling/unmarshalling with JAXB.
For example {{DefaultEngineeringCRS}} has the following methods:

     * Invoked by JAXB at marshalling time.
    @XmlElement(name="affineCS")      private AffineCS      getAffineCS()      {return getCoordinateSystem(AffineCS
    @XmlElement(name="cartesianCS")   private CartesianCS   getCartesianCS()   {return getCoordinateSystem(CartesianCS
    @XmlElement(name="cylindricalCS") private CylindricalCS getCylindricalCS() {return getCoordinateSystem(CylindricalCS.class);}
    @XmlElement(name="linearCS")      private LinearCS      getLinearCS()      {return getCoordinateSystem(LinearCS
    @XmlElement(name="polarCS")       private PolarCS       getPolarCS()       {return getCoordinateSystem(PolarCS
    @XmlElement(name="sphericalCS")   private SphericalCS   getSphericalCS()   {return getCoordinateSystem(SphericalCS
    @XmlElement(name="userDefinedCS") private UserDefinedCS getUserDefinedCS() {return getCoordinateSystem(UserDefinedCS.class);}

     * Invoked by JAXB at unmarshalling time.
    private void setAffineCS     (final AffineCS      cs) {super.setCoordinateSystem("affineCS",
    private void setCartesianCS  (final CartesianCS   cs) {super.setCoordinateSystem("cartesianCS",
    private void setCylindricalCS(final CylindricalCS cs) {super.setCoordinateSystem("cylindricalCS",
    private void setLinearCS     (final LinearCS      cs) {super.setCoordinateSystem("linearCS",
    private void setPolarCS      (final PolarCS       cs) {super.setCoordinateSystem("polarCS",
    private void setSphericalCS  (final SphericalCS   cs) {super.setCoordinateSystem("sphericalCS",
    private void setUserDefinedCS(final UserDefinedCS cs) {super.setCoordinateSystem("userDefinedCS",

This is an ugly hack, since there is really only one coordinate system property, which may
have different names in a GML document depending of its type. A more elegant solution would
be to declare all the names in a single method, like below:

     * Returns the coordinate system.
     * @return The coordinate system.
      @XmlElement(name = "cartesianCS",   type = DefaultCartesianCS.class),
      @XmlElement(name = "affineCS",      type = DefaultAffineCS.class),
      @XmlElement(name = "cylindricalCS", type = DefaultCylindricalCS.class),
      @XmlElement(name = "linearCS",      type = DefaultLinearCS.class),
      @XmlElement(name = "polarCS",       type = DefaultPolarCS.class),
      @XmlElement(name = "sphericalCS",   type = DefaultSphericalCS.class),
      @XmlElement(name = "userDefinedCS", type = DefaultUserDefinedCS.class)
    public CoordinateSystem getCoordinateSystem() {
        return super.getCoordinateSystem();

     * Used by JAXB only (invoked by reflection).
    private void setCoordinateSystem(final CoordinateSystem cs) {
        super.setCoordinateSystem("coordinateSystem", cs);

However it didn't worked in our experiment. For a unknown reason, the unmarshalled coordinate
system was empty. We need more investigation about this problem in order to replace the hack
by the above-cited cleaner strategy.

This message was sent by Atlassian JIRA

View raw message