Author: desruisseaux
Date: Fri Aug 2 14:56:14 2013
New Revision: 1509731
URL: http://svn.apache.org/r1509731
Log:
Revert back to straight Boolean fields instead than bitmask.
The reason is that we need the exact reference to Boolean objects in order to
determine NilReason.
Added:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
(with props)
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MetadataUtilitiesTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/PositionalAccuracy.xml
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/ProcessStep.xml
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -19,23 +19,22 @@ package org.apache.sis.internal.metadata
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import org.apache.sis.xml.NilReason;
import org.apache.sis.util.Static;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Messages;
import org.apache.sis.metadata.InvalidMetadataException;
+import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
import static org.apache.sis.metadata.iso.ISOMetadata.LOGGER;
-// Related to JDK7
-import java.util.Objects;
-
/**
* Miscellaneous utility methods for metadata.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.4
* @module
*/
public final class MetadataUtilities extends Static {
@@ -78,59 +77,22 @@ public final class MetadataUtilities ext
}
/**
- * Sets the bit under the given mask for the given boolean value.
- * This method uses two bits as below:
- *
- * <ul>
- * <li>{@code 00} - {@code null}</li>
- * <li>{@code 10} - {@code Boolean.FALSE}</li>
- * <li>{@code 11} - {@code Boolean.TRUE}</li>
- * </ul>
- *
- * @param flags The set of bits to modify for the given boolean value.
- * @param mask The bit mask, which much have exactly two consecutive
bits set.
- * @param value The boolean value to store in the {@code flags}, or
{@code null}.
- * @return The updated {@code flags}.
- */
- public static int setBoolean(int flags, final int mask, final Boolean
value) {
- assert 3 << Integer.numberOfTrailingZeros(mask) == mask : mask;
- if (value == null) {
- flags &= ~mask;
- } else {
- flags |= mask;
- if (!value) {
- flags &= ~(mask & (mask >>> 1));
- }
- }
- assert Objects.equals(getBoolean(flags, mask), value) : value;
- return flags;
- }
-
- /**
- * Returns the boolean value for the bits under the given mask.
- * This method is the reverse of {@link #setBoolean(int, int, Boolean)}.
- *
- * @param flags The set of bits from which to read the boolean value
under the given mask.
- * @param mask The bit mask, which much have exactly two consecutive
bits set.
- * @return The boolean value under the given mask (may be {@code null}).
- */
- public static Boolean getBoolean(int flags, final int mask) {
- flags &= mask;
- return (flags == 0) ? null : Boolean.valueOf(flags == mask);
- }
-
- /**
- * Makes sure that the given inclusion is non-null, then returns its value.
+ * Makes sure that the given inclusion is non-nil, then returns its value.
+ * If the given inclusion is {@code null}, then the default value is
{@code true}.
*
* @param value The {@link
org.opengis.metadata.extent.GeographicBoundingBox#getInclusion()} value.
* @return The given value as a primitive type.
- * @throws InvalidMetadataException if the given value is null.
+ * @throws InvalidMetadataException if the given value is nil.
*/
public static boolean getInclusion(final Boolean value) throws
InvalidMetadataException {
if (value == null) {
- throw new
InvalidMetadataException(Errors.format(Errors.Keys.MissingValueForProperty_1,
"inclusion"));
+ return true;
+ }
+ final boolean p = value;
+ if (p || value == Boolean.FALSE ||
!(PrimitiveTypeProperties.property(value) instanceof NilReason)) {
+ return p;
}
- return value;
+ throw new
InvalidMetadataException(Errors.format(Errors.Keys.MissingValueForProperty_1,
"inclusion"));
}
/**
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -25,9 +25,6 @@ import org.opengis.util.GenericName;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.content.FeatureCatalogueDescription;
-import static org.apache.sis.internal.metadata.MetadataUtilities.getBoolean;
-import static org.apache.sis.internal.metadata.MetadataUtilities.setBoolean;
-
/**
* Information identifying the feature catalogue.
@@ -36,7 +33,7 @@ import static org.apache.sis.internal.me
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
* @module
*/
@XmlType(name = "MD_FeatureCatalogueDescription_Type", propOrder = {
@@ -53,28 +50,26 @@ public class DefaultFeatureCatalogueDesc
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -3626075463499626813L;
+ private static final long serialVersionUID = -3626075463499626815L;
/**
- * Mask for the {@code compliant} {@link Boolean} value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
+ * Whether or not the cited feature catalogue complies with ISO 19110.
*
- * @see #booleans
+ * <p>Implementation note: we need to store the reference to the {@code
Boolean} instance instead
+ * than using bitmask because {@link
org.apache.sis.internal.jaxb.PrimitiveTypeProperties} may
+ * associate some properties to that particular instance.</p>
*/
- private static final byte COMPLIANT_MASK = 0b011;
+ private Boolean compliant;
/**
- * Mask for the {@code includedWithDataset} {@code boolean} value.
- * Needs only 1 bit because the value can not be {@code null}.
- *
- * @see #booleans
+ * Language(s) used within the catalogue
*/
- private static final byte INCLUDED_MASK = 0b100;
+ private Collection<Locale> languages;
/**
- * Language(s) used within the catalogue
+ * Whether or not the feature catalogue is included with the dataset.
*/
- private Collection<Locale> languages;
+ private boolean includedWithDataset;
/**
* Subset of feature types from cited feature catalogue occurring in
dataset.
@@ -87,15 +82,6 @@ public class DefaultFeatureCatalogueDesc
private Collection<Citation> featureCatalogueCitations;
/**
- * The set of {@code boolean} and {@link Boolean} values.
- * Bits are read and written using the {@code *_MASK} constants.
- *
- * @see #COMPLIANT_MASK
- * @see #INCLUDED_MASK
- */
- private byte booleans;
-
- /**
* Constructs an initially empty feature catalogue description.
*/
public DefaultFeatureCatalogueDescription() {
@@ -113,8 +99,8 @@ public class DefaultFeatureCatalogueDesc
public DefaultFeatureCatalogueDescription(final
FeatureCatalogueDescription object) {
super(object);
if (object != null) {
- booleans = object.isIncludedWithDataset() ?
INCLUDED_MASK : 0;
- booleans = (byte) setBoolean(booleans,
COMPLIANT_MASK, object.isCompliant());
+ compliant = object.isCompliant();
+ includedWithDataset = object.isIncludedWithDataset();
languages = copyCollection(object.getLanguages(),
Locale.class);
featureTypes =
copyCollection(object.getFeatureTypes(), GenericName.class);
featureCatalogueCitations =
copyCollection(object.getFeatureCatalogueCitations(), Citation.class);
@@ -154,7 +140,7 @@ public class DefaultFeatureCatalogueDesc
@Override
@XmlElement(name = "complianceCode")
public Boolean isCompliant() {
- return getBoolean(booleans, COMPLIANT_MASK);
+ return compliant;
}
/**
@@ -164,7 +150,7 @@ public class DefaultFeatureCatalogueDesc
*/
public void setCompliant(final Boolean newValue) {
checkWritePermission();
- booleans = (byte) setBoolean(booleans, COMPLIANT_MASK, newValue);
+ compliant = newValue;
}
/**
@@ -195,7 +181,7 @@ public class DefaultFeatureCatalogueDesc
@Override
@XmlElement(name = "includedWithDataset", required = true)
public boolean isIncludedWithDataset() {
- return (booleans & INCLUDED_MASK) != 0;
+ return includedWithDataset;
}
/**
@@ -205,11 +191,7 @@ public class DefaultFeatureCatalogueDesc
*/
public void setIncludedWithDataset(final boolean newValue) {
checkWritePermission();
- if (newValue) {
- booleans |= INCLUDED_MASK;
- } else {
- booleans &= ~INCLUDED_MASK;
- }
+ includedWithDataset = newValue;
}
/**
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -25,9 +25,6 @@ import org.opengis.metadata.content.Imag
import org.opengis.metadata.content.ImagingCondition;
import org.apache.sis.measure.ValueRange;
-import static org.apache.sis.internal.metadata.MetadataUtilities.getBoolean;
-import static org.apache.sis.internal.metadata.MetadataUtilities.setBoolean;
-
/**
* Information about an image's suitability for use.
@@ -36,7 +33,7 @@ import static org.apache.sis.internal.me
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
* @module
*/
@XmlType(name = "MD_ImageDescription_Type", propOrder = {
@@ -59,47 +56,7 @@ public class DefaultImageDescription ext
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 1756867502303578674L;
-
- /**
- * Mask for the {@code triangulationIndicator} {@link Boolean} value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final short TRIANGULATION_MASK = 3;
-
- /**
- * Mask for the {@code radiometricCalibrationDataAvailable} {@link
Boolean} value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final short RADIOMETRIC_MASK = TRIANGULATION_MASK << 2;
-
- /**
- * Mask for the {@code cameraCalibrationInformationAvailable} {@link
Boolean} value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final short CAMERA_MASK = RADIOMETRIC_MASK << 2;
-
- /**
- * Mask for the {@code filmDistortionInformationAvailable} {@link Boolean}
value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final short FILM_MASK = CAMERA_MASK << 2;
-
- /**
- * Mask for the {@code lensDistortionInformationAvailable} {@link Boolean}
value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final short LENS_MASK = FILM_MASK << 2;
+ private static final long serialVersionUID = 1756867502303578675L;
/**
* Illumination elevation measured in degrees clockwise from the target
plane
@@ -141,15 +98,34 @@ public class DefaultImageDescription ext
private Integer compressionGenerationQuantity;
/**
- * The set of {@link Boolean} values. Bits are read and written using the
{@code *_MASK} constants.
+ * Indication of whether or not triangulation has been performed upon the
image.
*
- * @see #TRIANGULATION_MASK
- * @see #RADIOMETRIC_MASK
- * @see #CAMERA_MASK
- * @see #FILM_MASK
- * @see #LENS_MASK
+ * <p>Implementation note: we need to store the reference to the {@code
Boolean} instance instead
+ * than using bitmask because {@link
org.apache.sis.internal.jaxb.PrimitiveTypeProperties} may
+ * associate some properties to that particular instance.</p>
*/
- private short booleans;
+ private Boolean triangulationIndicator;
+
+ /**
+ * Indication of whether or not the radiometric calibration information for
+ * generating the radiometrically calibrated standard data product is
available.
+ */
+ private Boolean radiometricCalibrationDataAvailable;
+
+ /**
+ * Indication of whether or not constants are available which allow for
camera calibration corrections.
+ */
+ private Boolean cameraCalibrationInformationAvailable;
+
+ /**
+ * Indication of whether or not Calibration Reseau information is
available.
+ */
+ private Boolean filmDistortionInformationAvailable;
+
+ /**
+ * Indication of whether or not lens aberration correction information is
available.
+ */
+ private Boolean lensDistortionInformationAvailable;
/**
* Constructs an initially empty image description.
@@ -176,14 +152,11 @@ public class DefaultImageDescription ext
cloudCoverPercentage =
object.getCloudCoverPercentage();
processingLevelCode =
object.getProcessingLevelCode();
compressionGenerationQuantity =
object.getCompressionGenerationQuantity();
-
- int flags;
- flags = setBoolean(0, TRIANGULATION_MASK,
object.getTriangulationIndicator());
- flags = setBoolean(flags, RADIOMETRIC_MASK,
object.isRadiometricCalibrationDataAvailable());
- flags = setBoolean(flags, CAMERA_MASK,
object.isCameraCalibrationInformationAvailable());
- flags = setBoolean(flags, FILM_MASK,
object.isFilmDistortionInformationAvailable());
- flags = setBoolean(flags, LENS_MASK,
object.isLensDistortionInformationAvailable());
- booleans = (short) flags;
+ triangulationIndicator =
object.getTriangulationIndicator();
+ radiometricCalibrationDataAvailable =
object.isRadiometricCalibrationDataAvailable();
+ cameraCalibrationInformationAvailable =
object.isCameraCalibrationInformationAvailable();
+ filmDistortionInformationAvailable =
object.isFilmDistortionInformationAvailable();
+ lensDistortionInformationAvailable =
object.isLensDistortionInformationAvailable();
}
}
@@ -384,7 +357,7 @@ public class DefaultImageDescription ext
@Override
@XmlElement(name = "triangulationIndicator")
public Boolean getTriangulationIndicator() {
- return getBoolean(booleans, TRIANGULATION_MASK);
+ return triangulationIndicator;
}
/**
@@ -394,7 +367,7 @@ public class DefaultImageDescription ext
*/
public void setTriangulationIndicator(final Boolean newValue) {
checkWritePermission();
- booleans = (short) setBoolean(booleans, TRIANGULATION_MASK, newValue);
+ triangulationIndicator = newValue;
}
/**
@@ -407,7 +380,7 @@ public class DefaultImageDescription ext
@Override
@XmlElement(name = "radiometricCalibrationDataAvailability")
public Boolean isRadiometricCalibrationDataAvailable() {
- return getBoolean(booleans, RADIOMETRIC_MASK);
+ return radiometricCalibrationDataAvailable;
}
/**
@@ -418,7 +391,7 @@ public class DefaultImageDescription ext
*/
public void setRadiometricCalibrationDataAvailable(final Boolean newValue)
{
checkWritePermission();
- booleans = (short) setBoolean(booleans, RADIOMETRIC_MASK, newValue);
+ radiometricCalibrationDataAvailable = newValue;
}
/**
@@ -431,7 +404,7 @@ public class DefaultImageDescription ext
@Override
@XmlElement(name = "cameraCalibrationInformationAvailability")
public Boolean isCameraCalibrationInformationAvailable() {
- return getBoolean(booleans, CAMERA_MASK);
+ return cameraCalibrationInformationAvailable;
}
/**
@@ -442,7 +415,7 @@ public class DefaultImageDescription ext
*/
public void setCameraCalibrationInformationAvailable(final Boolean
newValue) {
checkWritePermission();
- booleans = (short) setBoolean(booleans, CAMERA_MASK, newValue);
+ cameraCalibrationInformationAvailable = newValue;
}
/**
@@ -454,7 +427,7 @@ public class DefaultImageDescription ext
@Override
@XmlElement(name = "filmDistortionInformationAvailability")
public Boolean isFilmDistortionInformationAvailable() {
- return getBoolean(booleans, FILM_MASK);
+ return filmDistortionInformationAvailable;
}
/**
@@ -464,7 +437,7 @@ public class DefaultImageDescription ext
*/
public void setFilmDistortionInformationAvailable(final Boolean newValue) {
checkWritePermission();
- booleans = (short) setBoolean(booleans, FILM_MASK, newValue);
+ filmDistortionInformationAvailable = newValue;
}
/**
@@ -476,7 +449,7 @@ public class DefaultImageDescription ext
@Override
@XmlElement(name = "lensDistortionInformationAvailability")
public Boolean isLensDistortionInformationAvailable() {
- return getBoolean(booleans, LENS_MASK);
+ return lensDistortionInformationAvailable;
}
/**
@@ -486,6 +459,6 @@ public class DefaultImageDescription ext
*/
public void setLensDistortionInformationAvailable(final Boolean newValue) {
checkWritePermission();
- booleans = (short) setBoolean(booleans, LENS_MASK, newValue);
+ lensDistortionInformationAvailable = newValue;
}
}
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -26,9 +26,6 @@ import org.opengis.metadata.extent.Geogr
import org.opengis.metadata.extent.BoundingPolygon;
import org.apache.sis.metadata.iso.ISOMetadata;
-import static org.apache.sis.internal.metadata.MetadataUtilities.getBoolean;
-import static org.apache.sis.internal.metadata.MetadataUtilities.setBoolean;
-
/**
* Base class for geographic area of the dataset.
@@ -37,7 +34,7 @@ import static org.apache.sis.internal.me
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
* @module
*/
@XmlType(name = "AbstractEX_GeographicExtent_Type")
@@ -51,22 +48,17 @@ public class AbstractGeographicExtent ex
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 4819196764221609263L;
+ private static final long serialVersionUID = 4819196764221609265L;
/**
- * Mask for the {@code inclusion} {@link Boolean} value.
- * Needs 2 bits since the values can be {@code true}, {@code false} or
{@code null}.
- *
- * @see #booleans
- */
- private static final byte INCLUSION_MASK = 3;
-
- /**
- * The set of {@link Boolean} values. Bits are read and written using the
{@code *_MASK} constants.
+ * Indication of whether the bounding polygon encompasses an area covered
by the data
+ * (<cite>inclusion</cite>) or an area where data is not present
(<cite>exclusion</cite>).
*
- * @see #INCLUSION_MASK
+ * <p>Implementation note: we need to store the reference to the {@code
Boolean} instance instead
+ * than using bitmask because {@link
org.apache.sis.internal.jaxb.PrimitiveTypeProperties} may
+ * associate some properties to that particular instance.</p>
*/
- private byte booleans;
+ private Boolean inclusion;
/**
* Constructs an initially empty geographic extent.
@@ -80,7 +72,7 @@ public class AbstractGeographicExtent ex
* @param inclusion Whether the bounding polygon encompasses an area
covered by the data.
*/
public AbstractGeographicExtent(final boolean inclusion) {
- booleans = inclusion ? INCLUSION_MASK : 0;
+ this.inclusion = inclusion;
}
/**
@@ -95,7 +87,7 @@ public class AbstractGeographicExtent ex
public AbstractGeographicExtent(final GeographicExtent object) {
super(object);
if (object != null) {
- booleans = (byte) setBoolean(0, INCLUSION_MASK,
object.getInclusion());
+ inclusion = object.getInclusion();
}
}
@@ -148,7 +140,7 @@ public class AbstractGeographicExtent ex
@Override
@XmlElement(name = "extentTypeCode")
public Boolean getInclusion() {
- return getBoolean(booleans, INCLUSION_MASK);
+ return inclusion;
}
/**
@@ -159,6 +151,6 @@ public class AbstractGeographicExtent ex
*/
public void setInclusion(final Boolean newValue) {
checkWritePermission();
- booleans = (byte) setBoolean(booleans, INCLUSION_MASK, newValue);
+ inclusion = newValue;
}
}
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -322,9 +322,9 @@ public class DefaultGeographicBoundingBo
* Note that {@linkplain Double#NaN NaN} values are allowed.
*/
public void setBounds(final double westBoundLongitude,
- final double eastBoundLongitude,
- final double southBoundLatitude,
- final double northBoundLatitude)
+ final double eastBoundLongitude,
+ final double southBoundLatitude,
+ final double northBoundLatitude)
throws IllegalArgumentException
{
checkWritePermission();
Modified:
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MetadataUtilitiesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MetadataUtilitiesTest.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MetadataUtilitiesTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MetadataUtilitiesTest.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -21,8 +21,6 @@ import org.junit.Test;
import org.apache.sis.test.TestCase;
import static org.junit.Assert.*;
-import static java.lang.Boolean.TRUE;
-import static java.lang.Boolean.FALSE;
/**
@@ -30,7 +28,7 @@ import static java.lang.Boolean.FALSE;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.4
* @module
*/
public final strictfp class MetadataUtilitiesTest extends TestCase {
@@ -51,22 +49,4 @@ public final strictfp class MetadataUtil
assertEquals(new Date(1000), MetadataUtilities.toDate(1000));
assertNull(MetadataUtilities.toDate(Long.MIN_VALUE));
}
-
- /**
- * Tests {@link MetadataUtilities#setBoolean(int, byte, Boolean)}.
- * This will indirectly test the getter method through Java assertion.
- */
- @Test
- public void testSetBoolean() {
- final int mask0 = 0b000011;
- final int mask1 = 0b001100;
- final int mask2 = 0b110000;
- int flags = 0;
- flags = MetadataUtilities.setBoolean(flags, mask1, null );
assertEquals(0b000000, flags);
- flags = MetadataUtilities.setBoolean(flags, mask1, TRUE );
assertEquals(0b001100, flags);
- flags = MetadataUtilities.setBoolean(flags, mask2, FALSE);
assertEquals(0b101100, flags);
- flags = MetadataUtilities.setBoolean(flags, mask1, null );
assertEquals(0b100000, flags);
- flags = MetadataUtilities.setBoolean(flags, mask0, TRUE );
assertEquals(0b100011, flags);
- flags = MetadataUtilities.setBoolean(flags, mask0, FALSE);
assertEquals(0b100010, flags);
- }
}
Modified:
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -26,6 +26,9 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.bind.JAXBException;
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.metadata.iso.lineage.DefaultProcessing;
import org.apache.sis.metadata.iso.lineage.DefaultProcessStep;
import org.apache.sis.metadata.iso.quality.AbstractElement;
@@ -37,6 +40,7 @@ import org.junit.AfterClass;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.date;
import static org.apache.sis.test.TestUtilities.getSingleton;
@@ -48,7 +52,7 @@ import static org.apache.sis.test.TestUt
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
* @module
*/
@DependsOn(FreeTextMarshallingTest.class)
@@ -131,7 +135,7 @@ public final strictfp class MetadataMars
assertInstanceOf("Wrong value for <gmd:result>",
DefaultConformanceResult.class,
getSingleton(((AbstractElement) metadata).getResults()));
/*
- * Final comparison: ensure that we didn't lost any information, then
release.
+ * Final comparison: ensure that we didn't lost any information.
*/
assertXmlEquals(resource, marshal(marshaller, metadata), "xmlns:*",
"xsi:schemaLocation", "xsi:type");
pool.recycle(unmarshaller);
@@ -162,10 +166,48 @@ public final strictfp class MetadataMars
assertTrue(xml.startsWith("<?xml"));
assertXmlEquals(getResource("ProcessStep.xml"), xml, "xmlns:*",
"xsi:schemaLocation");
/*
- * Final comparison: ensure that we didn't lost any information, then
release.
+ * Final comparison: ensure that we didn't lost any information.
*/
assertEquals(processStep, unmarshal(unmarshaller, xml));
pool.recycle(unmarshaller);
pool.recycle(marshaller);
}
+
+ /**
+ * Tests the (un)marshalling of a {@code <gmd:EX_Extent>} object.
+ * This test opportunistically tests setting {@code "gml:id"} value.
+ *
+ * <p><b>XML test file:</b>
+ * <a href="{@scmUrl gmd-data}/Extent.xml">Extent.xml</a></p>
+ *
+ * @throws IOException If an error occurred while reading the XML file.
+ * @throws JAXBException If an error occurred during the during
marshalling / unmarshalling processes.
+ *
+ * @since 0.4
+ */
+ @Test
+ public void testExtent() throws IOException, JAXBException {
+ final Marshaller marshaller = pool.acquireMarshaller();
+ final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+ final DefaultGeographicBoundingBox bbox = new
DefaultGeographicBoundingBox(-99, -79, 14.9844, 31);
+ bbox.getIdentifierMap().put(IdentifierSpace.ID, "bbox");
+ final DefaultTemporalExtent temporal = new DefaultTemporalExtent();
+ if (PENDING_FUTURE_SIS_VERSION) {
+ // This block needs sis-temporal module.
+ temporal.setBounds(date("2010-01-27 13:26:10"), date("2010-08-27
13:26:10"));
+ }
+ final DefaultExtent extent = new DefaultExtent(null, bbox, null,
temporal);
+ /*
+ * XML marshalling, and compare with the content of "ProcessStep.xml"
file.
+ */
+ final String xml = marshal(marshaller, extent);
+ assertTrue(xml.startsWith("<?xml"));
+ assertXmlEquals(getResource("Extent.xml"), xml, "xmlns:*",
"xsi:schemaLocation");
+ /*
+ * Final comparison: ensure that we didn't lost any information.
+ */
+ assertEquals(extent, unmarshal(unmarshaller, xml));
+ pool.recycle(unmarshaller);
+ pool.recycle(marshaller);
+ }
}
Added:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml?rev=1509731&view=auto
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
(added)
+++
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
Fri Aug 2 14:56:14 2013
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<gmd:EX_Extent
+ xmlns:gco="http://www.isotc211.org/2005/gco"
+ xmlns:gmd="http://www.isotc211.org/2005/gmd"
+ xmlns:gml="http://www.opengis.net/gml"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation = "http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
+
+ <gmd:geographicElement>
+ <gmd:EX_GeographicBoundingBox id="bbox">
+ <gmd:extentTypeCode>
+ <gco:Boolean>true</gco:Boolean>
+ </gmd:extentTypeCode>
+ <gmd:westBoundLongitude>
+ <gco:Decimal>-99.0</gco:Decimal>
+ </gmd:westBoundLongitude>
+ <gmd:eastBoundLongitude>
+ <gco:Decimal>-79.0</gco:Decimal>
+ </gmd:eastBoundLongitude>
+ <gmd:southBoundLatitude>
+ <gco:Decimal>14.9844</gco:Decimal>
+ </gmd:southBoundLatitude>
+ <gmd:northBoundLatitude>
+ <gco:Decimal>31.0</gco:Decimal>
+ </gmd:northBoundLatitude>
+ </gmd:EX_GeographicBoundingBox>
+ </gmd:geographicElement>
+ <gmd:temporalElement>
+ <gmd:EX_TemporalExtent>
+ <!-- TODO: This block needs the sis-temporal module.
+ <gmd:extent>
+ <gml:TimePeriod gml:id="period">
+ <gml:description>Acquisition period</gml:description>
+ <gml:beginPosition>2010-01-27T08:26:10-05:00</gml:beginPosition>
+ <gml:endPosition>2010-08-27T08:26:10-05:00</gml:endPosition>
+ </gml:TimePeriod>
+ </gmd:extent>
+ -->
+ </gmd:EX_TemporalExtent>
+ </gmd:temporalElement>
+</gmd:EX_Extent>
Propchange:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/PositionalAccuracy.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/PositionalAccuracy.xml?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/PositionalAccuracy.xml
(original)
+++
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/PositionalAccuracy.xml
Fri Aug 2 14:56:14 2013
@@ -19,10 +19,10 @@
-->
<gmd:DQ_RelativeInternalPositionalAccuracy
- xmlns:gmd = "http://www.isotc211.org/2005/gmd"
- xmlns:gco = "http://www.isotc211.org/2005/gco"
- xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation = "http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
+ xmlns:gmd = "http://www.isotc211.org/2005/gmd"
+ xmlns:gco = "http://www.isotc211.org/2005/gco"
+ xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation = "http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
<!-- The <nameOfMeasure> element below is the main purpose of
MetadataMarshallingTest.testPositionalAccuracy().
The <result> element was added only in order to allow validation of
this XML file, with the addition of an
Modified:
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/ProcessStep.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/ProcessStep.xml?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/ProcessStep.xml
(original)
+++
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/ProcessStep.xml
Fri Aug 2 14:56:14 2013
@@ -19,11 +19,11 @@
-->
<gmd:LI_ProcessStep
- xmlns:gmd = "http://www.isotc211.org/2005/gmd"
- xmlns:gco = "http://www.isotc211.org/2005/gco"
- xmlns:gmi = "http://www.isotc211.org/2005/gmi"
- xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation = "http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
+ xmlns:gmd = "http://www.isotc211.org/2005/gmd"
+ xmlns:gco = "http://www.isotc211.org/2005/gco"
+ xmlns:gmi = "http://www.isotc211.org/2005/gmi"
+ xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation = "http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
<!-- As of February 2011, there is not yet any XSD schema for the "gmi"
namespace on the
OGC web site. Consequently the validation of this file does not work
fully yet. -->
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -44,7 +44,7 @@ public final class GO_Boolean extends Pr
* @param value The value.
*/
private GO_Boolean(final Boolean value) {
- super(value, !value);
+ super(value, value.booleanValue() == false && value != Boolean.FALSE);
}
/**
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -461,7 +461,7 @@ public final class NilReason implements
private static boolean mayBeNil(final Object object) {
// 'instanceof' checks on instances of final classes are expected to
be very fast.
if (object instanceof String) return ((String) object).isEmpty();
- if (object instanceof Boolean) return ((Boolean)
object).booleanValue() == false;
+ if (object instanceof Boolean) return ((Boolean)
object).booleanValue() == false && object != Boolean.FALSE;
if (object instanceof Number) {
/*
* Following test may return false positives for Long, Float and
Double types, but this is okay
Modified:
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1509731&r1=1509730&r2=1509731&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
[UTF-8] Fri Aug 2 14:56:14 2013
@@ -50,7 +50,7 @@ import static org.apache.sis.test.TestCo
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.16)
- * @version 0.3
+ * @version 0.4
* @module
*/
@RunWith(TestRunner.class)
@@ -72,6 +72,23 @@ public abstract strictfp class TestCase
public static final boolean PENDING_NEXT_GEOAPI_RELEASE = false;
/**
+ * A flag for code that are pending future SIS development before to be
enabled.
+ * This flag is always set to {@code false}. It shall be used as below:
+ *
+ * {@preformat java
+ * if (PENDING_FUTURE_SIS_VERSION) {
+ * // Do some stuff here.
+ * }
+ * }
+ *
+ * The intend is to make easier to identify test cases that fail with the
current version
+ * of SIS (e.g. because of unsupported operations), but should pass in a
future version.
+ *
+ * @since 0.4
+ */
+ public static final boolean PENDING_FUTURE_SIS_VERSION = false;
+
+ /**
* The output writer where to print debugging information (never {@code
null}).
* Texts sent to this printer will be show only if the test fails, or if
the
* {@value org.apache.sis.test.TestConfiguration#VERBOSE_OUTPUT_KEY}
system property