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 2013/08/15 19:37:31 UTC
svn commit: r1514393 [1/2] - in /sis/trunk: ./ application/sis-console/
application/sis-console/src/main/artifact/ core/sis-metadata/
core/sis-metadata/src/main/java/org/apache/sis/metadata/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ ...
Author: desruisseaux
Date: Thu Aug 15 17:37:30 2013
New Revision: 1514393
URL: http://svn.apache.org/r1514393
Log:
Merge from the JDK6 branch.
Added:
sis/trunk/application/sis-console/src/main/artifact/
- copied from r1514390, sis/branches/JDK6/application/sis-console/src/main/artifact/
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/SpecialCases.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/SpecialCases.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/SpecialCasesTest.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/SpecialCasesTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java
- copied unchanged from r1514390, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java
Modified:
sis/trunk/ (props changed)
sis/trunk/README
sis/trunk/application/sis-console/pom.xml
sis/trunk/core/sis-metadata/pom.xml
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/trunk/core/sis-referencing/pom.xml
sis/trunk/core/sis-utility/pom.xml
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/AngleTest.java
sis/trunk/ide-project/NetBeans/nbproject/project.properties
sis/trunk/pom.xml
sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1512214-1514388
Merged /sis/branches/JDK6:r1512216-1514390
Modified: sis/trunk/README
URL: http://svn.apache.org/viewvc/sis/trunk/README?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/README (original)
+++ sis/trunk/README Thu Aug 15 17:37:30 2013
@@ -79,6 +79,7 @@ You can subscribe the mailing lists by s
To unsubscribe, send a message to <LIST>-unsubscribe@sis.apache.org.
For more instructions, send a message to <LIST>-help@sis.apache.org.
+
Issue Tracker
=============
Modified: sis/trunk/application/sis-console/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/pom.xml?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/application/sis-console/pom.xml (original)
+++ sis/trunk/application/sis-console/pom.xml Thu Aug 15 17:37:30 2013
@@ -109,7 +109,7 @@ Console application.
<groupId>org.apache.sis.storage</groupId>
<artifactId>sis-netcdf</artifactId>
<version>${project.version}</version>
- <!-- TODO: use test or runtime scope -->
+ <scope>runtime</scope>
</dependency>
</dependencies>
Modified: sis/trunk/core/sis-metadata/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/pom.xml?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/pom.xml (original)
+++ sis/trunk/core/sis-metadata/pom.xml Thu Aug 15 17:37:30 2013
@@ -150,12 +150,12 @@ Implementations of metadata derived from
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
</dependency>
-
- <!-- Test dependencies -->
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -293,7 +293,12 @@ public class MetadataStandard implements
return null;
}
}
- final PropertyAccessor accessor = new PropertyAccessor(citation, type, implementation);
+ final PropertyAccessor accessor;
+ if (SpecialCases.isSpecialCase(type)) {
+ accessor = new SpecialCases(citation, type, implementation);
+ } else {
+ accessor = new PropertyAccessor(citation, type, implementation);
+ }
accessors.put(implementation, accessor);
return accessor;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -82,7 +82,7 @@ import static org.apache.sis.util.collec
* @module
*/
@ThreadSafe
-final class PropertyAccessor {
+class PropertyAccessor {
/**
* Getters shared between many instances of this class. Two different implementations
* may share the same getters but different setters.
@@ -535,7 +535,7 @@ final class PropertyAccessor {
* @param policy The kind of type to return.
* @return The type of property values, or {@code null} if unknown.
*/
- final Class<?> type(final int index, final TypeValuePolicy policy) {
+ Class<?> type(final int index, final TypeValuePolicy policy) {
if (index >= 0 && index < standardCount) {
switch (policy) {
case ELEMENT_TYPE: {
@@ -633,7 +633,7 @@ final class PropertyAccessor {
* @return The value, or {@code null} if none or if the given is out of bounds.
* @throws BackingStoreException If the implementation threw a checked exception.
*/
- final Object get(final int index, final Object metadata) throws BackingStoreException {
+ Object get(final int index, final Object metadata) throws BackingStoreException {
return (index >= 0 && index < standardCount) ? get(getters[index], metadata) : null;
}
@@ -680,7 +680,7 @@ final class PropertyAccessor {
* new collection in their existing instance.</li>
* <li>APPEND: Set the value only if it doesn't overwrite an existing value, then returns
* {@link Boolean#TRUE} if the metadata changed as a result of this method call,
- * {@code Boolean#FALSE} if the metadata didn't changed or {@code null} if the
+ * {@link Boolean#FALSE} if the metadata didn't changed or {@code null} if the
* value can not be set because an other value already exists.</li>
* </ul>
*
@@ -704,7 +704,7 @@ final class PropertyAccessor {
* @throws ClassCastException if the given value is not of the expected type.
* @throws BackingStoreException if the implementation threw a checked exception.
*/
- final Object set(final int index, final Object metadata, final Object value, final int mode)
+ Object set(final int index, final Object metadata, final Object value, final int mode)
throws UnmodifiableMetadataException, ClassCastException, BackingStoreException
{
if (index < 0 || index >= standardCount) {
@@ -884,9 +884,7 @@ final class PropertyAccessor {
// Other cases: let the collection unchanged. It is likely to
// cause an exception later. The message should be appropriate.
}
- // Getter type (targetType) shall be the same than the setter type (elementType).
- assert elementType == Numbers.primitiveToWrapper(targetType) : elementType;
- targetType = elementType; // Ensure that we use primitive wrapper.
+ targetType = Numbers.primitiveToWrapper(targetType);
} else {
/*
* We expect a collection. Collections are handled in one of the two ways below:
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -121,7 +121,7 @@ final class PropertyInformation<E> exten
* @param getter The getter method defined in the interface.
* @param elementType The value type, either the method return type if not a collection,
* or the type of elements in the collection otherwise.
- * @param valueRange The range of valid values, or {@code null} if none. This information is associated to the
+ * @param range The range of valid values, or {@code null} if none. This information is associated to the
* implementation method rather than the interface one, because it is specific to SIS.
*/
@SuppressWarnings({"unchecked","rawtypes"})
@@ -250,6 +250,8 @@ final class PropertyInformation<E> exten
* Returns the case type of values to be stored in the property.
* If the property type is an array or a collection, then this method
* returns the type of elements in the array or collection.
+ *
+ * @see TypeValuePolicy#ELEMENT_TYPE
*/
@Override
public Class<E> getElementType() {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -32,23 +32,32 @@ package org.apache.sis.metadata;
public enum TypeValuePolicy {
/**
* The type of a property, as inferred from the
- * {@linkplain java.lang.reflect.Method#getReturnType() return type} of the property method.
- * Collections are not handled in any special way; if the return type is a collection, then
- * the value is {@code Collection.class} (or a subclass).
+ * {@linkplain java.lang.reflect.Method#getReturnType() return type} of the property method
+ * defined in the interface.
+ *
+ * <p><b>Notes:</b></p>
+ * <ul>
+ * <li>Collections are not handled in any special way: if the return type is a collection,
+ * then the property type is {@code Collection.class} or any other declared return type.</li>
+ * <li>As a special case, values of type {@code double} (the primitive type) in
+ * {@link org.opengis.metadata.extent.GeographicBoundingBox} are wrapped in
+ * {@link org.apache.sis.measure.Longitude} and {@link org.apache.sis.measure.Latitude}
+ * objects instead of {@link Double}.</li>
+ * </ul>
*/
PROPERTY_TYPE,
/**
- * The type of a property, or type of elements if the property is a collection. This is the
- * same than {@link #PROPERTY_TYPE} except that collections are handled in a special way:
- * if the property is a collection, then the value is the type of <em>elements</em> in that
- * collection.
+ * The specialized type of a property, or type of elements if the property is a collection.
+ * This is the same type than {@link #PROPERTY_TYPE} except for the following:
*
- * {@note Current implementation has an additional slight difference: if the getter method
- * in the implementation class declares a more specific return value than the getter
- * method in the interface, and if the setter method (if any) expects the same specialized
- * type, then <code>ELEMENT_TYPE</code> will use that specialized type. This is different
- * than <code>PROPERTY_TYPE</code> which always use the type declared in the interface.}
+ * <ul>
+ * <li>If the property is a collection, then the element type is the type of <em>elements</em> in that
+ * collection. For example if the property type is {@code Collection<String>}, then the element type
+ * is {@code String}.</li>
+ * <li>If the implementation declares a more specific property type than the interface (as allowed by
+ * <cite>covariant return type</cite>), then the element type will be that specialized type.</li>
+ * </ul>
*/
ELEMENT_TYPE,
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -99,6 +99,16 @@ public class ISOMetadata extends Modifia
return MetadataStandard.ISO_19115;
}
+
+
+
+ // --------------------------------------------------------------------------------------
+ // Code below this point also appears in other IdentifiedObject implementations.
+ // If this code is modified, consider revisiting also the following classes:
+ //
+ // * org.apache.sis.metadata.iso.identification.DefaultRepresentativeFraction
+ // --------------------------------------------------------------------------------------
+
/**
* {@inheritDoc}
*/
@@ -170,10 +180,8 @@ public class ISOMetadata extends Modifia
/**
* Sets an unique identifier.
* This method is invoked automatically by JAXB and should never be invoked explicitely.
- *
- * @throws IllegalArgumentException If the UUID is already assigned to an other object.
*/
- private void setUUID(String id) {
+ private void setUUID(final String id) {
/*
* IdentifierMapWithSpecialCases will take care of converting the String to UUID if possible,
* or will store the value as a plain String if it can not be converted. In the later case, a
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -20,9 +20,11 @@ import java.net.URI;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.InternationalString;
import org.opengis.metadata.identification.BrowseGraphic;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.jaxb.gmx.MimeFileTypeAdapter;
/**
@@ -32,7 +34,7 @@ import org.apache.sis.metadata.iso.ISOMe
* @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_BrowseGraphic_Type", propOrder = {
@@ -171,6 +173,7 @@ public class DefaultBrowseGraphic extend
*/
@Override
@XmlElement(name = "fileType")
+ @XmlJavaTypeAdapter(MimeFileTypeAdapter.class)
public String getFileType() {
return fileType;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -16,15 +16,28 @@
*/
package org.apache.sis.metadata.iso.identification;
+import java.util.Collection;
+import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import org.opengis.metadata.Identifier;
import org.opengis.metadata.identification.RepresentativeFraction;
+import org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCases;
import org.apache.sis.internal.jaxb.gco.GO_Integer64;
+import org.apache.sis.internal.util.CheckedArrayList;
+import org.apache.sis.xml.IdentifierMap;
+import org.apache.sis.xml.IdentifierSpace;
+import org.apache.sis.xml.IdentifiedObject;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
+import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
+
/**
* A scale defined as the inverse of a denominator.
@@ -38,12 +51,12 @@ import org.apache.sis.util.resources.Err
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.4)
- * @version 0.3
+ * @version 0.4
* @module
*/
@XmlType(name = "MD_RepresentativeFraction_Type")
@XmlRootElement(name = "MD_RepresentativeFraction")
-public class DefaultRepresentativeFraction extends Number implements RepresentativeFraction {
+public class DefaultRepresentativeFraction extends Number implements RepresentativeFraction, IdentifiedObject {
/**
* Serial number for compatibility with different versions.
*/
@@ -55,6 +68,12 @@ public class DefaultRepresentativeFracti
private long denominator;
/**
+ * All identifiers associated with this metadata, or {@code null} if none.
+ * This field is initialized to a non-null value when first needed.
+ */
+ private Collection<Identifier> identifiers;
+
+ /**
* Creates a uninitialized representative fraction.
* The {@linkplain #getDenominator() denominator} is initially zero
* and the {@linkplain #doubleValue() double value} is NaN.
@@ -211,4 +230,78 @@ public class DefaultRepresentativeFracti
public int hashCode() {
return (int) denominator;
}
+
+
+
+
+ // --------------------------------------------------------------------------------------
+ // Code below this point is basically a copy-and-paste of ISOMetadata, with some edition.
+ // The JAXB attributes defined here shall be the same than the ISOMetadata ones.
+ // --------------------------------------------------------------------------------------
+
+ /**
+ * Returns all identifiers associated to this object, or an empty collection if none.
+ * Those identifiers are marshalled in XML as {@code id} or {@code uuid} attributes.
+ */
+ @Override
+ public Collection<Identifier> getIdentifiers() {
+ if (identifiers == null) {
+ identifiers = new CheckedArrayList<Identifier>(Identifier.class);
+ }
+ return identifiers;
+ }
+
+ /**
+ * Returns a map view of the {@linkplain #getIdentifiers() identifiers} collection as (<var>authority</var>,
+ * <var>code</var>) entries. That map is <cite>live</cite>: changes in the identifiers list will be reflected
+ * in the map, and conversely.
+ */
+ @Override
+ public IdentifierMap getIdentifierMap() {
+ return new IdentifierMapWithSpecialCases(getIdentifiers());
+ }
+
+ /**
+ * Invoked by JAXB for fetching the unique identifier unique for the XML document.
+ *
+ * @see org.apache.sis.metadata.iso.ISOMetadata#getID()
+ */
+ @XmlID
+ @XmlAttribute // Defined in "gco" as unqualified attribute.
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String getID() {
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(IdentifierSpace.ID);
+ }
+
+ /**
+ * Invoked by JAXB for specifying the unique identifier.
+ *
+ * @see org.apache.sis.metadata.iso.ISOMetadata#setID(String)
+ */
+ private void setID(String id) {
+ id = CharSequences.trimWhitespaces(id);
+ if (id != null && !id.isEmpty()) {
+ getIdentifierMap().putSpecialized(IdentifierSpace.ID, id);
+ }
+ }
+
+ /**
+ * Invoked by JAXB for fetching the unique identifier unique "worldwide".
+ *
+ * @see org.apache.sis.metadata.iso.ISOMetadata#getUUID()
+ */
+ @XmlAttribute // Defined in "gco" as unqualified attribute.
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String getUUID() {
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(IdentifierSpace.UUID);
+ }
+
+ /**
+ * Invoked by JAXB for specifying the unique identifier.
+ *
+ * @see org.apache.sis.metadata.iso.ISOMetadata#setUUID(String)
+ */
+ private void setUUID(final String id) {
+ getIdentifierMap().put(IdentifierSpace.UUID, id);
+ }
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -68,6 +68,20 @@ public class DefaultResolution extends I
}
/**
+ * Creates a new resolution initialized to the given scale.
+ *
+ * @param scale The scale, or {@code null} if none.
+ *
+ * @since 0.4
+ */
+ public DefaultResolution(final RepresentativeFraction scale) {
+ scaleOrDistance = scale;
+ }
+
+ // Note: there is not yet DefaultResolution(double) method because
+ // we need to update the Unit Of Measurement package first.
+
+ /**
* Constructs a new instance initialized with the values from the specified metadata object.
* This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the
* given object are not recursively copied.
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -63,6 +63,8 @@ public strictfp class LoggingWatcher ext
* for the log messages before the tests are run. This installation will cause the
* {@link #isLoggable(LogRecord)} method to be invoked when a message is logged.
*
+ * @param description A description of the JUnit test which is starting.
+ *
* @see #isLoggable(LogRecord)
*/
@Override
@@ -75,6 +77,8 @@ public strictfp class LoggingWatcher ext
/**
* Invoked when a test method finishes (whether passing or failing)
* This method removes the filter which had been set for testing purpose.
+ *
+ * @param description A description of the JUnit test that finished.
*/
@Override
public final void finished(final FrameworkMethod method) {
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -19,6 +19,7 @@ package org.apache.sis.metadata.iso.iden
import javax.xml.bind.JAXBException;
import org.apache.sis.xml.XML;
import org.apache.sis.metadata.iso.LoggingWatcher;
+import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Rule;
import org.junit.Test;
@@ -34,6 +35,7 @@ import static org.apache.sis.test.Assert
* @version 0.3
* @module
*/
+@DependsOn(DefaultRepresentativeFractionTest.class)
public final strictfp class DefaultResolutionTest extends TestCase {
/**
* A JUnit {@linkplain Rule rule} for listening to log events. This field is public
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.4
* @module
*/
@Suite.SuiteClasses({
@@ -34,7 +34,9 @@ import org.junit.BeforeClass;
org.apache.sis.metadata.iso.citation.DefaultCitationDateTest.class,
org.apache.sis.metadata.iso.citation.DefaultCitationTest.class,
org.apache.sis.metadata.iso.identification.DefaultKeywordsTest.class,
+ org.apache.sis.metadata.iso.identification.DefaultRepresentativeFractionTest.class,
org.apache.sis.metadata.iso.identification.DefaultResolutionTest.class,
+ org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
org.apache.sis.metadata.iso.spatial.DefaultGeorectifiedTest.class,
org.apache.sis.metadata.iso.maintenance.DefaultScopeDescriptionTest.class,
org.apache.sis.metadata.iso.quality.AbstractElementTest.class,
@@ -42,6 +44,7 @@ import org.junit.BeforeClass;
// Classes using Java reflection.
org.apache.sis.metadata.PropertyInformationTest.class,
org.apache.sis.metadata.PropertyAccessorTest.class,
+ org.apache.sis.metadata.SpecialCasesTest.class,
org.apache.sis.metadata.NameMapTest.class,
org.apache.sis.metadata.TypeMapTest.class,
org.apache.sis.metadata.InformationMapTest.class,
Modified: sis/trunk/core/sis-referencing/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/pom.xml?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/pom.xml (original)
+++ sis/trunk/core/sis-referencing/pom.xml Thu Aug 15 17:37:30 2013
@@ -120,12 +120,12 @@ Implementations of Coordinate Reference
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
</dependency>
-
- <!-- Test dependencies -->
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
Modified: sis/trunk/core/sis-utility/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/pom.xml?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/pom.xml (original)
+++ sis/trunk/core/sis-utility/pom.xml Thu Aug 15 17:37:30 2013
@@ -171,6 +171,8 @@ Miscellaneous utilities.
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -43,7 +43,7 @@ import org.apache.sis.xml.ReferenceResol
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.07)
- * @version 0.3
+ * @version 0.4
* @module
*/
public final class Context extends MarshalContext {
@@ -68,6 +68,20 @@ public final class Context extends Marsh
public static final int SUBSTITUTE_COUNTRY = 4;
/**
+ * The bit flag for enabling substitution of filenames by character strings.
+ *
+ * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
+ */
+ public static final int SUBSTITUTE_FILENAME = 8;
+
+ /**
+ * The bit flag for enabling substitution of mime types by character strings.
+ *
+ * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
+ */
+ public static final int SUBSTITUTE_MIMETYPE = 16;
+
+ /**
* The thread-local context. Elements are created in the constructor, and removed in a
* {@code finally} block by the {@link #finish()} method. This {@code ThreadLocal} shall
* not contain any value when no (un)marshalling is in progress.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -41,7 +41,7 @@ import org.apache.sis.internal.jaxb.gmd.
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
* @module
*
* @see StringAdapter
@@ -71,7 +71,7 @@ public final class CharSequenceAdapter e
* in a XML file or stream. JAXB calls automatically this method at marshalling time.
*
* @param value The string value.
- * @return The wrapper for the given character sequence.
+ * @return The wrapper for the given character sequence, or {@code null}.
*/
@Override
public GO_CharacterString marshal(final CharSequence value) {
@@ -83,11 +83,11 @@ public final class CharSequenceAdapter e
* in a XML file or stream.
*
* @param value The character representation of the object being marshalled.
- * @return The wrapper for the given character sequence.
+ * @return The wrapper for the given character sequence, or {@code null}.
*/
public static GO_CharacterString wrap(CharSequence value) {
if (value instanceof String) {
- return wrap(value, (String) value); // Slightly more efficient variant of this method.
+ return wrap(Context.current(), value, (String) value); // Slightly more efficient variant of this method.
}
/*
* <gmd:someElement xsi:type="gmd:PT_FreeText_PropertyType">
@@ -147,25 +147,38 @@ public final class CharSequenceAdapter e
* This method is a copy of {@link #wrap(CharSequence)} simplified for the case when we know
* that the character sequence being marshalled is a string.
*
- * @param object The object being marshalled (e.g. {@code URI} or {@code Locale}).
- * @param string The string representation of the object being marshalled.
- * @return The wrapper for the given character sequence.
+ * @param context The current (un)marshalling context, or {@code null} if none.
+ * @param object The object being marshalled (e.g. {@code URI} or {@code Locale}).
+ * @param string The string representation of the object being marshalled.
+ * @return The wrapper for the given character sequence, or {@code null}.
*/
- public static GO_CharacterString wrap(final Object object, String string) {
+ public static GO_CharacterString wrap(final Context context, final Object object, final String string) {
+ final CharSequence text = value(context, object, string);
+ return (text != null) ? new GO_CharacterString(text) : null;
+ }
+
+ /**
+ * Same as {@link #wrap(Object, String)}, but returns directly the {@link GO_CharacterString#text}
+ * value without wrapping in a {@code GO_CharacterString} instance.
+ *
+ * @param context The current (un)marshalling context, or {@code null} if none.
+ * @param object The object being marshalled (e.g. {@code URI} or {@code Locale}).
+ * @param string The string representation of the object being marshalled.
+ * @return The text value for the given character sequence, or {@code null}.
+ */
+ public static CharSequence value(final Context context, final Object object, String string) {
string = CharSequences.trimWhitespaces(string);
if (string == null || string.isEmpty()) {
return null;
}
- CharSequence value = string;
- final Context context = Context.current();
final XLink linkage = Context.resolver(context).anchor(context, object, string);
if (linkage != null) {
if (linkage instanceof Anchor) {
- value = (Anchor) linkage;
+ return (Anchor) linkage;
} else {
- value = new Anchor(linkage, string);
+ return new Anchor(linkage, string);
}
}
- return new GO_CharacterString(value);
+ return string;
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -16,32 +16,77 @@
*/
package org.apache.sis.internal.jaxb.gco;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
-
import org.apache.sis.xml.Namespaces;
-import org.apache.sis.internal.jaxb.gmd.PT_FreeText;
-import org.apache.sis.internal.jaxb.gmd.LanguageCode;
-import org.apache.sis.internal.jaxb.gmd.Country;
+import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.gmx.Anchor;
+import org.apache.sis.internal.jaxb.gmx.FileName;
+import org.apache.sis.internal.jaxb.gmx.MimeFileType;
import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.resources.Messages;
/**
- * JAXB wrapper for string value in a {@code <gco:CharacterString>} or {@code <gmx:Anchor>} element,
- * for ISO-19139 compliance.
+ * JAXB wrapper for string value in a {@code <gco:CharacterString>}, {@code <gmx:Anchor>},
+ * {@code <gmx:FileName>} or {@code <gmx:MimeFileType>} element, for ISO-19139 compliance.
+ *
+ * <p>{@code FileName} and {@code MimeFileType} are possible substitutions for {@code CharacterString}.
+ * They make sense only in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic} or
+ * other classes using URI, but the XML schema does not prevent their usage in place of other strings.
+ * Consequently we unconditionally accept {@code FileName} and {@code MimeFileType} at unmarshalling time.
+ * However marshalling will use the appropriate element for the kind of property to marshal.</p>
*
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
* @module
*
* @see org.apache.sis.internal.jaxb.gmd.PT_FreeText
*/
@XmlType(name = "CharacterString_PropertyType")
-@XmlSeeAlso({PT_FreeText.class, LanguageCode.class, Country.class})
+@XmlSeeAlso({
+ org.apache.sis.internal.jaxb.gmd.PT_FreeText.class,
+ org.apache.sis.internal.jaxb.gmd.LanguageCode.class,
+ org.apache.sis.internal.jaxb.gmd.Country.class
+})
public class GO_CharacterString {
+ /*
+ * Numerical values below are ordered: if two or more values are defined (thoerically not legal,
+ * but we try to be robust), the value associated to the highest constant has precedence.
+ */
+ /**
+ * Value assigned to {@link #type} if the character string
+ * shall be marshalled as a {@code <gmx:MimeFileType>} element.
+ */
+ public static final byte MIME_TYPE = 1;
+
+ /**
+ * Value assigned to {@link #type} if the character string
+ * shall be marshalled as a {@code <gmx:FileName>} element.
+ */
+ public static final byte FILENAME = 2;
+
+ /**
+ * Value assigned to {@link #type} if the current {@link #text}
+ * has been found in a {@code <gco:CharacterString>} element.
+ */
+ private static final byte ANCHOR = 3;
+
+ /**
+ * The XML element names for each possible {@link #type} values.
+ */
+ private static final String[] NAMES = new String[4];
+ static {
+ NAMES[0] = "CharacterString";
+ NAMES[MIME_TYPE] = "MimeFileType";
+ NAMES[FILENAME] = "FileName";
+ NAMES[ANCHOR] = "Anchor";
+ }
+
/**
* The text or anchor value, or {@code null} if none. May be an instance
* of {@link Anchor}, which needs to be handled in a special way.
@@ -49,13 +94,22 @@ public class GO_CharacterString {
private CharSequence text;
/**
+ * 0 if the text shall be marshalled as a {@code <gco:CharacterString>} or an anchor,
+ * or one of the static constants in this class otherwise.
+ *
+ * @see #FILENAME
+ * @see #MIME_TYPE
+ */
+ public byte type;
+
+ /**
* Empty constructor for JAXB and subclasses.
*/
- protected GO_CharacterString() {
+ public GO_CharacterString() {
}
/**
- * Builds an wrapper for the given text.
+ * Builds a wrapper for the given text.
*
* @param text The string to marshal, or {@code null} if none.
*/
@@ -64,38 +118,118 @@ public class GO_CharacterString {
}
/**
- * Builds an wrapper as a copy of the given one.
+ * Sets the {@link #text} field to the given value.
+ * If the given value overwrites a previous one, a warning is emitted.
*
- * @param text The wrapper to copy, or {@code null} if none.
+ * @param value The value to set.
+ * @param property 0 or one of the {@link #MIME_TYPE}, {@link #FILENAME} or {@link #ANCHOR} constants.
*/
- protected GO_CharacterString(final GO_CharacterString text) {
- if (text != null) {
- this.text = text.text;
+ private void setText(final CharSequence value, byte property) {
+ if (text != null && !value.equals(text)) {
+ /*
+ * The given value overwrite a previous one. Determine which value will be discarded
+ * using the 'type' value as a criterion, then emit a warning.
+ */
+ byte discarded = type;
+ boolean noset = false;
+ if (discarded > property) {
+ discarded = property;
+ property = type;
+ noset = true;
+ }
+ final Context context = Context.current();
+ final LogRecord record = Messages.getResources(context != null ? context.getLocale() : null)
+ .getLogRecord(Level.WARNING, Messages.Keys.DiscardedExclusiveProperty_2,
+ NAMES[discarded], NAMES[property]);
+ record.setSourceClassName(getClass().getCanonicalName());
+ record.setSourceMethodName("setText");
+ Context.warningOccured(context, value, record);
+ if (noset) {
+ return;
+ }
}
+ text = value;
+ type = property;
}
/**
- * Returns the text. This method is called by JAXB at marshalling time.
+ * Returns the text in a {@code <gco:CharacterString>} element, or {@code null} if none.
*
* @return The text, or {@code null}.
*/
@XmlElement(name = "CharacterString")
public final String getCharacterString() {
- final CharSequence text = this.text;
- return (text == null || text instanceof Anchor) ? null : text.toString();
+ if (type == 0) {
+ final CharSequence text = this.text;
+ if (text != null && !(text instanceof Anchor)) {
+ return text.toString();
+ }
+ }
+ return null;
}
/**
* Sets the value to the given string. This method is called by JAXB at unmarshalling time.
*
- * @param text The new text.
+ * @param value The new text.
*/
- public final void setCharacterString(String text) {
- text = CharSequences.trimWhitespaces(text);
- if (text != null && text.isEmpty()) {
- text = null;
+ public final void setCharacterString(String value) {
+ value = CharSequences.trimWhitespaces(value);
+ if (value != null && !value.isEmpty()) {
+ setText(value, (byte) 0);
+ }
+ }
+
+ /**
+ * Returns the text in a {@code <gmx:FileName>} element, or {@code null} if none.
+ */
+ @XmlElement(name = "FileName", namespace = Namespaces.GMX)
+ final FileName getFileName() {
+ if (type == FILENAME) {
+ final CharSequence text = this.text;
+ if (text != null && !(text instanceof Anchor)) {
+ return new FileName(text.toString());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Invoked by JAXB for setting the filename.
+ */
+ final void setFileName(final FileName file) {
+ if (file != null) {
+ final String value = CharSequences.trimWhitespaces(file.toString());
+ if (value != null && !value.isEmpty()) {
+ setText(value, FILENAME);
+ }
+ }
+ }
+
+ /**
+ * Returns the text in a {@code <gmx:MimeFileType>} element, or {@code null} if none.
+ */
+ @XmlElement(name = "MimeFileType", namespace = Namespaces.GMX)
+ final MimeFileType getMimeFileType() {
+ if (type == MIME_TYPE) {
+ final CharSequence text = this.text;
+ if (text != null && !(text instanceof Anchor)) {
+ return new MimeFileType(text.toString());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Invoked by JAXB for setting the MIME type.
+ */
+ final void setMimeFileType(final MimeFileType type) {
+ if (type != null) {
+ final String value = CharSequences.trimWhitespaces(type.toString());
+ if (value != null && !value.isEmpty()) {
+ setText(value, MIME_TYPE);
+ }
}
- this.text = text;
}
/**
@@ -117,7 +251,7 @@ public class GO_CharacterString {
* @param anchor The new anchor.
*/
public final void setAnchor(final Anchor anchor) {
- this.text = anchor;
+ setText(anchor, ANCHOR);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -34,11 +34,11 @@ import org.apache.sis.internal.jaxb.Cont
* @version 0.3
* @module
*/
-public final class StringAdapter extends XmlAdapter<GO_CharacterString, String> {
+public class StringAdapter extends XmlAdapter<GO_CharacterString, String> {
/**
- * Empty constructor for JAXB.
+ * Empty constructor for JAXB or subclasses.
*/
- private StringAdapter() {
+ public StringAdapter() {
}
/**
@@ -105,6 +105,6 @@ public final class StringAdapter extends
*/
@Override
public GO_CharacterString marshal(final String value) {
- return CharSequenceAdapter.wrap(value, value);
+ return CharSequenceAdapter.wrap(Context.current(), value, value);
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -23,20 +23,19 @@ import org.apache.sis.internal.jaxb.Cont
/**
- * JAXB adapter wrapping a URI value with a {@code <gco:CharacterString>} element,
- * for ISO-19139 compliance.
+ * JAXB adapter wrapping a URI value with a {@code <gmx:FileName>} element, for ISO-19139 compliance.
*
* @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
*/
public final class URIAdapter extends XmlAdapter<GO_CharacterString, URI> {
/**
* Empty constructor for JAXB.
*/
- private URIAdapter() {
+ public URIAdapter() {
}
/**
@@ -44,7 +43,7 @@ public final class URIAdapter extends Xm
* JAXB calls automatically this method at unmarshalling time.
*
* @param value The wrapper for the URI value, or {@code null}.
- * @return An {@link URI} which represents the URI value, or {@code null}.
+ * @return A {@link URI} which represents the URI value, or {@code null}.
* @throws URISyntaxException If the string is not a valid URI.
*/
@Override
@@ -66,6 +65,16 @@ public final class URIAdapter extends Xm
*/
@Override
public GO_CharacterString marshal(final URI value) {
- return (value != null) ? CharSequenceAdapter.wrap(value, value.toString()) : null;
+ if (value != null) {
+ final Context context = Context.current();
+ final GO_CharacterString wrapper = CharSequenceAdapter.wrap(context, value, value.toString());
+ if (wrapper != null) {
+ if (!Context.isFlagSet(context, Context.SUBSTITUTE_FILENAME)) {
+ wrapper.type = GO_CharacterString.FILENAME;
+ }
+ return wrapper;
+ }
+ }
+ return null;
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -79,7 +79,7 @@
* @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
*
* @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -45,7 +45,7 @@ import org.apache.sis.internal.jaxb.gco.
* @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
*/
@XmlType(name = "Country_PropertyType")
@@ -63,10 +63,10 @@ public final class Country extends GO_Ch
}
/**
- * Builds a {@code <gco:CharacterString>} element.
+ * Builds a {@code <gco:Country>} element.
* For private use by {@link #create(Context, Locale)} only.
*/
- private Country(final GO_CharacterString code) {
+ private Country(final CharSequence code) {
super(code);
}
@@ -99,7 +99,7 @@ public final class Country extends GO_Ch
* Marshal the locale as a <gco:CharacterString> instead than <Country>,
* using the user-supplied anchors if any.
*/
- final GO_CharacterString string = CharSequenceAdapter.wrap(locale, codeListValue);
+ final CharSequence string = CharSequenceAdapter.value(context, locale, codeListValue);
if (string != null) {
return new Country(string);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -61,10 +61,10 @@ public final class LanguageCode extends
}
/**
- * Builds a {@code <gco:CharacterString>} element.
+ * Builds a {@code <gco:LanguageCode>} element.
* For private use by {@link #create(Context, Locale)} only.
*/
- private LanguageCode(final GO_CharacterString code) {
+ private LanguageCode(final CharSequence code) {
super(code);
}
@@ -97,7 +97,7 @@ public final class LanguageCode extends
* Marshal the locale as a <gco:CharacterString> instead than <LanguageCode>,
* using the user-supplied anchors if any.
*/
- final GO_CharacterString string = CharSequenceAdapter.wrap(locale, codeListValue);
+ final CharSequence string = CharSequenceAdapter.value(context, locale, codeListValue);
if (string != null) {
return new LanguageCode(string);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -96,6 +96,9 @@ public final class Anchor extends XLink
/**
* Returns the text as a string, or {@code null} if none.
+ *
+ * @param locale Ignored in current implementation.
+ * @return The anchor text, or {@code null} if none.
*/
@Override
public String toString(final Locale locale) {
@@ -120,7 +123,7 @@ public final class Anchor extends XLink
/**
* Returns the sequence of characters in the given range of index.
- * The returned object still an anchor with the same attribute values.
+ * The returned object is an anchor with the same attribute values.
* It is caller responsibility to determine if those attributes are still
* appropriate for the sub-sequence.
*/
@@ -131,7 +134,7 @@ public final class Anchor extends XLink
original = "";
}
final String substring = original.substring(start, end);
- if (substring == original) {
+ if (substring == original) { // Identity comparison is ok here.
return this;
}
return new Anchor(this, substring);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -20,7 +20,7 @@
*
* @author Guilhem Legal (Geomatys)
* @since 0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
* @module
*
* @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -54,7 +54,7 @@ public final class LocalizedParseExcepti
private final Locale locale;
/**
- * The resources key as one of the {@link Errors.Keys} constant.
+ * The resources key as one of the {@code Errors.Keys} constant.
*/
private final int key;
@@ -68,7 +68,7 @@ public final class LocalizedParseExcepti
* and message arguments. This is the most generic constructor.
*
* @param locale The locale for {@link #getLocalizedMessage()}.
- * @param key The resource key as one of the {@link Errors.Keys} constant.
+ * @param key The resource key as one of the {@code Errors.Keys} constant.
* @param arguments The value of {@link #arguments(String, ParsePosition)}.
* @param errorOffset The position where the error is found while parsing.
*/
@@ -85,7 +85,7 @@ public final class LocalizedParseExcepti
* index, and uses that word as the single argument associated to the resource key.
*
* @param locale The locale for {@link #getLocalizedMessage()}.
- * @param key The resource key as one of the {@link Errors.Keys} constant.
+ * @param key The resource key as one of the {@code Errors.Keys} constant.
* @param text The full text that {@code Format} failed to parse.
* @param errorOffset The position where the error is found while parsing.
*/
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -389,7 +389,7 @@ public abstract class CompoundFormat<T>
} else if (valueType == Date.class) {
final DateFormat format;
if (!Locale.ROOT.equals(locale)) {
- format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale);
+ format = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale);
} else {
format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ROOT);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java?rev=1514393&r1=1514392&r2=1514393&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java [UTF-8] Thu Aug 15 17:37:30 2013
@@ -241,7 +241,7 @@ public class Angle implements Comparable
private static Format getAngleFormat() {
assert Thread.holdsLock(Angle.class);
if (format == null) {
- format = AngleFormat.getInstance(Locale.ROOT);
+ format = new AngleFormat(Locale.ROOT);
}
return format;
}