sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1496857 - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/...
Date Wed, 26 Jun 2013 09:36:15 GMT
Author: desruisseaux
Date: Wed Jun 26 09:36:13 2013
New Revision: 1496857

URL: http://svn.apache.org/r1496857
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/
      - copied from r1496855, sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/
      - copied from r1496855, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
      - copied unchanged from r1496855, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
      - copied, changed from r1496855, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
      - copied unchanged from r1496855, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/GM_Object.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/package-info.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/XmlUtilitiesTest.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1495603-1496855

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/GM_Object.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/GM_Object.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/GM_Object.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/GM_Object.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -83,7 +83,7 @@ public class GM_Object extends XmlAdapte
      * The default implementation returns {@code null} if all cases. Subclasses
      * must override this method in order to provide useful marshalling.
      *
-     * @param value The value to marshall.
+     * @param value The value to marshal.
      * @return The adapter which covers the geometry value.
      */
     protected GM_Object wrap(Geometry value) {

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -18,7 +18,6 @@ package org.apache.sis.metadata.iso;
 
 import java.util.Map;
 import java.util.Locale;
-import java.util.Collection;
 import java.util.logging.Level;
 import java.io.Serializable;
 import javax.xml.bind.annotation.XmlElement;
@@ -32,7 +31,6 @@ import org.opengis.util.InternationalStr
 import org.apache.sis.util.Locales;
 import org.apache.sis.util.Immutable;
 import org.apache.sis.util.Deprecable;
-import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Messages;
@@ -334,7 +332,7 @@ public class ImmutableIdentifier impleme
          * identifier if there is any, otherwise we take the shortest title.
          */
         if (codeSpace == null && authority instanceof Citation) {
-            codeSpace = getCodeSpace((Citation) authority);
+            codeSpace = Citations.getIdentifier((Citation) authority);
         }
         /*
          * Store the definitive reference to the attributes. Note that casts are performed
only
@@ -357,50 +355,6 @@ public class ImmutableIdentifier impleme
     }
 
     /**
-     * Returns the shortest title inferred from the specified authority.
-     * This is used both for creating a generic name, or for inferring a
-     * default identifier code space.
-     */
-    private static InternationalString getShortestTitle(final Citation authority) {
-        InternationalString title = authority.getTitle();
-        int length = title.length();
-        final Collection<? extends InternationalString> alt = authority.getAlternateTitles();
-        if (alt != null) {
-            for (final InternationalString candidate : alt) {
-                final int candidateLength = candidate.length();
-                if (candidateLength > 0 && candidateLength < length) {
-                    title = candidate;
-                    length = candidateLength;
-                }
-            }
-        }
-        return title;
-    }
-
-    /**
-     * Tries to get a code space from the specified authority. This method scans first
-     * through the identifier, then through the titles if no suitable identifier were found.
-     */
-    private static String getCodeSpace(final Citation authority) {
-        if (authority != null) {
-            final Collection<? extends Identifier> identifiers = authority.getIdentifiers();
-            if (identifiers != null) {
-                for (final Identifier id : identifiers) {
-                    final String identifier = id.getCode();
-                    if (CharSequences.isUnicodeIdentifier(identifier)) {
-                        return identifier;
-                    }
-                }
-            }
-            final String title = getShortestTitle(authority).toString(Locale.ROOT);
-            if (CharSequences.isUnicodeIdentifier(title)) {
-                return title;
-            }
-        }
-        return null;
-    }
-
-    /**
      * Returns a SIS identifier implementation with the values of the given arbitrary implementation.
      * This method performs the first applicable actions in the following choices:
      *

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -193,13 +193,34 @@ public final class Citations extends Sta
     }
 
     /**
-     * Returns the shortest identifier for the specified citation, or the title if there
is
-     * no identifier. This method is useful for extracting the namespace from an authority,
-     * for example {@code "EPSG"}.
+     * Infers an identifier from the given citation, or returns {@code null} if no identifier
has been found.
+     * This method is useful for extracting the namespace from an authority, for example
{@code "EPSG"}.
+     * The implementation performs the following choices:
+     *
+     * <ul>
+     *   <li>If the given citation is {@code null}, then this method returns {@code
null}.</li>
+     *   <li>Otherwise if the citation contains at least one {@linkplain Citation#getIdentifiers()
identifier}, then:
+     *     <ul>
+     *       <li>If at least one identifier is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
+     *           unicode identifier}, then the shortest of those identifiers is returned.</li>
+     *       <li>Otherwise the shortest identifier is returned, despite not being a
Unicode identifier.</li>
+     *     </ul></li>
+     *   <li>Otherwise if the citation contains at least one {@linkplain Citation#getTitle()
title} or
+     *       {@linkplain Citation#getAlternateTitles() alternate title}, then:
+     *     <ul>
+     *       <li>If at least one title is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
+     *           unicode identifier}, then the shortest of those titles is returned.</li>
+     *       <li>Otherwise the shortest title is returned, despite not being a Unicode
identifier.</li>
+     *     </ul></li>
+     *   <li>Otherwise this method returns {@code null}.</li>
+     * </ul>
+     *
+     * This method searches in alternate titles as a fallback because ISO specification said
+     * that those titles are often used for abbreviations.
      *
      * @param  citation The citation for which to get the identifier, or {@code null}.
-     * @return The shortest identifier of the given citation, or {@code null} if the
-     *         given citation was null or doesn't declare any identifier or title.
+     * @return An identifier for the given citation, or {@code null} if the given citation
is null
+     *         or does not declare any identifier or title.
      */
     public static String getIdentifier(final Citation citation) {
         return org.apache.sis.internal.util.Citations.getIdentifier(citation);

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -41,7 +41,7 @@ import org.apache.sis.xml.Namespaces;
  * @module
  */
 @XmlType(name = "MD_CoverageDescription_Type", propOrder = {
-// TODO    "attributeDescription",
+    "attributeDescription",
     "contentType",
     "dimensions",
     "rangeElementDescriptions"
@@ -135,7 +135,7 @@ public class DefaultCoverageDescription 
      * Returns the description of the attribute described by the measurement value.
      */
     @Override
-    // TODO @XmlElement(name = "attributeDescription", required = true)
+    @XmlElement(name = "attributeDescription", required = true)
     public RecordType getAttributeDescription() {
         return attributeDescription;
     }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -110,7 +110,7 @@
     @XmlJavaTypeAdapter(LocaleAdapter.class),
     @XmlJavaTypeAdapter(InternationalStringAdapter.class),
     @XmlJavaTypeAdapter(GO_GenericName.class),
-//  @XmlJavaTypeAdapter(GO_RecordType.class), // TODO
+    @XmlJavaTypeAdapter(GO_RecordType.class),
     @XmlJavaTypeAdapter(GO_Boolean.class),        @XmlJavaTypeAdapter(type=boolean.class,
value=GO_Boolean.class),
     @XmlJavaTypeAdapter(GO_Decimal.class),        @XmlJavaTypeAdapter(type=double.class,
 value=GO_Decimal.class),
     @XmlJavaTypeAdapter(GO_Integer.class),        @XmlJavaTypeAdapter(type=int.class,   
 value=GO_Integer.class),

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -126,7 +126,7 @@ public class DefaultTemporalExtent exten
      * @return The content date.
      */
     @Override
-    // TODO @XmlElement(name = "extent", required = true)
+    @XmlElement(name = "extent", required = true)
     public TemporalPrimitive getExtent() {
         return extent;
     }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -45,7 +45,7 @@ import org.apache.sis.internal.metadata.
 @XmlType(name = "EX_VerticalExtent_Type", propOrder = {
     "minimumValue",
     "maximumValue",
-// TODO    "verticalCRS"
+    "verticalCRS"
 })
 @XmlRootElement(name = "EX_VerticalExtent")
 public class DefaultVerticalExtent extends ISOMetadata implements VerticalExtent {
@@ -178,7 +178,7 @@ public class DefaultVerticalExtent exten
      * identification includes unit of measure.
      */
     @Override
-    // TODO @XmlElement(name = "verticalCRS", required = true)
+    @XmlElement(name = "verticalCRS", required = true)
     public VerticalCRS getVerticalCRS() {
         return verticalCRS;
     }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -143,8 +143,8 @@
     @XmlJavaTypeAdapter(EX_VerticalExtent.class),
     @XmlJavaTypeAdapter(GM_Object.class),
     @XmlJavaTypeAdapter(MD_Identifier.class),
-//  @XmlJavaTypeAdapter(SC_VerticalCRS.class), // TODO
-//  @XmlJavaTypeAdapter(TM_Primitive.class),   // TODO
+    @XmlJavaTypeAdapter(SC_VerticalCRS.class),
+    @XmlJavaTypeAdapter(TM_Primitive.class),
 
     // Java types, primitive types and basic OGC types handling
     @XmlJavaTypeAdapter(InternationalStringAdapter.class),
@@ -163,6 +163,6 @@ import javax.xml.bind.annotation.adapter
 
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.internal.jaxb.gco.*;
+import org.apache.sis.internal.jaxb.gml.*;
 import org.apache.sis.internal.jaxb.metadata.*;
-// TODO import org.apache.sis.internal.jaxb.referencing.*;
 import org.apache.sis.internal.jaxb.geometry.GM_Object;

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -37,7 +37,7 @@ import org.opengis.util.RecordType;
  * @module
  */
 @XmlType(name = "DQ_QuantitativeResult_Type", propOrder = {
-// TODO    "valueType",
+    "valueType",
     "valueUnit",
     "errorStatistic"
 })
@@ -138,7 +138,7 @@ public class DefaultQuantitativeResult e
      * Return the value type for reporting a data quality result, or {@code null} if none.
      */
     @Override
-    // TODO @XmlElement(name = "valueType")
+    @XmlElement(name = "valueType")
     public RecordType getValueType()  {
         return valueType;
     }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/package-info.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/package-info.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -143,7 +143,7 @@
     @XmlJavaTypeAdapter(StringAdapter.class),
     @XmlJavaTypeAdapter(InternationalStringAdapter.class),
     @XmlJavaTypeAdapter(GO_DateTime.class),
-//    @XmlJavaTypeAdapter(GO_RecordType.class), // TODO
+    @XmlJavaTypeAdapter(GO_RecordType.class),
     @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class)
 })
 package org.apache.sis.metadata.iso.quality;

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -53,7 +53,10 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.MetadataStandardTest.class,
     org.apache.sis.metadata.PrunerTest.class,
     org.apache.sis.metadata.AbstractMetadataTest.class,
-    org.apache.sis.metadata.iso.AllMetadataTest.class
+    org.apache.sis.metadata.iso.AllMetadataTest.class,
+
+    // XML marshalling
+    org.apache.sis.internal.jaxb.gml.TimePeriodTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -32,6 +32,11 @@ import javax.xml.bind.annotation.adapter
  * <p>This interface is mostly for handling extensions to metadata profile provided
as extension,
  * like the {@code FRA} extension for France provided in the {@code sis-metadata-fra} module.</p>
  *
+ * <p><b>WARNING:</b> there is currently no mechanism for ensuring that
the registration performed
+ * by an {@code AdapterReplacement} instance does not overwrite the registration performed
by an
+ * other {@code AdapterReplacement} instance. This is okay as long as the instances are defined
+ * only in SIS. However we will need to revisit this issue if we move this interface to public
API.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
@@ -44,8 +49,10 @@ public interface AdapterReplacement {
     /**
      * The system-wide provider of {@code AdapterReplacement} instances.
      * <strong>Every usage of this service loader must be synchronized.</strong>
-     * This loader is public for allowing modules to unregister their instance
-     * when the module is unloaded (e.g. from an OSGi container), as below:
+     * This loader is public for {@link org.apache.sis.xml.MarshallerPool} usage.
+     *
+     * <p>This loader needs to be cleared as below when modules are loaded or unloaded.
+     * This is done opportunistically by {@link TypeRegistration}.</p>
      *
      * {@preformat java
      *     synchronized (AdapterReplacement.PROVIDER) {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -137,7 +137,7 @@ public final class Context extends Marsh
      *     }
      * }
      *
-     * @param  bitMasks        A combination of {@link #MARSHALLING}, {@code #SUBSTITUTE_*}
or other bit masks.
+     * @param  bitMasks        A combination of {@link #MARSHALLING}, {@code SUBSTITUTE_*}
or other bit masks.
      * @param  locale          The locale, or {@code null} if unspecified.
      * @param  timezone        The timezone, or {@code null} if unspecified.
      * @param  schemas         The schemas root URL, or {@code null} if none.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -47,13 +47,24 @@ import org.apache.sis.internal.system.Sy
  */
 public abstract class TypeRegistration {
     /**
-     * The JAXB context, or {@code null} if not yet created.
+     * The JAXB context, or {@code null} if not yet created or if the classpath changed.
      */
     private static Reference<JAXBContext> context;
     static {
         SystemListener.add(new SystemListener(Modules.UTILITIES) {
             @Override protected void classpathChanged() {
-                context = null;
+                synchronized (TypeRegistration.class) {
+                    context = null;
+                }
+                /*
+                 * Opportunistically clears the AdapterReplacement.PROVIDER. We can not do
this work in the
+                 * AdapterReplacement interface because we can not declare static initializer
in interfaces.
+                 * This TypeRegistration class is an acceptable fallback because MarshallerPool
uses this
+                 * class before to use AdapterReplacement.
+                 */
+                synchronized (AdapterReplacement.PROVIDER) {
+                    AdapterReplacement.PROVIDER.reload();
+                }
             }
         });
     }
@@ -105,9 +116,8 @@ public abstract class TypeRegistration {
      * @throws JAXBException If an error occurred while creating the JAXB context.
      */
     public static synchronized JAXBContext getSharedContext() throws JAXBException {
-        final Reference<JAXBContext> ref = context; // Protect from changes by the
listener.
-        if (ref != null) {
-            final JAXBContext instance = ref.get();
+        if (context != null) {
+            final JAXBContext instance = context.get();
             if (instance != null) {
                 return instance;
             }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -27,6 +27,7 @@ import org.apache.sis.util.Static;
 
 import static org.apache.sis.util.CharSequences.equalsFiltered;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
+import static org.apache.sis.util.CharSequences.isUnicodeIdentifier;
 import static org.apache.sis.util.Characters.Filter.LETTERS_AND_DIGITS;
 
 
@@ -65,6 +66,15 @@ public final class Citations extends Sta
     }
 
     /**
+     * Returns a "unlocalized" string representation of the given international string,
+     * or {@code null} if none. This method is used by {@link #getIdentifier(Citation)},
+     * which is why we don't want the localized string.
+     */
+    private static String toString(final InternationalString title) {
+        return (title != null) ? trimWhitespaces(title.toString(Locale.ROOT)) : null;
+    }
+
+    /**
      * Returns {@code true} if at least one {@linkplain Citation#getTitle() title} or
      * {@linkplain Citation#getAlternateTitles() alternate title} in {@code c1} is leniently
      * equal to a title or alternate title in {@code c2}. The comparison is case-insensitive
@@ -223,15 +233,37 @@ public final class Citations extends Sta
     }
 
     /**
-     * Returns the shortest identifier for the specified citation, or the title if there
is
-     * no identifier. This method is useful for extracting the namespace from an authority,
-     * for example {@code "EPSG"}.
+     * Infers an identifier from the given citation, or returns {@code null} if no identifier
has been found.
+     * This method is useful for extracting the namespace from an authority, for example
{@code "EPSG"}.
+     * The implementation performs the following choices:
+     *
+     * <ul>
+     *   <li>If the given citation is {@code null}, then this method returns {@code
null}.</li>
+     *   <li>Otherwise if the citation contains at least one {@linkplain Citation#getIdentifiers()
identifier}, then:
+     *     <ul>
+     *       <li>If at least one identifier is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
+     *           unicode identifier}, then the shortest of those identifiers is returned.</li>
+     *       <li>Otherwise the shortest identifier is returned, despite not being a
Unicode identifier.</li>
+     *     </ul></li>
+     *   <li>Otherwise if the citation contains at least one {@linkplain Citation#getTitle()
title} or
+     *       {@linkplain Citation#getAlternateTitles() alternate title}, then:
+     *     <ul>
+     *       <li>If at least one title is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
+     *           unicode identifier}, then the shortest of those titles is returned.</li>
+     *       <li>Otherwise the shortest title is returned, despite not being a Unicode
identifier.</li>
+     *     </ul></li>
+     *   <li>Otherwise this method returns {@code null}.</li>
+     * </ul>
+     *
+     * This method searches in alternate titles as a fallback because ISO specification said
+     * that those titles are often used for abbreviations.
      *
      * @param  citation The citation for which to get the identifier, or {@code null}.
-     * @return The shortest identifier of the given citation, or {@code null} if the
-     *         given citation was null or doesn't declare any identifier or title.
+     * @return An identifier for the given citation, or {@code null} if the given citation
is null
+     *         or does not declare any identifier or title.
      */
     public static String getIdentifier(final Citation citation) {
+        boolean isUnicode = false; // Whether 'identifier' is a Unicode identifier.
         String identifier = null;
         if (citation != null) {
             final Iterator<? extends Identifier> it = iterator(citation.getIdentifiers());
@@ -241,18 +273,43 @@ public final class Citations extends Sta
                     final String candidate = trimWhitespaces(id.getCode());
                     if (candidate != null) {
                         final int length = candidate.length();
-                        if (length != 0) {
-                            if (identifier == null || length < identifier.length()) {
+                        if (length != 0 && (identifier == null || length < identifier.length()))
{
+                            final boolean s = isUnicodeIdentifier(candidate);
+                            if (s || !isUnicode) {
                                 identifier = candidate;
+                                isUnicode = s;
                             }
                         }
                     }
                 }
             }
+            /*
+             * If no identifier has been found, fallback on the shortest title or alternate
title.
+             * We search for alternate titles because ISO specification said that those titles
are
+             * often used for abbreviations.
+             */
             if (identifier == null) {
-                final InternationalString title = citation.getTitle();
-                if (title != null) {
-                    identifier = title.toString();
+                identifier = toString(citation.getTitle());
+                if (identifier != null) {
+                    if (identifier.isEmpty()) {
+                        identifier = null;
+                    } else {
+                        isUnicode = isUnicodeIdentifier(identifier);
+                    }
+                }
+                final Iterator<? extends InternationalString> iterator = iterator(citation.getAlternateTitles());
+                if (iterator != null) while (iterator.hasNext()) {
+                    final String candidate = toString(iterator.next());
+                    if (candidate != null) {
+                        final int length = candidate.length();
+                        if (length != 0 && (identifier == null || length < identifier.length()))
{
+                            final boolean s = isUnicodeIdentifier(candidate);
+                            if (s || !isUnicode) {
+                                identifier = candidate;
+                                isUnicode = s;
+                            }
+                        }
+                    }
                 }
             }
         }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -83,6 +83,9 @@ public class DefaultNameFactory extends 
     /**
      * Creates an international string from a set of strings in different locales.
      *
+     * @param strings String value for each locale key.
+     * @return The international string.
+     *
      * @see Types#toInternationalString(CharSequence)
      */
     @Override

Copied: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
(from r1496855, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java?p2=sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java&p1=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java&r1=1496855&r2=1496857&rev=1496857&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -35,7 +35,7 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.internal.util.CollectionsExt;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
 
 
 /**
@@ -114,7 +114,7 @@ public class DefaultRecordType implement
         ArgumentChecks.ensureNonNull("typeName",    typeName);
         ArgumentChecks.ensureNonNull("container",   container);
         ArgumentChecks.ensureNonNull("memberTypes", memberTypes);
-        memberTypes = new LinkedHashMap<>(memberTypes);
+        memberTypes = new LinkedHashMap<MemberName,Type>(memberTypes);
         memberTypes.remove(null);
         for (final Map.Entry<MemberName,Type> entry : memberTypes.entrySet()) {
             final MemberName name = entry.getKey();

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -216,6 +216,11 @@ public final class Errors extends Indexe
         public static final int IllegalLanguageCode_1 = 12;
 
         /**
+         * Member “{0}” can not be associated to type “{1}”.
+         */
+        public static final int IllegalMemberType_2 = 106;
+
+        /**
          * Option ‘{0}’ can not take the “{1}” value.
          */
         public static final int IllegalOptionValue_2 = 101;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Wed Jun 26 09:36:13 2013
@@ -54,6 +54,7 @@ IllegalBitsPattern_1            = Illega
 IllegalClass_2                  = Class \u2018{1}\u2019 is illegal. It must be \u2018{0}\u2019
or a derived class.
 IllegalFormatPatternForClass_2  = The \u201c{1}\u201d pattern can not be applied to formating
of objects of type \u2018{0}\u2019.
 IllegalLanguageCode_1           = The \u201c{0}\u201d language is not recognized.
+IllegalMemberType_2             = Member \u201c{0}\u201d can not be associated to type \u201c{1}\u201d.
 IllegalOrdinateRange_3          = The [{0} \u2026 {1}] range of ordinate values is not valid
for the \u201c{2}\u201d axis.
 IllegalPropertyClass_2          = Property \u2018{0}\u2019 can be associated to an instance
of \u2018{1}\u2019.
 IllegalRange_2                  = Range [{0} \u2026 {1}] is not valid.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Wed Jun 26 09:36:13 2013
@@ -44,6 +44,7 @@ IllegalBitsPattern_1            = Patter
 IllegalClass_2                  = La classe \u2018{1}\u2019 est ill\u00e9gale. Il doit s\u2019agir
d\u2019une classe \u2018{0}\u2019 ou d\u00e9riv\u00e9e.
 IllegalFormatPatternForClass_2  = Le mod\u00e8le \u201c{1}\u201d ne peut pas \u00eatre appliqu\u00e9
au formatage d\u2019objets de type \u2018{0}\u2019.
 IllegalLanguageCode_1           = Le code de langue \u201c{0}\u201d n\u2019est pas reconnu.
+IllegalMemberType_2             = Le membre \u201c{0}\u201d ne peut pas \u00eatre associ\u00e9
au type \u201c{1}\u201d.
 IllegalOrdinateRange_3          = La plage de valeurs de coordonn\u00e9es [{1} \u2026 {2}]
n\u2019est pas valide pour l\u2019axe \u201c{0}\u201d.
 IllegalPropertyClass_2          = La propri\u00e9t\u00e9 \u2018{0}\u2019 ne peut pas \u00eatre
associ\u00e9e \u00e0 une valeur de type \u2018{1}\u2019.
 IllegalRange_2                  = La plage [{0} \u2026 {1}] n\u2019est pas valide.

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/XmlUtilitiesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/XmlUtilitiesTest.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/XmlUtilitiesTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/XmlUtilitiesTest.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -18,10 +18,9 @@ package org.apache.sis.internal.jaxb;
 
 import java.util.Date;
 import java.util.Locale;
-import java.util.TimeZone;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.datatype.DatatypeConfigurationException;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -36,7 +35,7 @@ import static javax.xml.datatype.Datatyp
  * @version 0.3
  * @module
  */
-public final strictfp class XmlUtilitiesTest extends TestCase {
+public final strictfp class XmlUtilitiesTest extends XMLTestCase {
     /**
      * Tests the {@link XmlUtilities#toXML} method.
      * This test arbitrarily uses the CET timezone.
@@ -45,11 +44,11 @@ public final strictfp class XmlUtilities
      */
     @Test
     public void testToXML() throws DatatypeConfigurationException {
-        final Context context = new Context(0, Locale.FRENCH, TimeZone.getTimeZone("CET"),
null, null, null, null, null);
-        final XMLGregorianCalendar cal = XmlUtilities.toXML(context, new Date(1230786000000L));
-        assertEquals("2009-01-01T06:00:00.000+01:00", cal.toString());
+        createContext(false, Locale.FRANCE, "CET");
+        final XMLGregorianCalendar calendar = XmlUtilities.toXML(context, new Date(1230786000000L));
+        assertEquals("2009-01-01T06:00:00.000+01:00", calendar.toString());
 
-        cal.setMillisecond(FIELD_UNDEFINED);
-        assertEquals("2009-01-01T06:00:00+01:00", cal.toString());
+        calendar.setMillisecond(FIELD_UNDEFINED);
+        assertEquals("2009-01-01T06:00:00+01:00", calendar.toString());
     }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java?rev=1496857&r1=1496856&r2=1496857&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
[UTF-8] Wed Jun 26 09:36:13 2013
@@ -17,13 +17,12 @@
 package org.apache.sis.internal.jaxb.gco;
 
 import java.util.UUID;
-import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.xml.XLink;
 import org.apache.sis.xml.IdentifierSpace;
 import org.apache.sis.xml.ReferenceResolverMock;
 import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -38,7 +37,7 @@ import static org.junit.Assert.*;
  * @module
  */
 @DependsOn(org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class)
-public final strictfp class PropertyTypeTest extends TestCase {
+public final strictfp class PropertyTypeTest extends XMLTestCase {
     /**
      * The pseudo-metadata object to wrap for testing purpose.
      */
@@ -108,13 +107,8 @@ public final strictfp class PropertyType
     public void testWithUUID() throws Exception {
         final UUID uuid = UUID.randomUUID();
         metadata.getIdentifierMap().putSpecialized(IdentifierSpace.UUID, uuid);
-        final Context context = ReferenceResolverMock.begin(true);
-        final PropertyTypeMock property;
-        try {
-            property = marshal();
-        } finally {
-            context.finish();
-        }
+        context = ReferenceResolverMock.begin(true);
+        final PropertyTypeMock property = marshal();
         assertSame  (metadata,        property.metadata);
         assertNull  ("nilReason",     property.getNilReason());
         assertEquals(uuid.toString(), property.getUUIDREF());
@@ -146,13 +140,8 @@ public final strictfp class PropertyType
     public void testWithXLink() throws Exception {
         final XLink link = createXLink();
         metadata.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, link);
-        final Context context = ReferenceResolverMock.begin(true);
-        final PropertyTypeMock property;
-        try {
-            property = marshal();
-        } finally {
-            context.finish();
-        }
+        context = ReferenceResolverMock.begin(true);
+        final PropertyTypeMock property = marshal();
         assertSame  (metadata,              property.metadata);
         assertNull  ("nilReason",           property.getNilReason());
         assertNull  ("uuidref",             property.getUUIDREF());



Mime
View raw message