sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1551743 [1/3] - in /sis/trunk: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ core/sis-...
Date Tue, 17 Dec 2013 22:39:57 GMT
Author: desruisseaux
Date: Tue Dec 17 22:39:56 2013
New Revision: 1551743

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

Added:
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
      - copied unchanged from r1551742, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/PT_LocaleTest.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
      - copied unchanged from r1551742, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
      - copied unchanged from r1551742, sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
      - copied unchanged from r1551742, sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java
      - copied unchanged from r1551742, sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java
Removed:
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
    sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.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/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
    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/IdentifierMapAdapter.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.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/GO_DateTime.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.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/gmd/LocaleAdapter.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.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/internal/util/URIParser.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListener.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.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/jaxb/gco/MeasureTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/xml/NilReasonTest.java
    sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1550842-1551738
  Merged /sis/branches/JDK6:r1550854-1551742

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -264,7 +264,8 @@ abstract class SubCommand {
      */
     final boolean hasUnexpectedFileCount(final int min, final int max) {
         final int size = files.size();
-        final int expected, key;
+        final int expected;
+        final short key;
         if (size < min) {
             expected = min;
             key = Errors.Keys.TooFewArguments_2;

Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java [UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -76,7 +76,7 @@ class IndexedResourceCompiler implements
     /**
      * The Java modifiers applies on the key constants to be generated.
      */
-    private static final String KEY_MODIFIERS = "public static final int ";
+    private static final String KEY_MODIFIERS = "public static final short ";
 
     /**
      * Margin to write before the {@link #KEY_MODIFIERS}.

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.metadata.identification.CharacterSet;
-import org.apache.sis.util.Locales;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.gmd.Country;
@@ -59,7 +58,7 @@ import org.apache.sis.internal.jaxb.gmd.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see LanguageCode
@@ -127,6 +126,9 @@ public final class PT_Locale extends Xml
         /**
          * Invoked by JAXB {@link javax.xml.bind.Marshaller} before this object is marshalled to XML.
          * This method sets the {@link #characterEncoding} to the XML encoding.
+         *
+         * {@note This is totally redundant with the encoding declared in the XML header. Unfortunately,
+         *        the <code>gmd:characterEncoding</code> element is mandatory according OGC/ISO schemas.}
          */
         public void beforeMarshal(final Marshaller marshaller) {
             final String encoding;
@@ -135,7 +137,7 @@ public final class PT_Locale extends Xml
             } catch (Exception e) { // (PropertyException | ClassCastException) on the JDK7 branch.
                 // Should never happen. But if it happen anyway, just let the
                 // characterEncoding unitialized: it will not be marshalled.
-                Context.warningOccured(Context.current(), marshaller, PT_Locale.class, "beforeMarshal", e, true);
+                Context.warningOccured(Context.current(), PT_Locale.class, "beforeMarshal", e, true);
                 return;
             }
             if (encoding != null) {
@@ -158,11 +160,11 @@ public final class PT_Locale extends Xml
     }
 
     /**
-     * Substitutes the locale by the adapter to be marshalled into an XML file
+     * Substitutes the locale by the wrapper to be marshalled into an XML file
      * or stream. JAXB calls automatically this method at marshalling time.
      *
      * @param value The locale value.
-     * @return The adapter for the locale value.
+     * @return The wrapper for the locale value.
      */
     @Override
     public PT_Locale marshal(final Locale value) {
@@ -170,10 +172,10 @@ public final class PT_Locale extends Xml
     }
 
     /**
-     * Substitutes the adapter value read from a XML stream by the object which will
+     * Substitutes the wrapped value read from a XML stream by the object which will
      * contains the value. JAXB calls automatically this method at unmarshalling time.
      *
-     * @param value The adapter for this metadata value.
+     * @param value The wrapper for this metadata value.
      * @return A locale which represents the metadata value.
      */
     @Override
@@ -181,18 +183,7 @@ public final class PT_Locale extends Xml
         if (value != null) {
             final Wrapper element = value.element;
             if (element != null) {
-                Locale language = LanguageCode.getLocale(Context.current(), element.languageCode, true);
-                Locale country  = Country.getLocale(element.country);
-                if (language == null) {
-                    language = country;
-                } else if (country != null) {
-                    // Merge the language and the country in a single Locale instance.
-                    final String c = country.getCountry();
-                    if (!c.equals(language.getCountry())) {
-                        language = Locales.unique(new Locale(language.getLanguage(), c));
-                    }
-                }
-                return language;
+                return Country.getLocale(Context.current(), element.languageCode, element.country, PT_Locale.class);
             }
         }
         return null;

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -95,6 +95,8 @@ public class SC_VerticalCRS extends Prop
 
     /**
      * Returns the GeoAPI interface which is bound by this adapter.
+     *
+     * @return {@code VerticalCRS.class}
      */
     @Override
     protected final Class<VerticalCRS> getBoundType() {
@@ -114,7 +116,7 @@ public class SC_VerticalCRS extends Prop
      */
     @XmlAnyElement(lax = true)
     public Object getElement() {
-        Context.warningOccured(Context.current(), metadata, SC_VerticalCRS.class, "getElement",
+        Context.warningOccured(Context.current(), SC_VerticalCRS.class, "getElement",
                 Errors.class, Errors.Keys.MissingRequiredModule_1, "sis-referencing");
         return null;
     }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -108,8 +108,9 @@ public final class TM_Primitive extends 
     public void setTimePeriod(final TimePeriod period) {
         metadata = null; // Cleaned first in case of failure.
         if (period != null) {
-            final Date begin = toDate(period.begin);
-            final Date end   = toDate(period.end);
+            final Context context = Context.current();
+            final Date begin = toDate(context, period.begin);
+            final Date end   = toDate(context, period.end);
             if (begin != null || end != null) {
                 if (begin != null && end != null && end.before(begin)) {
                     /*
@@ -118,7 +119,7 @@ public final class TM_Primitive extends 
                      * TemporalPrimitive as the source class, since it is the closest we can get
                      * to a public API.
                      */
-                    Context.warningOccured(Context.current(), this, TemporalPrimitive.class, "setTimePeriod",
+                    Context.warningOccured(context, TemporalPrimitive.class, "setTimePeriod",
                             Errors.class, Errors.Keys.IllegalRange_2, begin, end);
                 } else try {
                     metadata = TemporalUtilities.createPeriod(begin, end);
@@ -139,7 +140,7 @@ public final class TM_Primitive extends 
     public void setTimeInstant(final TimeInstant instant) {
         metadata = null; // Cleaned first in case of failure.
         if (instant != null) {
-            final Date position = XmlUtilities.toDate(instant.timePosition);
+            final Date position = XmlUtilities.toDate(Context.current(), instant.timePosition);
             if (position != null) try {
                 metadata = TemporalUtilities.createInstant(position);
                 instant.copyIdTo(metadata);
@@ -152,8 +153,8 @@ public final class TM_Primitive extends 
     /**
      * Returns the date of the given bounds, or {@code null} if none.
      */
-    private static Date toDate(final TimePeriodBound bound) {
-        return (bound != null) ? XmlUtilities.toDate(bound.calendar()) : null;
+    private static Date toDate(final Context context, final TimePeriodBound bound) {
+        return (bound != null) ? XmlUtilities.toDate(context, bound.calendar()) : null;
     }
 
     /**
@@ -162,7 +163,7 @@ public final class TM_Primitive extends 
      * @param method The name of the method to declare in the log record.
      * @param e the exception.
      */
-    private void warningOccured(final String method, final Exception e) {
-        Context.warningOccured(Context.current(), this, TM_Primitive.class, method, e, true);
+    private static void warningOccured(final String method, final Exception e) {
+        Context.warningOccured(Context.current(), TM_Primitive.class, method, e, true);
     }
 }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -88,7 +88,7 @@ public final class TimeInstant extends G
                         return date;
                     }
                 } catch (DatatypeConfigurationException e) {
-                    Context.warningOccured(context, position, TimeInstant.class, "toXML", e, true);
+                    Context.warningOccured(context, TimeInstant.class, "toXML", e, true);
                 }
             }
         }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -73,6 +73,8 @@ public final class TM_PeriodDuration ext
 
     /**
      * Returns the GeoAPI interface which is bound by this adapter.
+     *
+     * @return {@code PeriodDuration.class}
      */
     @Override
     protected Class<PeriodDuration> getBoundType() {
@@ -176,7 +178,7 @@ public final class TM_PeriodDuration ext
      * @param methodName The method name.
      * @param e The exception.
      */
-    private void warningOccured(final String methodName, final Exception e) {
-        Context.warningOccured(Context.current(), this, TM_PeriodDuration.class, methodName, e, true);
+    private static void warningOccured(final String methodName, final Exception e) {
+        Context.warningOccured(Context.current(), TM_PeriodDuration.class, methodName, e, true);
     }
 }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -104,7 +104,7 @@ public final class MetadataUtilities ext
      * @param  key       The key from the message resource bundle to use for creating a message.
      * @param  arguments The arguments to be used together with the key for building the message.
      */
-    public static void warning(final Class<?> caller, final String method, final int key, final Object... arguments) {
+    public static void warning(final Class<?> caller, final String method, final short key, final Object... arguments) {
         final LogRecord record = Messages.getResources(null).getLogRecord(Level.WARNING, key, arguments);
         record.setSourceClassName(caller.getCanonicalName());
         record.setSourceMethodName(method);

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.metadata.citation.ResponsibleParty;
 import org.opengis.metadata.identification.TopicCategory;
 import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
@@ -57,7 +58,7 @@ public final strictfp class CodeListMars
     private static String getResponsiblePartyXML(final String baseURL) {
         return "<gmd:CI_ResponsibleParty xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
                "  <gmd:role>\n" +
-               "    <gmd:CI_RoleCode codeList=\"" + baseURL + "resources/Codelist/gmxCodelists.xml#CI_RoleCode\"" +
+               "    <gmd:CI_RoleCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH + "#CI_RoleCode\"" +
                     " codeListValue=\"principalInvestigator\">" + "Principal investigator</gmd:CI_RoleCode>\n" +
                "  </gmd:role>\n" +
                "</gmd:CI_ResponsibleParty>";
@@ -71,7 +72,7 @@ public final strictfp class CodeListMars
     private static String getCitationXML(final String baseURL, final String language, final String value) {
         return "<gmd:CI_Date xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
                "  <gmd:dateType>\n" +
-               "    <gmd:CI_DateTypeCode codeList=\"" + baseURL + "resources/Codelist/gmxCodelists.xml#CI_DateTypeCode\"" +
+               "    <gmd:CI_DateTypeCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH + "#CI_DateTypeCode\"" +
                     " codeListValue=\"creation\" codeSpace=\"" + language + "\">" + value + "</gmd:CI_DateTypeCode>\n" +
                "  </gmd:dateType>\n" +
                "</gmd:CI_Date>";
@@ -84,7 +85,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testDefaultURL() throws JAXBException {
-        final String expected = getResponsiblePartyXML("http://schemas.opengis.net/iso/19139/20070417/");
+        final String expected = getResponsiblePartyXML(Schemas.METADATA_ROOT);
         final ResponsibleParty rp = (ResponsibleParty) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
         /*
@@ -102,7 +103,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testISO_URL() throws JAXBException {
-        final String expected = getResponsiblePartyXML("http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/");
+        final String expected = getResponsiblePartyXML(Schemas.ISO_19139_ROOT);
         final ResponsibleParty rp = (ResponsibleParty) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
 
@@ -128,16 +129,16 @@ public final strictfp class CodeListMars
          * First, test using the French locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.FRENCH);
-        String expected = getCitationXML("http://schemas.opengis.net/iso/19139/20070417/", "fra", "Création");
+        String expected = getCitationXML(Schemas.METADATA_ROOT, "fra", "Création");
         CitationDate ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         String actual = marshal(marshaller, ci);
         assertXmlEquals(expected, actual, "xmlns:*");
         /*
-         * Tests again using the Englisg locale.
+         * Tests again using the English locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.ENGLISH);
-        expected = getCitationXML("http://schemas.opengis.net/iso/19139/20070417/", "eng", "Creation");
+        expected = getCitationXML(Schemas.METADATA_ROOT, "eng", "Creation");
         ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         actual = marshal(marshaller, ci);

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -55,8 +55,7 @@ public final strictfp class TimePeriodTe
 
     /**
      * Set the marshalling context to a fixed locale and timezone before to create the
-     * JAXB wrappers for temporal objects. Callers shall invoke {@link #clearContext()}
-     * after this method.
+     * JAXB wrappers for temporal objects.
      */
     private void createContext() {
         createContext(true, Locale.FRANCE, "CET");
@@ -88,17 +87,6 @@ public final strictfp class TimePeriodTe
     }
 
     /**
-     * Creates a new time instant for the given date.
-     */
-    private TimeInstant createTimeInstant(final String date) throws DatatypeConfigurationException {
-        final TimeInstant instant = new TimeInstant();
-        createContext();
-        instant.timePosition = XmlUtilities.toXML(context, date(date));
-        clearContext();
-        return instant;
-    }
-
-    /**
      * Tests time instant. The test is executed using an arbitrary locale and timezone.
      *
      * @throws JAXBException If an error occurred while marshalling.
@@ -106,10 +94,11 @@ public final strictfp class TimePeriodTe
      */
     @Test
     public void testTimeInstant() throws JAXBException, DatatypeConfigurationException {
+        createContext();
         final Marshaller   marshaller   = pool.acquireMarshaller();
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
-
-        final TimeInstant instant = createTimeInstant("1992-01-01 00:00:00");
+        final TimeInstant  instant      = new TimeInstant();
+        instant.timePosition = XmlUtilities.toXML(context, date("1992-01-01 00:00:00"));
         final String actual = marshal(marshaller, instant);
         assertXmlEquals(
                 "<gml:TimeInstant xmlns:gml=\"" + Namespaces.GML + "\">\n" +
@@ -117,7 +106,7 @@ public final strictfp class TimePeriodTe
                 "</gml:TimeInstant>\n", actual, "xmlns:*");
 
         final TimeInstant test = (TimeInstant) unmarshal(unmarshaller, actual);
-        assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(test.timePosition)));
+        assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(context, test.timePosition)));
 
         pool.recycle(marshaller);
         pool.recycle(unmarshaller);
@@ -134,7 +123,6 @@ public final strictfp class TimePeriodTe
         createContext();
         final TimePeriodBound begin = new TimePeriodBound.GML2(new DummyInstant(date("1992-01-01 00:00:00")));
         final TimePeriodBound end   = new TimePeriodBound.GML2(new DummyInstant(date("2007-12-31 00:00:00")));
-        clearContext();
         testPeriod(begin, end,
                 "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:begin>\n" +
@@ -162,15 +150,15 @@ public final strictfp class TimePeriodTe
     {
         final Marshaller   marshaller   = pool.acquireMarshaller();
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
-        final TimePeriod period = new TimePeriod();
+        final TimePeriod   period       = new TimePeriod();
         period.begin = begin;
         period.end   = end;
         final String actual = marshal(marshaller, period);
         assertXmlEquals(expected, actual, "xmlns:*");
         final TimePeriod test = (TimePeriod) unmarshal(unmarshaller, actual);
         if (verifyValues) {
-            assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(test.begin.calendar())));
-            assertEquals("2007-12-31 00:00:00", format(XmlUtilities.toDate(test.end  .calendar())));
+            assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(context, test.begin.calendar())));
+            assertEquals("2007-12-31 00:00:00", format(XmlUtilities.toDate(context, test.end  .calendar())));
         }
         pool.recycle(marshaller);
         pool.recycle(unmarshaller);
@@ -187,7 +175,6 @@ public final strictfp class TimePeriodTe
         createContext();
         final TimePeriodBound begin = new TimePeriodBound.GML3(new DummyInstant(date("1992-01-01 00:00:00")), "before");
         final TimePeriodBound end   = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-31 00:00:00")), "after");
-        clearContext();
         testPeriod(begin, end,
                 "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:beginPosition>1992-01-01T01:00:00+01:00</gml:beginPosition>\n" +
@@ -206,7 +193,6 @@ public final strictfp class TimePeriodTe
         createContext();
         final TimePeriodBound begin = new TimePeriodBound.GML3(new DummyInstant(date("1992-01-01 23:00:00")), "before");
         final TimePeriodBound end   = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
-        clearContext();
         testPeriod(begin, end,
                 "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
@@ -225,7 +211,6 @@ public final strictfp class TimePeriodTe
         createContext();
         final TimePeriodBound begin = new TimePeriodBound.GML3(null, "before");
         final TimePeriodBound end   = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
-        clearContext();
         testPeriod(begin, end,
                 "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:beginPosition indeterminatePosition=\"before\"/>\n" +
@@ -244,7 +229,6 @@ public final strictfp class TimePeriodTe
         createContext();
         final TimePeriodBound begin = new TimePeriodBound.GML3(new DummyInstant(date("1992-01-01 23:00:00")), "before");
         final TimePeriodBound end   = new TimePeriodBound.GML3(null, "after");
-        clearContext();
         testPeriod(begin, end,
                 "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.metadata.iso.LoggingWatcher;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Rule;
@@ -135,7 +136,7 @@ public final strictfp class DefaultResol
                 "<gmd:MD_Resolution xmlns:gmd=\"" + Namespaces.GMD + '"' +
                                   " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
                 "  <gmd:distance>\n" +
-                "    <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n" +
+                "    <gco:Distance uom=\"" + Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n" +
                 "  </gmd:distance>\n" +
                 "</gmd:MD_Resolution>", xml, "xmlns:*");
         /*

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -50,7 +50,8 @@ import org.junit.BeforeClass;
 
     // XML marshalling.
     org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
-    org.apache.sis.internal.jaxb.gmd.LanguageMarshallingTest.class,
+    org.apache.sis.internal.jaxb.code.PT_LocaleTest.class,
+    org.apache.sis.internal.jaxb.gmd.LanguageCodeTest.class,
     org.apache.sis.internal.jaxb.gml.TimePeriodTest.class,
     org.apache.sis.xml.FreeTextMarshallingTest.class,
     org.apache.sis.xml.NilReasonMarshallingTest.class,

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -294,7 +294,7 @@ public abstract class AbstractDirectPosi
             final char close = (c == '(') ? ')' : ']';
             final int pos = CharSequences.lastIndexOf(wkt, close, i, length);
             if (pos != --length) {
-                final int key;
+                final short key;
                 final Object[] args;
                 if (pos < 0) {
                     key  = Errors.Keys.NonEquilibratedParenthesis_2;

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -493,7 +493,7 @@ public enum GeodeticObjects {
         /**
          * The resource keys for the name as one of the {@code Vocabulary.Keys} constants.
          */
-        private final int key;
+        private final short key;
 
         /**
          * The cached object. This is initially {@code null}, then set to various kind of objects depending
@@ -509,7 +509,7 @@ public enum GeodeticObjects {
          *        early class initialization. In particular, we do not want early dependency to the SIS-specific
          *        <code>VerticalDatumTypes.ELLIPSOIDAL</code> constant.}
          */
-        private Vertical(final int name) {
+        private Vertical(final short name) {
             this.key = name;
         }
 
@@ -637,7 +637,7 @@ public enum GeodeticObjects {
         /**
          * The resource keys for the name as one of the {@code Vocabulary.Keys} constants.
          */
-        private final int key;
+        private final short key;
 
         /**
          * The date and time origin of this temporal datum.
@@ -654,7 +654,7 @@ public enum GeodeticObjects {
         /**
          * Creates a new enumeration value of the given name with time counted since the given epoch.
          */
-        private Temporal(final int name, final long epoch) {
+        private Temporal(final short name, final long epoch) {
             this.key   = name;
             this.epoch = epoch;
         }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -549,9 +549,9 @@ public class DefaultEllipsoid extends Ab
     /**
      * Emits a warning telling that the given element is repeated twice.
      */
-    private void warnDuplicated(final String element) {
+    private static void warnDuplicated(final String element) {
          // We cheat a bit for the "unmarshal" method name since there is not such method...
-        Context.warningOccured(Context.current(), this, DefaultEllipsoid.class, "unmarshal",
+        Context.warningOccured(Context.current(), DefaultEllipsoid.class, "unmarshal",
                 Errors.class, Errors.Keys.DuplicatedElement_1, element);
     }
 

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -76,7 +76,7 @@ public final strictfp class DefaultPrime
     @Test
     public void testMarshall() throws JAXBException {
         final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
-        assertXmlEquals(getGreenwichXml(Namespaces.GML), marshal(pm), "xmlns:*", "xsi:schemaLocation");
+        assertXmlEquals(getGreenwichXml(Namespaces.GML), marshal(pm), "xmlns:*");
     }
 
     /**
@@ -147,6 +147,6 @@ public final strictfp class DefaultPrime
                 "  <gml:remarks>Equivalent to 2°20′14.025″.</gml:remarks>\n" +
                 "  <gml:greenwichLongitude uom=\"urn:ogc:def:uom:EPSG::9105\">2.5969213</gml:greenwichLongitude>\n" +
                 "</gml:PrimeMeridian>\n",
-                marshal(pm), "xmlns:*", "xsi:schemaLocation");
+                marshal(pm), "xmlns:*");
     }
 }

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -383,19 +383,17 @@ public final class Context extends Marsh
      * if defined, or to the {@code "org.apache.sis.xml"} logger otherwise.
      *
      * @param context The current context, or {@code null} if none.
-     * @param source  The object that emitted a warning. Can not be null.
      * @param warning The warning.
      */
-    @SuppressWarnings("unchecked")
-    public static void warningOccured(final Context context, final Object source, final LogRecord warning) {
+    public static void warningOccured(final Context context, final LogRecord warning) {
         String logger = warning.getLoggerName();
         if (logger == null) {
             warning.setLoggerName(logger = "org.apache.sis.xml");
         }
         if (context != null) {
             final WarningListener<?> warningListener = context.warningListener;
-            if (warningListener != null && warningListener.getSourceClass().isInstance(source)) {
-                ((WarningListener) warningListener).warningOccured(source, warning);
+            if (warningListener != null) {
+                warningListener.warningOccured(null, warning);
                 return;
             }
         }
@@ -412,15 +410,14 @@ public final class Context extends Marsh
      * resources. The message will be logged at {@link Level#WARNING}.
      *
      * @param context   The current context, or {@code null} if none.
-     * @param source    The object that emitted a warning. Can not be null.
      * @param classe    The class to declare as the warning source.
      * @param method    The name of the method to declare as the warning source.
      * @param resources Either {@code Errors.class} or {@code Messages.class}.
      * @param key       The resource keys as one of the constants defined in the {@code Keys} inner class.
      * @param arguments The arguments to be given to {@code MessageFormat} for formatting the log message.
      */
-    public static void warningOccured(final Context context, final Object source, final Class<?> classe, final String method,
-            final Class<? extends IndexedResourceBundle> resources, final int key, final Object... arguments)
+    public static void warningOccured(final Context context, final Class<?> classe, final String method,
+            final Class<? extends IndexedResourceBundle> resources, final short key, final Object... arguments)
     {
         final Locale locale = context != null ? context.getLocale() : null;
         final IndexedResourceBundle bundle;
@@ -434,7 +431,7 @@ public final class Context extends Marsh
         final LogRecord warning = bundle.getLogRecord(Level.WARNING, key, arguments);
         warning.setSourceClassName(classe.getCanonicalName());
         warning.setSourceMethodName(method);
-        warningOccured(context, source, warning);
+        warningOccured(context, warning);
     }
 
     /**
@@ -442,13 +439,12 @@ public final class Context extends Marsh
      * The logger will be {@code "org.apache.sis.xml"}.
      *
      * @param context The current context, or {@code null} if none.
-     * @param source  The object that emitted a warning. Can not be null.
      * @param classe  The class to declare as the warning source.
      * @param method  The name of the method to declare as the warning source.
      * @param cause   The exception which occurred.
      * @param warning {@code true} for {@link Level#WARNING}, or {@code false} for {@link Level#FILE}.
      */
-    public static void warningOccured(final Context context, final Object source, final Class<?> classe,
+    public static void warningOccured(final Context context, final Class<?> classe,
             final String method, final Exception cause, final boolean warning)
     {
         final LogRecord record = new LogRecord(warning ? Level.WARNING : Level.FINE,
@@ -456,7 +452,7 @@ public final class Context extends Marsh
         record.setSourceClassName(classe.getCanonicalName());
         record.setSourceMethodName(method);
         record.setThrown(cause);
-        warningOccured(context, source, record);
+        warningOccured(context, record);
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -273,7 +273,7 @@ public class IdentifierMapAdapter extend
             }
         }
         if (code != null) {
-            identifiers.add(SpecializedIdentifier.parse(this, authority, code));
+            identifiers.add(SpecializedIdentifier.parse(authority, code));
         }
         return old;
     }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -215,7 +215,7 @@ public final class IdentifierMapWithSpec
                 return (uri != null) ? uri.toString() : old;
             }
         }
-        SpecializedIdentifier.parseFailure(context, this, code, type, exception);
+        SpecializedIdentifier.parseFailure(context, code, type, exception);
         final String old = super.put(authority, code);
         return (old == null && removed != null) ? removed.toString() : old;
     }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -92,13 +92,12 @@ public final class SpecializedIdentifier
      * authorities declared in the {@link IdentifierSpace} interface. Otherwise a
      * plain {@link IdentifierMapEntry} is created.
      *
-     * @param source    The object to declare as the source in case of failure.
      * @param authority The authority, typically as one of the {@link IdentifierSpace} constants.
      * @param code      The identifier code to parse.
      *
      * @see IdentifierMapAdapter#put(Citation, String)
      */
-    static Identifier parse(final IdentifierMap source, final Citation authority, final String code) {
+    static Identifier parse(final Citation authority, final String code) {
         if (authority instanceof NonMarshalledAuthority) {
             final int ordinal = ((NonMarshalledAuthority) authority).ordinal;
             switch (ordinal) {
@@ -111,7 +110,7 @@ public final class SpecializedIdentifier
                     try {
                         return new SpecializedIdentifier<UUID>(IdentifierSpace.UUID, converter.toUUID(context, code));
                     } catch (IllegalArgumentException e) {
-                        parseFailure(context, source, code, UUID.class, e);
+                        parseFailure(context, code, UUID.class, e);
                         break;
                     }
                 }
@@ -123,7 +122,7 @@ public final class SpecializedIdentifier
                     try {
                         href = converter.toURI(context, code);
                     } catch (URISyntaxException e) {
-                        parseFailure(context, source, code, URI.class, e);
+                        parseFailure(context, code, URI.class, e);
                         break;
                     }
                     if (ordinal == NonMarshalledAuthority.HREF) {
@@ -147,20 +146,17 @@ public final class SpecializedIdentifier
      * the public API by which this method has been invoked.</p>
      *
      * @param context The marshalling context, or {@code null} if none.
-     * @param source  The object to declare as the source of the warning.
      * @param value   The value that we failed to parse.
      * @param type    The target type of the parsing process.
      * @param cause   The exception that occurred during the parsing process.
      */
-    static void parseFailure(final Context context, final IdentifierMap source,
-            final String value, final Class<?> type, final Exception cause)
-    {
+    static void parseFailure(final Context context, final String value, final Class<?> type, final Exception cause) {
         final Messages resources = Messages.getResources(context != null ? context.getLocale() : null);
         final LogRecord record = resources.getLogRecord(Level.WARNING, Messages.Keys.UnparsableValueStoredAsText_2, type, value);
         record.setSourceClassName(IdentifierMap.class.getCanonicalName());
         record.setSourceMethodName("put");
         record.setThrown(cause);
-        Context.warningOccured(context, source, record);
+        Context.warningOccured(context, record);
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -177,10 +177,21 @@ public final class XmlUtilities extends 
     /**
      * Converts the given XML Gregorian calendar to a date.
      *
+     * @param  context The current (un)marshalling context, or {@code null} if none.
      * @param  xml The XML calendar to convert to a date, or {@code null}.
      * @return The date, or {@code null} if {@code xml} was null.
      */
-    public static Date toDate(final XMLGregorianCalendar xml) {
-        return (xml != null) ? xml.toGregorianCalendar().getTime() : null;
+    public static Date toDate(final Context context, final XMLGregorianCalendar xml) {
+        if (xml != null) {
+            final GregorianCalendar calendar =  xml.toGregorianCalendar();
+            if (context != null && xml.getTimezone() == FIELD_UNDEFINED) {
+                final TimeZone timezone = context.getTimeZone();
+                if (timezone != null) {
+                    calendar.setTimeZone(timezone);
+                }
+            }
+            return calendar.getTime();
+        }
+        return null;
     }
 }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -70,7 +70,7 @@ public final class DateAsLongAdapter ext
         if (value != null) {
             final long time = value;
             if (time != Long.MIN_VALUE) {
-                return new GO_DateTime(this, new Date(time), false);
+                return new GO_DateTime(new Date(time), false);
             }
         }
         return new GO_DateTime();

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -76,13 +76,16 @@ public class GO_CharacterString {
 
     /**
      * The XML element names for each possible {@link #type} values.
+     * Used for formatting error messages.
      */
-    private static final String[] NAMES = new String[4];
-    static {
-        NAMES[0]         = "CharacterString";
-        NAMES[MIME_TYPE] = "MimeFileType";
-        NAMES[FILENAME]  = "FileName";
-        NAMES[ANCHOR]    = "Anchor";
+    private static String nameOf(final byte type) {
+        switch (type) {
+            case 0:         return "CharacterString";
+            case MIME_TYPE: return "MimeFileType";
+            case FILENAME:  return "FileName";
+            case ANCHOR:    return "Anchor";
+            default:        throw new AssertionError(type);
+        }
     }
 
     /**
@@ -135,8 +138,8 @@ public class GO_CharacterString {
                 property  = type;
                 noset     = true;
             }
-            Context.warningOccured(Context.current(), value, getClass(), "setText",
-                    Messages.class, Messages.Keys.DiscardedExclusiveProperty_2, NAMES[discarded], NAMES[property]);
+            Context.warningOccured(Context.current(), getClass(), "setText", Messages.class,
+                    Messages.Keys.DiscardedExclusiveProperty_2, nameOf(discarded), nameOf(property));
             if (noset) {
                 return;
             }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -61,12 +61,11 @@ public final class GO_DateTime extends X
     /**
      * Builds a wrapper for the given {@link Date}.
      *
-     * @param source The source for reporting errors.
      * @param date The date to marshal. Can not be {@code null}.
      * @param allowTime {@code true} for allowing the usage of {@code "DateTime"} field if
      *        applicable, or {@code false} for using the {@code "Date"} field in every cases.
      */
-    GO_DateTime(final XmlAdapter<GO_DateTime,?> source, final Date date, final boolean allowTime) {
+    GO_DateTime(final Date date, final boolean allowTime) {
         final Context context = Context.current();
         try {
             final XMLGregorianCalendar gc = XmlUtilities.toXML(context, date);
@@ -76,16 +75,16 @@ public final class GO_DateTime extends X
                 dateTime = gc;
             }
         } catch (DatatypeConfigurationException e) {
-            Context.warningOccured(context, source, XmlAdapter.class, "marshal", e, true);
+            Context.warningOccured(context, XmlAdapter.class, "marshal", e, true);
         }
     }
 
     /**
-     * Returns the current date, or {@code null} if none. IF both fields are defined,
+     * Returns the current date, or {@code null} if none. If both fields are defined,
      * then {@link #dateTime} has precedence since it is assumed more accurate.
      */
     final Date getDate() {
-        return XmlUtilities.toDate(dateTime != null ? dateTime : date);
+        return XmlUtilities.toDate(Context.current(), dateTime != null ? dateTime : date);
     }
 
     /**
@@ -110,6 +109,6 @@ public final class GO_DateTime extends X
      */
     @Override
     public GO_DateTime marshal(final Date value) {
-        return (value != null) ? new GO_DateTime(this, value, true) : null;
+        return (value != null) ? new GO_DateTime(value, true) : null;
     }
 }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -22,8 +22,8 @@ import javax.measure.unit.NonSI;
 import javax.measure.quantity.Quantity;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.XmlAttribute;
-import org.apache.sis.internal.jaxb.gmd.CodeListProxy;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.measure.Units;
 
@@ -119,10 +119,6 @@ public final class Measure {
      *
      * @return The string representation of the unit of measure.
      *
-     * @todo The file on schemas.opengis.net is <code>gmxUom.xml</code>, but the file on standards.iso.org
-     *       and eden.ign.fr is <code>ML_gmxUom.xml</code>. Is there some rule allowing us to know which
-     *       filename to use?
-     *
      * @todo Strictly speaking, the above URL should be used only for "m", "deg" and "rad" units because they
      *       are the only ones defined in the <code>gmxUom.xml</code> file. What should we do for other units?
      */
@@ -141,8 +137,8 @@ public final class Measure {
                 return "urn:ogc:def:uom:EPSG::" + code;
             }
         }
-        return Context.schema(Context.current(), "gmd", CodeListProxy.DEFAULT_SCHEMA)
-                .append("resources/uom/gmxUom.xml#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
+        return Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT).append(Schemas.UOM_PATH)
+                .append("#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
     }
 
     /**
@@ -182,7 +178,7 @@ public final class Measure {
      */
     public void setUnit(final Unit<?> newUnit) {
         if (unit != null && !unit.equals(newUnit)) {
-            Context.warningOccured(Context.current(), this, getClass(), "setUnit",
+            Context.warningOccured(Context.current(), getClass(), "setUnit",
                     Errors.class, Errors.Keys.IncompatiblePropertyValue_1, unit);
         }
         unit = newUnit;

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -148,7 +148,7 @@ final class ObjectReference {
         if (value != null) {
             final T previous = map.putSpecialized(authority, value);
             if (previous != null && !previous.equals(value)) {
-                Context.warningOccured(context, map, IdentifierMap.class, "putSpecialized",
+                Context.warningOccured(context, IdentifierMap.class, "putSpecialized",
                         Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(), value);
                 map.putSpecialized(authority, previous);
             }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -46,8 +46,6 @@ import org.apache.sis.internal.jaxb.Cont
  * @since   0.3 (derived from geotk-2.5)
  * @version 0.3
  * @module
- *
- * @see CodeListLocaleAdapter
  */
 public abstract class CodeListAdapter<ValueType extends CodeListAdapter<ValueType,BoundType>,
         BoundType extends CodeList<BoundType>> extends XmlAdapter<ValueType,BoundType>
@@ -64,8 +62,7 @@ public abstract class CodeListAdapter<Va
     }
 
     /**
-     * Creates a wrapper for a {@link CodeList}, in order to handle the format specified
-     * in ISO-19139.
+     * Creates a wrapper for a {@link CodeList}, in order to handle the format specified in ISO-19139.
      *
      * @param proxy The proxy version of {@link CodeList} to be marshalled.
      */

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -25,13 +25,14 @@ import javax.xml.bind.annotation.XmlValu
 import org.opengis.util.CodeList;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.Schemas;
 
 
 /**
  * Stores information about {@link CodeList}, in order to handle format defined in ISO-19139
  * about the {@code CodeList} tags. This object is wrapped by {@link CodeListAdapter} or, in
- * the spacial case of {@link Locale} type, by {@link CodeListLocaleAdapter}. It provides the
- * {@link #codeList} and {@link #codeListValue} attribute to be marshalled.
+ * the spacial case of {@link Locale} type, by {@link LanguageCode} or {@link Country}. This
+ * class provides the {@link #codeList} and {@link #codeListValue} attributes to be marshalled.
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -40,34 +41,28 @@ import org.apache.sis.internal.jaxb.Cont
  * @module
  *
  * @see CodeListAdapter
- * @see CodeListLocaleAdapter
  */
-@XmlType(name = "CodeList", propOrder = { "codeSpace", "codeListValue", "codeList" })
+@XmlType(name = "CodeList", propOrder = { "codeList", "codeListValue", "codeSpace" })
 public final class CodeListProxy {
     /**
-     * The default schema to be given to {@link Context#schema(Context, String, String)} (last argument).
-     */
-    public static final String DEFAULT_SCHEMA = "http://schemas.opengis.net/iso/19139/20070417/";
-
-    /**
      * Returns the URL to a given code list in the given XML file.
-     * This method concatenates the base schema URL with the given file and identifier.
+     * This method concatenates the base schema URL with the given identifier.
      * Some examples of strings returned by this method are:
      *
      * <ul>
-     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode"}</li>
+     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode"}</li>
      *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode"}</li>
      *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode"}</li>
      * </ul>
      *
      * @param  context    The current (un)marshalling context, or {@code null} if none.
-     * @param  file       The XML file, either {@code "gmxCodelists.xml"} or {@code "ML_gmxCodelists.xml"}.
      * @param  identifier The UML identifier of the code list.
      * @return The URL to the given code list in the given schema.
      */
-    private static String schema(final Context context, final String file, final String identifier) {
-        return Context.schema(context, "gmd", DEFAULT_SCHEMA).append("resources/Codelist/")
-                .append(file).append('#').append(identifier).toString();
+    private static String schema(final Context context, final String identifier) {
+        return Context.schema(context, "gmd", Schemas.METADATA_ROOT)
+                .append(Schemas.CODELISTS_PATH) // Future SIS version may switch between localized/unlocalized file.
+                .append('#').append(identifier).toString();
     }
 
     /**
@@ -122,26 +117,25 @@ public final class CodeListProxy {
     }
 
     /**
-     * Builds a {@link CodeList} as defined in ISO-19139 standard.
+     * Builds a value for {@link LanguageCode} and {@link Country} elements.
      *
      * @param context       The current (un)marshalling context, or {@code null} if none.
-     * @param catalog       The file which defines the code list (for example {@code "ML_gmxCodelists.xml"}), without its path.
-     * @param codeList      The {@code codeList} attribute, to be concatenated after the catalog name and the {@code "#"} symbol.
+     * @param codeList      The {@code codeList} attribute, to be concatenated after the {@code "#"} symbol.
      * @param codeListValue The {@code codeListValue} attribute, to be declared in the attribute.
      * @param codeSpace     The 3-letters language code of the {@code value} attribute, or {@code null} if none.
      * @param value         The value in the language specified by the {@code codeSpace} attribute, or {@code null} if none.
      */
-    CodeListProxy(final Context context, final String catalog,
-            final String codeList, final String codeListValue, final String codeSpace, final String value)
+    CodeListProxy(final Context context, final String codeList, final String codeListValue,
+            final String codeSpace, final String value)
     {
-        this.codeList      = schema(context, catalog, codeList);
+        this.codeList      = schema(context, codeList);
         this.codeListValue = codeListValue;
         this.codeSpace     = codeSpace;
         this.value         = value;
     }
 
     /**
-     * Builds a proxy instance of {@link CodeList}.
+     * Builds a value for {@link CodeListAdapter} elements.
      * This constructors stores the values that will be used for marshalling.
      *
      * @param context The current (un)marshalling context, or {@code null} if none.
@@ -150,7 +144,7 @@ public final class CodeListProxy {
     CodeListProxy(final Context context, final CodeList<?> code) {
         final String classID = Types.getListName(code);
         final String fieldID = Types.getCodeName(code);
-        codeList = schema(context, "gmxCodelists.xml", classID);
+        codeList = schema(context, classID);
         /*
          * Get the localized name of the field identifier, if possible.
          * This code partially duplicates Types.getCodeTitle(CodeList).
@@ -165,7 +159,7 @@ public final class CodeListProxy {
                 value = ResourceBundle.getBundle("org.opengis.metadata.CodeLists",
                         locale, CodeList.class.getClassLoader()).getString(key);
             } catch (MissingResourceException e) {
-                Context.warningOccured(context, code, CodeListAdapter.class, "marshal", e, false);
+                Context.warningOccured(context, CodeListAdapter.class, "marshal", e, false);
             }
         }
         if (value != null) {

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -19,12 +19,11 @@ package org.apache.sis.internal.jaxb.gmd
 import java.util.Locale;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
-
-import org.apache.sis.util.Locales;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.gco.GO_CharacterString;
 import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
+import org.apache.sis.util.resources.Errors;
 
 
 /**
@@ -72,7 +71,7 @@ public final class Country extends GO_Ch
 
     /**
      * Builds a {@code <Country>} element.
-     * For private use by {@link #create(Context, Locale, CharSequenceAdapter)} only.
+     * For private use by {@link #create(Context, Locale)} only.
      *
      * @param context       The current (un)marshalling context, or {@code null} if none.
      * @param codeListValue The {@code codeListValue} attribute in the XML element.
@@ -80,7 +79,7 @@ public final class Country extends GO_Ch
      * @param value         The value in the language specified by the {@code codeSpace} attribute, or {@code null} if none.
      */
     private Country(final Context context, final String codeListValue, final String codeSpace, final String value) {
-        proxy = new CodeListProxy(context, "ML_gmxCodelists.xml", "Country", codeListValue, codeSpace, value);
+        proxy = new CodeListProxy(context, "Country", codeListValue, codeSpace, value);
     }
 
     /**
@@ -92,8 +91,8 @@ public final class Country extends GO_Ch
      *         or if its {@link Locale#getCountry()} attribute is the empty string.
      */
     public static Country create(final Context context, final Locale locale) {
-        if (locale != null) {
-            final String codeListValue = Context.converter(context).toCountryCode(context, locale);
+        final String codeListValue = Context.converter(context).toCountryCode(context, locale);
+        if (codeListValue != null) {
             if (!codeListValue.isEmpty() && Context.isFlagSet(context, Context.SUBSTITUTE_COUNTRY)) {
                 /*
                  * Marshal the locale as a <gco:CharacterString> instead than <Country>,
@@ -104,17 +103,12 @@ public final class Country extends GO_Ch
                     return new Country(string);
                 }
             }
-            String codeSpace = null;
-            String value = null;
-            if (context != null) {
-                final Locale marshalLocale = context.getLocale();
-                if (marshalLocale != null) {
-                    codeSpace = Context.converter(context).toLanguageCode(context, locale);
-                    value = locale.getDisplayCountry(marshalLocale);
-                    if (value.isEmpty()) {
-                        value = null;
-                    }
-                }
+            final Locale marshalLocale = LanguageCode.marshalLocale(context);
+            String codeSpace = Context.converter(context).toLanguageCode(context, marshalLocale);
+            String value = locale.getDisplayCountry(marshalLocale);
+            if (value.isEmpty()) {
+                codeSpace = null;
+                value = null;
             }
             if (!codeListValue.isEmpty() || value != null) {
                 return new Country(context, codeListValue, codeSpace, value);
@@ -124,29 +118,44 @@ public final class Country extends GO_Ch
     }
 
     /**
-     * Returns the locale for the given country (which may be null), or {@code null} if none.
+     * Returns the locale for the given language and country (which may be null), or {@code null} if none.
      *
-     * @param value The wrapper for this metadata value.
-     * @return A locale which represents the metadata value.
+     * @param  context  The current (un)marshalling context, or {@code null} if none.
+     * @param  language The wrapper for the language value.
+     * @param  country  The wrapper for the country value.
+     * @param  caller   The class which is invoking this method, used only in case of warning.
+     * @return A locale which represents the language and country value.
      *
      * @see LanguageCode#getLocale(Context, LanguageCode, boolean)
      */
-    public static Locale getLocale(final Country value) {
-        if (value != null) {
-            String code = null;
-            if (value.proxy != null) {
-                code = value.proxy.codeListValue;
-            }
-            // If the country was not specified as a code list,
-            // look for a simple character string declaration.
-            if (code == null) {
-                code = value.toString();
-            }
-            code = CharSequences.trimWhitespaces(code);
-            if (code != null && !code.isEmpty()) {
-                return Locales.unique(new Locale("", code));
+    public static Locale getLocale(final Context context, final LanguageCode language, final Country country,
+            final Class<?> caller)
+    {
+        String code = null;
+        if (language != null) {
+            code = language.getLanguage();
+        }
+        if (country != null) {
+            final CodeListProxy proxy = country.proxy;
+            final String c = CharSequences.trimWhitespaces(proxy != null ? proxy.identifier() : country.toString());
+            if (c != null && !c.isEmpty()) {
+                if (code == null) {
+                    code = "";
+                }
+                int i = code.indexOf('_');
+                if (i < 0) {
+                    code = code + '_' + c;
+                } else {
+                    final int length = code.length();
+                    if (++i == code.length() || code.charAt(i) == '_') {
+                        code = new StringBuilder().append(code, 0, i).append(c).append(code, i, length).toString();
+                    } else if (!c.equals(CharSequences.token(code, i))) {
+                        Context.warningOccured(context, caller, "unmarshal", Errors.class,
+                                Errors.Keys.IncompatiblePropertyValue_1, "country");
+                    }
+                }
             }
         }
-        return null;
+        return Context.converter(context).toLocale(context, code);
     }
 }

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=1551743&r1=1551742&r2=1551743&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] Tue Dec 17 22:39:56 2013
@@ -19,7 +19,6 @@ package org.apache.sis.internal.jaxb.gmd
 import java.util.Locale;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
-
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.gco.GO_CharacterString;
 import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
@@ -43,7 +42,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 = "LanguageCode_PropertyType")
@@ -78,7 +77,7 @@ public final class LanguageCode extends 
      * @param value         The value in the language specified by the {@code codeSpace} attribute, or {@code null} if none.
      */
     private LanguageCode(final Context context, final String codeListValue, final String codeSpace, final String value) {
-        proxy = new CodeListProxy(context, "ML_gmxCodelists.xml", "LanguageCode", codeListValue, codeSpace, value);
+        proxy = new CodeListProxy(context, "LanguageCode", codeListValue, codeSpace, value);
     }
 
     /**
@@ -90,8 +89,8 @@ public final class LanguageCode extends 
      *         or if its {@link Locale#getLanguage()} attribute is the empty string.
      */
     public static LanguageCode create(final Context context, final Locale locale) {
-        if (locale != null) {
-            final String codeListValue = Context.converter(context).toLanguageCode(context, locale);
+        final String codeListValue = Context.converter(context).toLanguageCode(context, locale);
+        if (codeListValue != null) {
             if (!codeListValue.isEmpty() && Context.isFlagSet(context, Context.SUBSTITUTE_LANGUAGE)) {
                 /*
                  * Marshal the locale as a <gco:CharacterString> instead than <LanguageCode>,
@@ -102,11 +101,11 @@ public final class LanguageCode extends 
                     return new LanguageCode(string);
                 }
             }
-            final Locale marshalLocale = (context != null) ? context.getLocale() : null;
-            final String codeSpace = Context.converter(context).toLanguageCode(context, locale);
-            String value = (marshalLocale != null) ? locale.getDisplayLanguage(marshalLocale)
-                                                   : locale.getDisplayLanguage();
+            final Locale marshalLocale = marshalLocale(context);
+            String codeSpace = Context.converter(context).toLanguageCode(context, marshalLocale);
+            String value = locale.getDisplayLanguage(marshalLocale);
             if (value.isEmpty()) {
+                codeSpace = null;
                 value = null;
             }
             if (!codeListValue.isEmpty() || value != null) {
@@ -117,30 +116,46 @@ public final class LanguageCode extends 
     }
 
     /**
-     * Returns the locale for the given language (which may be null), or {@code null} if none.
-     *
-     * @param context The current (un)marshalling context, or {@code null} if none.
-     * @param value The wrapper for this metadata value.
-     * @param useCharSequence Whatever this method should fallback on the
-     *        {@code gco:CharacterString} element if no value were specified for the
-     *        {@code gml:LanguageCode} element.
-     * @return A locale which represents the metadata value.
-     *
-     * @see Country#getLocale(Country)
+     * Returns the locale to use at marshalling time, or the default locale if unspecified.
      */
-    public static Locale getLocale(final Context context, final LanguageCode value, final boolean useCharSequence) {
-        if (value != null) {
-            final CodeListProxy proxy = value.proxy;
-            if (proxy != null) {
-                final Locale locale = Context.converter(context).toLocale(context, proxy.codeListValue);
-                if (locale != null) {
-                    return locale;
-                }
-            }
-            if (useCharSequence) {
-                return Context.converter(context).toLocale(context, value.toString());
+    static Locale marshalLocale(final Context context) {
+        if (context != null) {
+            final Locale marshalLocale = context.getLocale();
+            if (marshalLocale != null) {
+                return marshalLocale;
             }
         }
-        return null;
+        return Locale.getDefault();
+    }
+
+    /**
+     * Returns the language, or {@code null} if none. The language is expected to
+     * be a 2- or 3-letters ISO 639 code, but this is not verified by this method.
+     *
+     * @return The language code
+     */
+    public String getLanguage() {
+        String code;
+        final CodeListProxy proxy = this.proxy;
+        if (proxy != null) {
+            /*
+             * <gmd:language>
+             *   <gmd:LanguageCode codeList="(snip)#LanguageCode" codeListValue="jpn">Japanese</gmd:LanguageCode>
+             * </gmd:language>
+             */
+            code = proxy.identifier(); // May still be null.
+        } else {
+            /*
+             * <gmd:language>
+             *   <gco:CharacterString>jpn</gco:CharacterString>
+             * </gmd:language>
+             */
+            code = toString(); // May still be null.
+        }
+        /*
+         * Do not trim whitespaces. We leave that decision to ValueConverter.
+         * The default implementation of ValueConverter does that.
+         */
+        return code;
     }
 }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -18,7 +18,6 @@ package org.apache.sis.internal.jaxb.gmd
 
 import java.util.Locale;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.sis.internal.jaxb.gco.StringAdapter;
 import org.apache.sis.internal.jaxb.Context;
 
 
@@ -28,14 +27,14 @@ import org.apache.sis.internal.jaxb.Cont
  *
  * {@preformat xml
  *   <gmd:language>
- *     <gco:CharacterString>eng</gco:CharacterString>
+ *     <gmd:LanguageCode codeList="(snip)#LanguageCode" codeListValue="jpn">Japanese</gmd:LanguageCode>
  *   </gmd:language>
  * }
  *
  * @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 LanguageCode
@@ -58,12 +57,7 @@ public final class LocaleAdapter extends
     @Override
     public Locale unmarshal(final LanguageCode value) {
         final Context context = Context.current();
-        final Locale candidate = LanguageCode.getLocale(context, value, false);
-        if (candidate != null) {
-            return candidate;
-        }
-        final String text = StringAdapter.toString(value);
-        return (text != null) ? Context.converter(context).toLocale(context, text) : null;
+        return Context.converter(context).toLocale(context, value.getLanguage());
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1551743&r1=1551742&r2=1551743&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] Tue Dec 17 22:39:56 2013
@@ -40,10 +40,11 @@ import org.apache.sis.internal.jdk7.Obje
  */
 final class LocalisedCharacterString {
     /**
-     * A prefix to concatenate with the {@linkplain Locale#getISO3Language() language code}
-     * in order to get the attribute value specified in ISO-19139 for this elements.
+     * A prefix to concatenate with the {@linkplain Locale#getISO3Language() language code}.
+     * This is a hack for a common pattern found in the way locales are specified in ISO 19139 files.
+     * See <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a> for more information.
      */
-    private static final String LOCALE = "#locale-";
+    private static final String PREFIX = "#locale-";
 
     /**
      * The locale value for this string.
@@ -75,10 +76,10 @@ final class LocalisedCharacterString {
     }
 
     /**
-     * Returns the locale language, as specified by ISO-19139 for
-     * {@code <LocalisedCharacterString>} attribute.
+     * Returns the locale language for {@code <LocalisedCharacterString>} attribute.
      *
      * @return The current locale.
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a>
      */
     @XmlAttribute(name = "locale", required = true)
     public String getLocale() {
@@ -86,7 +87,7 @@ final class LocalisedCharacterString {
             return null;
         }
         final Context context = Context.current();
-        return LOCALE.concat(Context.converter(context).toLanguageCode(context, locale));
+        return PREFIX.concat(Context.converter(context).toLanguageCode(context, locale));
     }
 
     /**
@@ -94,6 +95,7 @@ final class LocalisedCharacterString {
      * where {@code xxx} are the two or three letters representing the language.
      *
      * @param localeId The new locale.
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a>
      */
     public void setLocale(final String localeId) {
         if (localeId != null) {



Mime
View raw message