You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/11/25 06:42:27 UTC
svn commit: r1641528 - in /sis/branches/JDK7: ./
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/...
Author: desruisseaux
Date: Tue Nov 25 05:42:26 2014
New Revision: 1641528
URL: http://svn.apache.org/r1641528
Log:
Merge from the JDK8 branch for GeoAPI changes.
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
Merged /sis/branches/JDK8:r1641227-1641527
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] Tue Nov 25 05:42:26 2014
@@ -103,17 +103,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;
@@ -154,8 +143,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();
}
@@ -187,22 +174,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()}.
*
@@ -411,50 +382,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/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] Tue Nov 25 05:42:26 2014
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlSeeA
import javax.xml.bind.annotation.XmlType;
import org.opengis.metadata.content.Band;
import org.opengis.metadata.content.SampleDimension;
+import org.opengis.metadata.content.TransferFunctionType;
import org.opengis.util.Record;
import org.opengis.util.RecordType;
import org.apache.sis.measure.ValueRange;
@@ -110,12 +111,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;
@@ -151,17 +163,19 @@ public class DefaultSampleDimension exte
public DefaultSampleDimension(final SampleDimension object) {
super(object);
if (object != null) {
- 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();
}
}
@@ -204,10 +218,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);
}
}
@@ -384,6 +398,26 @@ 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}.
+ */
+ @Override
+ 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.
*
@@ -411,6 +445,31 @@ 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}.
+ */
+ @Override
+ @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/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java [UTF-8] Tue Nov 25 05:42:26 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;
@@ -70,6 +71,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.
*/
@@ -150,8 +156,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")
@@ -164,6 +173,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();
@@ -171,6 +182,42 @@ 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()
+ */
+ @Override
+ 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/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] Tue Nov 25 05:42:26 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;
@@ -104,12 +105,12 @@ public class DefaultScopeDescription ext
* The value, as one of the following types:
*
* <ul>
- * <li>{@code Set<CharSequence>} for the {@code features} property</li>
- * <li>{@code Set<CharSequence>} for the {@code attributes} property</li>
- * <li>{@code Set<CharSequence>} for the {@code featureInstances} property</li>
- * <li>{@code Set<CharSequence>} for the {@code attributeInstances} property</li>
- * <li>{@code String} for the {@code dataset} property</li>
- * <li>{@code String} for the {@code other} property</li>
+ * <li>{@code Set<CharSequence>} for the {@code features} property</li>
+ * <li>{@code Set<CharSequence>} for the {@code attributes} property</li>
+ * <li>{@code Set<CharSequence>} for the {@code featureInstances} property</li>
+ * <li>{@code Set<CharSequence>} for the {@code attributeInstances} property</li>
+ * <li>{@code String} for the {@code dataset} property</li>
+ * <li>{@code InternationalString} for the {@code other} property</li>
* </ul>
*/
private Object value;
@@ -429,8 +430,8 @@ public class DefaultScopeDescription ext
*/
@Override
@XmlElement(name = "other")
- public String getOther() {
- return (property == OTHER) ? (String) value : null;
+ public InternationalString getOther() {
+ return (property == OTHER) ? (InternationalString) value : null;
}
/**
@@ -443,7 +444,7 @@ public class DefaultScopeDescription ext
*
* @param newValue Other class of information.
*/
- public void setOther(final String newValue) {
+ public void setOther(final InternationalString newValue) {
checkWritePermission();
if (newValue != null || property == OTHER) {
warningOnOverwrite(OTHER);
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] Tue Nov 25 05:42:26 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.Enumerated;
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;
@@ -233,29 +228,27 @@ 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 (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) {
+ case "MD_Scope": { // ISO 19115:2014
+ name = "DQ_Scope"; // ISO 19115:2003
+ break;
+ }
+ case "distributedComputingPlatform": {
+ name = "DCP";
+ break;
+ }
+ case "stepDateTime": {
+ name = "dateTime";
+ break;
+ }
+ case "locale": {
+ if (enclosing == org.opengis.metadata.content.FeatureCatalogueDescription.class) {
+ name = "language";
+ }
+ break;
+ }
}
return name;
}
@@ -269,10 +262,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;
@@ -338,13 +331,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/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] Tue Nov 25 05:42:26 2014
@@ -17,6 +17,7 @@
package org.apache.sis.metadata.iso.maintenance;
import org.apache.sis.metadata.iso.LoggingWatcher;
+import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.test.TestCase;
import org.junit.Rule;
import org.junit.Test;
@@ -29,7 +30,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.5
* @module
*/
public final strictfp class DefaultScopeDescriptionTest extends TestCase {
@@ -61,12 +62,12 @@ public final strictfp class DefaultScope
assertEquals("dataset", "A dataset", metadata.getDataset());
listener.maximumLogCount = 1;
- metadata.setOther("Other value");
- assertEquals("other", "Other value", metadata.getOther());
+ metadata.setOther(new SimpleInternationalString("Other value"));
+ assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
metadata.setDataset(null); // Expected to be a no-op.
- assertEquals("other", "Other value", metadata.getOther());
+ assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
metadata.setOther(null);
Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java?rev=1641528&r1=1641527&r2=1641528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java [UTF-8] Tue Nov 25 05:42:26 2014
@@ -236,22 +236,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();
}
@@ -385,6 +385,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:
*
@@ -405,7 +418,7 @@ public abstract strictfp class Annotatio
if (!Enumerated.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);
@@ -495,7 +508,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)