sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1641531 - in /sis/trunk: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintena...
Date Tue, 25 Nov 2014 06:14:51 GMT
Author: desruisseaux
Date: Tue Nov 25 06:14:50 2014
New Revision: 1641531

URL: http://svn.apache.org/r1641531
Log:
Merge from the JDK6 branch.

Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK8:r1640668-1641527
  Merged /sis/branches/JDK7:r1640671-1641528
  Merged /sis/branches/JDK6:r1640673-1641529

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -108,17 +108,6 @@ public class DefaultBand extends Default
     private Integer toneGradation;
 
     /**
-     * Smallest distance between which separate points can be distinguished, as specified
in
-     * instrument design.
-     */
-    private Double nominalSpatialResolution;
-
-    /**
-     * Type of transfer function to be used when scaling a physical value for a given element.
-     */
-    private TransferFunctionType transferFunctionType;
-
-    /**
      * Polarization of the radiation transmitted.
      */
     private PolarizationOrientation transmittedPolarization;
@@ -162,8 +151,6 @@ public class DefaultBand extends Default
             peakResponse             = object.getPeakResponse();
             toneGradation            = object.getToneGradation();
             bandBoundaryDefinition   = object.getBandBoundaryDefinition();
-            nominalSpatialResolution = object.getNominalSpatialResolution();
-            transferFunctionType     = object.getTransferFunctionType();
             transmittedPolarization  = object.getTransmittedPolarization();
             detectedPolarization     = object.getDetectedPolarization();
         }
@@ -195,22 +182,6 @@ public class DefaultBand extends Default
     }
 
     /**
-     * Ensures that the given property value is positive.
-     *
-     * @param property Name of the property to check.
-     * @param strict   {@code false} is zero is a legal value.
-     * @param newValue The property value to verify.
-     * @throws IllegalArgumentException if the given value is negative and the problem has
not been logged.
-     */
-    private static void ensurePositive(final String property, final boolean strict, final
Double newValue)
-            throws IllegalArgumentException
-    {
-        if (newValue != null && !(strict ? newValue > 0 : newValue >= 0)) {
// Use '!' for catching NaN.
-            warnNonPositiveArgument(DefaultBand.class, property, strict, newValue);
-        }
-    }
-
-    /**
      * Returns the shortest wavelength that the sensor is capable of collecting within a
designated band.
      * The units of measurement is given by {@link #getBoundUnit()}.
      *
@@ -450,50 +421,37 @@ public class DefaultBand extends Default
     }
 
     /**
-     * Returns the smallest distance between which separate points can be distinguished,
-     * as specified in instrument design.
-     *
-     * @return Smallest distance between which separate points can be distinguished, or {@code
null}.
+     * {@inheritDoc}
      */
     @Override
-    @ValueRange(minimum = 0, isMinIncluded = false)
     @XmlElement(name = "nominalSpatialResolution", namespace = Namespaces.GMI)
     public Double getNominalSpatialResolution() {
-        return nominalSpatialResolution;
+        return super.getNominalSpatialResolution();
     }
 
     /**
-     * Sets the smallest distance between which separate points can be distinguished,
-     * as specified in instrument design.
-     *
-     * @param newValue The new nominal spatial resolution.
-     * @throws IllegalArgumentException if the given value is negative.
+     * {@inheritDoc}
      */
+    @Override
     public void setNominalSpatialResolution(final Double newValue) {
-        checkWritePermission();
-        ensurePositive("nominalSpatialResolution", true, newValue);
-        nominalSpatialResolution = newValue;
+        super.setNominalSpatialResolution(newValue);
     }
 
     /**
-     * Returns type of transfer function to be used when scaling a physical value for a given
element.
-     *
-     * @return Type of transfer function, or {@code null}.
+     * {@inheritDoc}
      */
     @Override
     @XmlElement(name = "transferFunctionType", namespace = Namespaces.GMI)
     public TransferFunctionType getTransferFunctionType() {
-        return transferFunctionType;
+        return super.getTransferFunctionType();
     }
 
     /**
-     * Sets the type of transfer function to be used when scaling a physical value for a
given element.
-     *
-     * @param newValue The new transfer function value.
+     * {@inheritDoc}
      */
+    @Override
     public void setTransferFunctionType(final TransferFunctionType newValue) {
-        checkWritePermission();
-        transferFunctionType = newValue;
+        super.setTransferFunctionType(newValue);
     }
 
     /**

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlType;
+import org.opengis.metadata.content.TransferFunctionType;
 import org.opengis.util.Record;
 import org.opengis.util.RecordType;
 import org.opengis.metadata.content.Band;
@@ -124,12 +125,23 @@ public class DefaultSampleDimension exte
     private Double offset;
 
     /**
+     * Type of transfer function to be used when scaling a physical value for a given element.
+     */
+    private TransferFunctionType transferFunctionType;
+
+    /**
      * Maximum number of significant bits in the uncompressed representation
      * for the value in each band of each pixel.
      */
     private Integer bitsPerValue;
 
     /**
+     * Smallest distance between which separate points can be distinguished, as specified
in
+     * instrument design.
+     */
+    private Double nominalSpatialResolution;
+
+    /**
      * Type of other attribute description.
      */
     private RecordType otherPropertyType;
@@ -173,17 +185,19 @@ public class DefaultSampleDimension exte
      * Initializes this sample dimension to the values of the given object.
      */
     private void init(final DefaultSampleDimension object) {
-        minValue          = object.getMinValue();
-        maxValue          = object.getMaxValue();
-        meanValue         = object.getMeanValue();
-        numberOfValues    = object.getNumberOfValues();
-        standardDeviation = object.getStandardDeviation();
-        units             = object.getUnits();
-        scaleFactor       = object.getScaleFactor();
-        offset            = object.getOffset();
-        bitsPerValue      = object.getBitsPerValue();
-        otherPropertyType = object.getOtherPropertyType();
-        otherProperty     = object.getOtherProperty();
+        minValue                 = object.getMinValue();
+        maxValue                 = object.getMaxValue();
+        meanValue                = object.getMeanValue();
+        numberOfValues           = object.getNumberOfValues();
+        standardDeviation        = object.getStandardDeviation();
+        units                    = object.getUnits();
+        scaleFactor              = object.getScaleFactor();
+        offset                   = object.getOffset();
+        transferFunctionType     = object.getTransferFunctionType();
+        bitsPerValue             = object.getBitsPerValue();
+        nominalSpatialResolution = object.getNominalSpatialResolution();
+        otherPropertyType        = object.getOtherPropertyType();
+        otherProperty            = object.getOtherProperty();
     }
 
     /**
@@ -213,10 +227,10 @@ public class DefaultSampleDimension exte
      * @param newValue The property value to verify.
      * @throws IllegalArgumentException if the given value is negative and the problem has
not been logged.
      */
-    private static void ensurePositive(final String property, final boolean strict, final
Integer newValue)
+    static void ensurePositive(final String property, final boolean strict, final Number
newValue)
             throws IllegalArgumentException
     {
-        if (newValue != null && !(strict ? newValue > 0 : newValue >= 0)) {
+        if (newValue != null && !(strict ? newValue.doubleValue() > 0 : newValue.doubleValue()
>= 0)) { // Use '!' for catching NaN.
             warnNonPositiveArgument(DefaultSampleDimension.class, property, strict, newValue);
         }
     }
@@ -393,6 +407,25 @@ public class DefaultSampleDimension exte
     }
 
     /**
+     * Returns type of transfer function to be used when scaling a physical value for a given
element.
+     *
+     * @return Type of transfer function, or {@code null}.
+     */
+    public TransferFunctionType getTransferFunctionType() {
+        return transferFunctionType;
+    }
+
+    /**
+     * Sets the type of transfer function to be used when scaling a physical value for a
given element.
+     *
+     * @param newValue The new transfer function value.
+     */
+    public void setTransferFunctionType(final TransferFunctionType newValue) {
+        checkWritePermission();
+        transferFunctionType = newValue;
+    }
+
+    /**
      * Returns the maximum number of significant bits in the uncompressed representation
      * for the value in each band of each pixel.
      *
@@ -420,6 +453,30 @@ public class DefaultSampleDimension exte
     }
 
     /**
+     * Returns the smallest distance between which separate points can be distinguished,
+     * as specified in instrument design.
+     *
+     * @return Smallest distance between which separate points can be distinguished, or {@code
null}.
+     */
+    @ValueRange(minimum = 0, isMinIncluded = false)
+    public Double getNominalSpatialResolution() {
+        return nominalSpatialResolution;
+    }
+
+    /**
+     * Sets the smallest distance between which separate points can be distinguished,
+     * as specified in instrument design.
+     *
+     * @param newValue The new nominal spatial resolution.
+     * @throws IllegalArgumentException if the given value is negative.
+     */
+    public void setNominalSpatialResolution(final Double newValue) {
+        checkWritePermission();
+        ensurePositive("nominalSpatialResolution", true, newValue);
+        nominalSpatialResolution = newValue;
+    }
+
+    /**
      * Returns type of other attribute description.
      *
      * @return Type of other attribute description, or {@code null} if none.

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.metadata.iso.distribution;
 
+import java.util.Currency;
 import java.util.Date;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -73,6 +74,11 @@ public class DefaultStandardOrderProcess
     private InternationalString fees;
 
     /**
+     * The {@link #fees} currency, or {@code null} if unknown or unspecified.
+     */
+    private Currency currency;
+
+    /**
      * Date and time when the dataset will be available,
      * in milliseconds elapsed since January 1st, 1970.
      */
@@ -155,8 +161,11 @@ public class DefaultStandardOrderProcess
     /**
      * Returns fees and terms for retrieving the resource.
      * Include monetary units (as specified in ISO 4217).
+     * The monetary units may also be available with {@link #getCurrency()}.
      *
      * @return Fees and terms for retrieving the resource, or {@code null}.
+     *
+     * @see #getCurrency()
      */
     @Override
     @XmlElement(name = "fees")
@@ -169,6 +178,8 @@ public class DefaultStandardOrderProcess
      * Include monetary units (as specified in ISO 4217).
      *
      * @param newValue The new fees.
+     *
+     * @see #setCurrency(Currency)
      */
     public void setFees(final InternationalString newValue) {
         checkWritePermission();
@@ -176,6 +187,41 @@ public class DefaultStandardOrderProcess
     }
 
     /**
+     * Returns the monetary units of the {@link #getFees() fees} (as specified in ISO 4217).
+     *
+     * <p><b>Constraints:</b><br>
+     * For ISO 19115 compatibility reasons, this method is <strong>not</strong>
required to return
+     * a non-null value even if the text returned by {@link #getFees()} contains a currency
units.
+     * However if this method returns a non-null value, then that value is required to be
consistent
+     * with the fees text.</p>
+     *
+     * @return The fees monetary units, or {@code null} if none or unknown.
+     *
+     * @since 0.5
+     *
+     * @see #getFees()
+     */
+    public Currency getCurrency() {
+        return currency;
+    }
+
+    /**
+     * Sets the monetary units of the {@link #getFees() fees} (as specified in ISO 4217).
+     * Callers should ensure that the given currency is consistent with the currency
+     * in the {@linkplain #getFees() fees} text.
+     *
+     * @param newValue The new currency.
+     *
+     * @since 0.5
+     *
+     * @see #setFees(InternationalString)
+     */
+    public void setCurrency(final Currency newValue) {
+        checkWritePermission();
+        currency = newValue;
+    }
+
+    /**
      * Returns the date and time when the dataset will be available.
      *
      * @return Date and time when the dataset will be available, or {@code null}.

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -21,6 +21,7 @@ import java.util.Collection;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.util.InternationalString;
 import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.maintenance.ScopeDescription;
 import org.apache.sis.metadata.iso.ISOMetadata;
@@ -471,6 +472,10 @@ public class DefaultScopeDescription ext
     /**
      * Returns the class of information that does not fall into the other categories to which
the information applies.
      *
+     * <div class="warning"><b>Upcoming API change:</b>
+     * The type of this property may be changed to {@link InternationalString} for ISO 19115:2014
conformance.
+     * See <a href="http://jira.codehaus.org/browse/GEO-221">GEO-221</a> for
more information.</div>
+     *
      * @return Class of information that does not fall into the other categories, or {@code
null}.
      */
     @Override
@@ -487,6 +492,10 @@ public class DefaultScopeDescription ext
      * If and only if the {@code newValue} is non-null, then this method automatically
      * discards all other properties.
      *
+     * <div class="warning"><b>Upcoming API change:</b>
+     * The type of this property may be changed to {@link InternationalString} for ISO 19115:2014
conformance.
+     * See <a href="http://jira.codehaus.org/browse/GEO-221">GEO-221</a> for
more information.</div>
+     *
      * @param newValue Other class of information.
      */
     public void setOther(final String newValue) {

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -16,18 +16,13 @@
  */
 package org.apache.sis.metadata.iso;
 
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import org.opengis.util.CodeList;
 import org.opengis.annotation.UML;
 import org.opengis.annotation.Specification;
-import org.opengis.metadata.content.FeatureCatalogueDescription;
 import org.apache.sis.metadata.MetadataStandard;
 import org.apache.sis.metadata.MetadataTestCase;
-import org.apache.sis.metadata.iso.identification.DefaultCoupledResource;
-import org.apache.sis.metadata.iso.identification.DefaultOperationChainMetadata;
-import org.apache.sis.metadata.iso.identification.DefaultOperationMetadata;
-import org.apache.sis.metadata.iso.identification.DefaultRepresentativeFraction;
-import org.apache.sis.metadata.iso.identification.DefaultServiceIdentification;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.xml.Namespaces;
 import org.junit.Rule;
@@ -221,31 +216,20 @@ public final strictfp class AllMetadataT
      * @return {@inheritDoc}
      */
     @Override
-    protected String getExpectedXmlElementName(final Class<?> type, final UML uml)
{
-        String name = uml.identifier();
-        if (name.equals("distributedComputingPlatform")) {
-            name = "DCP";
-        } else if (name.equals("stepDateTime")) {
-            name = "dateTime";
-        } else if (name.equals("defaultLocale+otherLocale") ||
-                type == FeatureCatalogueDescription.class && name.equals("locale"))
-        {
-            name = "language";
-        }
-        return name;
-    }
-
-    /**
-     * Returns the name of the XML element for the given UML element.
-     * This method checks for the special cases which are known to have different UML and
XML names.
-     *
-     * @return {@inheritDoc}
-     */
-    @Override
-    protected String getExpectedXmlRootElementName(final UML uml) {
-        String name = uml.identifier();
-        if (name.equals("MD_Scope")) {  // ISO 19115:2014
-            name = "DQ_Scope";          // ISO 19115:2003
+    protected String getExpectedXmlElementName(final Class<?> enclosing, final UML
uml) {
+        String name = super.getExpectedXmlElementName(enclosing, uml);
+        /*switch (name)*/ {
+            if (name.equals("MD_Scope")) {      // ISO 19115:2014
+                name = "DQ_Scope";  // ISO 19115:2003
+            } else if (name.equals("distributedComputingPlatform")) {
+                name = "DCP";
+            } else if (name.equals("stepDateTime")) {
+                name = "dateTime";
+            } else if (name.equals("locale")) {
+                if (enclosing == org.opengis.metadata.content.FeatureCatalogueDescription.class)
{
+                    name = "language";
+                }
+            }
         }
         return name;
     }
@@ -259,10 +243,10 @@ public final strictfp class AllMetadataT
      */
     @Override
     protected String getExpectedNamespace(final Class<?> impl, final Specification
specification) {
-        if (impl == DefaultCoupledResource.class ||
-            impl == DefaultOperationChainMetadata.class ||
-            impl == DefaultOperationMetadata.class ||
-            impl == DefaultServiceIdentification.class)
+        if (impl == org.apache.sis.metadata.iso.identification.DefaultCoupledResource.class
||
+            impl == org.apache.sis.metadata.iso.identification.DefaultOperationChainMetadata.class
||
+            impl == org.apache.sis.metadata.iso.identification.DefaultOperationMetadata.class
||
+            impl == org.apache.sis.metadata.iso.identification.DefaultServiceIdentification.class)
         {
             assertEquals(Specification.ISO_19115, specification);
             return Namespaces.SRV;
@@ -331,13 +315,30 @@ public final strictfp class AllMetadataT
     }
 
     /**
+     * Returns {@code true} if the given method is a non-standard extension.
+     * If {@code true}, then {@code method} does not need to have UML annotation.
+     *
+     * @param method The method to verify.
+     * @return {@code true} if the given method is an extension, or {@code false} otherwise.
+     *
+     * @since 0.5
+     */
+    @Override
+    protected boolean isExtension(final Method method) {
+        if (org.opengis.metadata.distribution.StandardOrderProcess.class.isAssignableFrom(method.getDeclaringClass()))
{
+            return method.getName().equals("getCurrency");
+        }
+        return super.isExtension(method);
+    }
+
+    /**
      * Return {@code false} for the Apache SIS properties which are known to have no setter
methods.
      *
      * @return {@inheritDoc}
      */
     @Override
     protected boolean isWritable(final Class<?> impl, final String property) {
-        if (DefaultRepresentativeFraction.class.isAssignableFrom(impl)) {
+        if (org.apache.sis.metadata.iso.identification.DefaultRepresentativeFraction.class.isAssignableFrom(impl))
{
             if (property.equals("doubleValue")) {
                 return false;
             }

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -169,8 +169,7 @@ public final strictfp class DefaultDataI
 
     /**
      * Tests {@link DefaultDataIdentification#asMap()}, in particular on the {@code "language"}
property.
-     * This property is handle in a special way since the declared UML identifier is
-     * {@code "defaultLocale+otherLocale"}.
+     * This property still use the UML identifier of ISO 19115:2003.
      */
     @Test
     public void testValueMap() {

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java?rev=1641531&r1=1641530&r2=1641531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
[UTF-8] Tue Nov 25 06:14:50 2014
@@ -235,22 +235,22 @@ public abstract strictfp class Annotatio
 
     /**
      * Returns the name of the XML element for the given UML element.
+     * This method is invoked in two situations:
      *
-     * @param  uml The UML element.
-     * @return The corresponding XML element name.
-     */
-    protected String getExpectedXmlRootElementName(final UML uml) {
-        return uml.identifier();
-    }
-
-    /**
-     * Returns the name of the XML element for the given UML element.
+     * <ul>
+     *   <li>For the root XML element name of an interface, in which case {@code enclosing}
is {@code null}.</li>
+     *   <li>For the XML element name of a property (field or method) defined by an
interface,
+     *       in which case {@code enclosing} is the interface containing the property.</li>
+     * </ul>
      *
-     * @param  type The GeoAPI interface which contains the property.
-     * @param  uml The UML element of a property in the {@code type} interface.
-     * @return The corresponding XML element name.
+     * The default implementation returns {@link UML#identifier()}. Subclasses shall override
this method
+     * when mismatches are known to exist between the UML and XML element names.
+     *
+     * @param  enclosing The GeoAPI interface which contains the property, or {@code null}
if none.
+     * @param  uml The UML element for which to get the corresponding XML element name.
+     * @return The XML element name for the given UML element.
      */
-    protected String getExpectedXmlElementName(final Class<?> type, final UML uml)
{
+    protected String getExpectedXmlElementName(final Class<?> enclosing, final UML
uml) {
         return uml.identifier();
     }
 
@@ -384,6 +384,19 @@ public abstract strictfp class Annotatio
     }
 
     /**
+     * Returns {@code true} if the given method is a non-standard extension.
+     * If {@code true}, then {@code method} does not need to have UML annotation.
+     *
+     * @param method The method to verify.
+     * @return {@code true} if the given method is an extension, or {@code false} otherwise.
+     *
+     * @since 0.5
+     */
+    protected boolean isExtension(final Method method) {
+        return false;
+    }
+
+    /**
      * Tests the annotations on every GeoAPI interfaces and code lists in the {@link #types}
array.
      * More specifically this method tests that:
      *
@@ -404,7 +417,7 @@ public abstract strictfp class Annotatio
             if (!CodeList.class.isAssignableFrom(type)) {
                 for (final Method method : type.getDeclaredMethods()) {
                     testingMethod = method.getName();
-                    if (!isIgnored(method)) {
+                    if (!isIgnored(method) && !isExtension(method)) {
                         uml = method.getAnnotation(UML.class);
                         if (!method.isAnnotationPresent(Deprecated.class)) {
                             assertNotNull("Missing @UML annotation.", uml);
@@ -494,7 +507,7 @@ public abstract strictfp class Annotatio
             assertNotNull("Missing @XmlRootElement annotation.", root);
             final UML uml = type.getAnnotation(UML.class);
             if (uml != null) {
-                assertEquals("Wrong @XmlRootElement.name().", getExpectedXmlRootElementName(uml),
root.name());
+                assertEquals("Wrong @XmlRootElement.name().", getExpectedXmlElementName(null,
uml), root.name());
             }
             /*
              * Check that the namespace is the expected one (according subclass)



Mime
View raw message