You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2012/12/25 09:19:08 UTC

svn commit: r1425728 - in /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb: MarshalContext.java gco/InternationalStringAdapter.java gco/StringAdapter.java gco/URIAdapter.java gmd/LocaleAdapter.java gmx/Anchor.java

Author: desruisseaux
Date: Tue Dec 25 08:19:07 2012
New Revision: 1425728

URL: http://svn.apache.org/viewvc?rev=1425728&view=rev
Log:
Ported a few adapters to be used in JAXB (un)marshalling.

Added:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java   (with props)
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java   (with props)
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java   (with props)
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java   (with props)
Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java?rev=1425728&r1=1425727&r2=1425728&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java Tue Dec 25 08:19:07 2012
@@ -29,7 +29,10 @@ import org.apache.sis.util.collection.Un
 
 /**
  * Thread-local status of a marshalling or unmarshalling process.
- * Contains also static methods for managing the collections to be marshalled.
+ * All non-static methods in this class except {@link #finish()} are implementation of public API.
+ * All static methods are internal API. Those methods expect a {@code MarshalContext} instance as
+ * their first argument. They should be though as if they were normal member methods, except that
+ * they accept {@code null} instance if no (un)marshalling is in progress.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
@@ -45,16 +48,22 @@ public final class MarshalContext extend
 
     /**
      * The bit flag for enabling substitution of language codes by character strings.
+     *
+     * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
     public static final int SUBSTITUTE_LANGUAGE = 2;
 
     /**
      * The bit flag for enabling substitution of country codes by character strings.
+     *
+     * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
     public static final int SUBSTITUTE_COUNTRY = 4;
 
     /**
-     * The thread-local context.
+     * The thread-local context. Elements are created in the constructor, and removed in a
+     * {@code finally} block by the {@link #finish()} method. This {@code ThreadLocal} shall
+     * not contain any value when no (un)marshalling is in progress.
      */
     private static final ThreadLocal<MarshalContext> CURRENT = new ThreadLocal<>();
 
@@ -162,6 +171,45 @@ public final class MarshalContext extend
     }
 
     /**
+     * Returns the schema version of the XML document being (un)marshalled.
+     * See the super-class javadoc for the list of prefix that we shall support.
+     */
+    @Override
+    public final Version getVersion(final String prefix) {
+        if (prefix.equals("gml")) {
+            return versionGML;
+        }
+        // Future SIS versions may add more cases here.
+        return null;
+    }
+
+    /**
+     * Returns the locale to use for marshalling, or {@code null} if no locale were explicitly
+     * specified. A {@code null} value means that some locale-neutral language should be used
+     * if available, or an implementation-default locale (typically English) otherwise.
+     */
+    @Override
+    public final Locale getLocale() {
+        return locale;
+    }
+
+    /**
+     * Returns the timezone, or {@code null} if none were explicitely defined.
+     * In the later case, an implementation-default (typically UTC) timezone is used.
+     */
+    @Override
+    public final TimeZone getTimeZone() {
+        return timezone;
+    }
+
+    /*
+     * ---- END OF PUBLIC API --------------------------------------------------------------
+     *
+     * Following are internal API. They are provided as static methods with a MarshalContext
+     * argument rather than normal member methods in order to accept null context.
+     */
+
+    /**
      * Returns the context of the XML (un)marshalling currently progressing in the current thread,
      * or {@code null} if none.
      *
@@ -174,13 +222,13 @@ public final class MarshalContext extend
     /**
      * Returns {@code true} if the given flag is set.
      *
+     * @param  context The current context, or {@code null} if none.
      * @param  flag One of {@link #MARSHALING}, {@link #SUBSTITUTE_LANGUAGE},
      *         {@link #SUBSTITUTE_COUNTRY} or other bit masks.
      * @return {@code true} if the given flag is set.
      */
-    public static boolean isFlagSet(final int flag) {
-        final MarshalContext current = current();
-        return (current != null) && (current.bitMasks & flag) != 0;
+    public static boolean isFlagSet(final MarshalContext context, final int flag) {
+        return (context != null) && (context.bitMasks & flag) != 0;
     }
 
     /**
@@ -189,12 +237,12 @@ public final class MarshalContext extend
      *
      * {@note This method is static for the convenience of performing the check for null context.}
      *
-     * @param  current The current context, or {@code null} if none.
+     * @param  context The current context, or {@code null} if none.
      * @return The current value converter (never null).
      */
-    public static ValueConverter converter(final MarshalContext current) {
-        if (current != null) {
-            final ValueConverter converter = current.converter;
+    public static ValueConverter converter(final MarshalContext context) {
+        if (context != null) {
+            final ValueConverter converter = context.converter;
             if (converter != null) {
                 return converter;
             }
@@ -208,12 +256,12 @@ public final class MarshalContext extend
      *
      * {@note This method is static for the convenience of performing the check for null context.}
      *
-     * @param  current The current context, or {@code null} if none.
+     * @param  context The current context, or {@code null} if none.
      * @return The current reference resolver (never null).
      */
-    public static ReferenceResolver resolver(final MarshalContext current) {
-        if (current != null) {
-            final ReferenceResolver resolver = current.resolver;
+    public static ReferenceResolver resolver(final MarshalContext context) {
+        if (context != null) {
+            final ReferenceResolver resolver = context.resolver;
             if (resolver != null) {
                 return resolver;
             }
@@ -227,15 +275,15 @@ public final class MarshalContext extend
      *
      * {@note This method is static for the convenience of performing the check for null context.}
      *
-     * @param  current The current context, or {@code null} if none.
+     * @param  context The current context, or {@code null} if none.
      * @param  key One of the value documented in the "<cite>Map key</cite>" column of
      *         {@link org.apache.sis.xml.XML#SCHEMAS}.
      * @param  defaultSchema The value to return if no schema is found for the given key.
      * @return The base URL of the schema, or {@code null} if none were specified.
      */
-    public static String schema(final MarshalContext current, final String key, final String defaultSchema) {
-        if (current != null) {
-            final Map<String,String> schemas = current.schemas;
+    public static String schema(final MarshalContext context, final String key, final String defaultSchema) {
+        if (context != null) {
+            final Map<String,String> schemas = context.schemas;
             if (schemas != null) {
                 final String schema = schemas.get(key);
                 if (schema != null) {
@@ -253,15 +301,15 @@ public final class MarshalContext extend
      *
      * {@note This method is static for the convenience of performing the check for null context.}
      *
-     * @param  current The current context, or {@code null} if none.
+     * @param  context The current context, or {@code null} if none.
      * @param  version The version to compare to.
      * @return {@code true} if the GML version is equals or newer than the specified version.
      *
      * @see #getVersion(String)
      */
-    public static boolean isGMLVersion(final MarshalContext current, final Version version) {
-        if (current != null) {
-            final Version versionGML = current.versionGML;
+    public static boolean isGMLVersion(final MarshalContext context, final Version version) {
+        if (context != null) {
+            final Version versionGML = context.versionGML;
             if (versionGML != null) {
                 return versionGML.compareTo(version) >= 0;
             }
@@ -270,53 +318,59 @@ public final class MarshalContext extend
     }
 
     /**
-     * Returns the schema version of the XML document being (un)marshalled.
-     * See the super-class javadoc for the list of prefix that we shall support.
+     * If marshalling, filters the given collection of identifiers in order to omit any identifiers
+     * for which the authority is one of the {@link org.apache.sis.xml.IdentifierSpace} constants.
+     *
+     * @param  identifiers The identifiers to filter, or {@code null}.
+     * @return The identifiers to marshal, or {@code null} if none.
      */
-    @Override
-    public final Version getVersion(final String prefix) {
-        if (prefix.equals("gml")) {
-            return versionGML;
+    public static Collection<Identifier> filterIdentifiers(Collection<Identifier> identifiers) {
+        if (identifiers != null && isFlagSet(current(), MARSHALING)) {
+            int count = identifiers.size();
+            if (count != 0) {
+                final Identifier[] copy = identifiers.toArray(new Identifier[count]);
+                for (int i=count; --i>=0;) {
+                    final Identifier id = copy[i];
+                    if (id == null || (id.getAuthority() instanceof NonMarshalledAuthority)) {
+                        System.arraycopy(copy, i+1, copy, i, --count - i);
+                    }
+                }
+                identifiers = (count != 0) ? UnmodifiableArrayList.wrap(copy, 0, count) : null;
+            }
         }
-        // Future SIS versions may add more cases here.
-        return null;
-    }
-
-    /**
-     * Returns the timezone, or {@code null} if none were explicitely defined.
-     * In the later case, an implementation-default (typically UTC) timezone is used.
-     */
-    @Override
-    public final TimeZone getTimeZone() {
-        return timezone;
-    }
-
-    /**
-     * Returns the locale to use for marshalling, or {@code null} if no locale were explicitly
-     * specified. A {@code null} value means that some locale-neutral language should be used
-     * if available, or an implementation-default locale (typically English) otherwise.
-     */
-    @Override
-    public final Locale getLocale() {
-        return locale;
+        return identifiers;
     }
 
     /**
      * Sets the locale to the given value. The old locales are remembered and will
-     * be restored by the next call to {@link #pullLocale()}.
+     * be restored by the next call to {@link #pull()}. This method can be invoked
+     * when marshalling object that need to marshall their children in a different
+     * locale, like below:
+     *
+     * {@preformat java
+     *     private void beforeMarshal(Marshaller marshaller) {
+     *         MarshalContext.push(language);
+     *     }
+     *
+     *     private void afterMarshal(Marshaller marshaller) {
+     *         MarshalContext.pull();
+     *     }
+     * }
      *
      * @param locale The locale to set, or {@code null}.
      */
     public static void push(final Locale locale) {
-        final MarshalContext current = new MarshalContext(current());
+        final MarshalContext context = new MarshalContext(current());
         if (locale != null) {
-            current.locale = locale;
+            context.locale = locale;
         }
     }
 
     /**
-     * Restores the locale (or any other setting) which was used prior the call to
-     * {@link #push(Locale)}.
+     * Restores the locale (or any other setting) which was used prior the call
+     * to {@link #push(Locale)}. It is not necessary to invoke this method in a
+     * {@code finally} block if the parent {@code MarshalContext} is itself
+     * disposed in a {@code finally} block.
      */
     public static void pull() {
         final MarshalContext current = current();
@@ -326,30 +380,6 @@ public final class MarshalContext extend
     }
 
     /**
-     * If marshalling, filters the given collection of identifiers in order to omit any identifiers
-     * for which the authority is one of the {@link org.apache.sis.xml.IdentifierSpace} constants.
-     *
-     * @param  identifiers The identifiers to filter, or {@code null}.
-     * @return The identifiers to marshal, or {@code null} if none.
-     */
-    public static Collection<Identifier> filterIdentifiers(Collection<Identifier> identifiers) {
-        if (identifiers != null && isFlagSet(MARSHALING)) {
-            int count = identifiers.size();
-            if (count != 0) {
-                final Identifier[] copy = identifiers.toArray(new Identifier[count]);
-                for (int i=count; --i>=0;) {
-                    final Identifier id = copy[i];
-                    if (id == null || (id.getAuthority() instanceof NonMarshalledAuthority)) {
-                        System.arraycopy(copy, i+1, copy, i, --count - i);
-                    }
-                }
-                identifiers = (count != 0) ? UnmodifiableArrayList.wrap(copy, 0, count) : null;
-            }
-        }
-        return identifiers;
-    }
-
-    /**
      * Invoked in a {@code finally} block when a unmarshalling process is finished.
      */
     public final void finish() {

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java?rev=1425728&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java (added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java Tue Dec 25 08:19:07 2012
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.gco;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.opengis.util.InternationalString;
+import org.apache.sis.util.iso.SimpleInternationalString;
+
+
+/**
+ * JAXB adapter for XML {@code <GO_CharacterString>} element mapped to {@link InternationalString}.
+ * This adapter is similar to {@link StringAdapter}, except that the {@code unmarshall} method does
+ * not need to localize {@code InternationalString} instances for the locale specified in the current
+ * marshaller context.
+ *
+ * @author  Cédric Briançon (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.3 (derived from geotk-2.5)
+ * @version 0.3
+ * @module
+ */
+public final class InternationalStringAdapter extends XmlAdapter<GO_CharacterString, InternationalString> {
+    /**
+     * The adapter on which to delegate the marshalling processes.
+     */
+    private final CharSequenceAdapter adapter;
+
+    /**
+     * Empty constructor for JAXB.
+     */
+    private InternationalStringAdapter() {
+        adapter = new CharSequenceAdapter();
+    }
+
+    /**
+     * Creates a new adapter which will use the anchor map from the given adapter.
+     *
+     * @param adapter The adaptor on which to delegate the work.
+     */
+    public InternationalStringAdapter(final CharSequenceAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Converts an object read from a XML stream to an {@link InternationalString} implementation.
+     * JAXB invokes automatically this method at unmarshalling time.
+     *
+     * @param value The adapter for the string value.
+     * @return An {@link InternationalString} for the string value.
+     */
+    @Override
+    public InternationalString unmarshal(final GO_CharacterString value) {
+        final CharSequence text = adapter.unmarshal(value);
+        if (text != null) {
+            if (text instanceof InternationalString) {
+                return (InternationalString) text;
+            }
+            return new SimpleInternationalString(text.toString());
+        }
+        return null;
+    }
+
+    /**
+     * Converts an {@link InternationalString} to an object to format into a XML stream.
+     * JAXB invokes automatically this method at marshalling time.
+     *
+     * @param  value The string value.
+     * @return The adapter for the string.
+     */
+    @Override
+    public GO_CharacterString marshal(final InternationalString value) {
+        return adapter.marshal(value);
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1425728&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java (added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java Tue Dec 25 08:19:07 2012
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.gco;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.opengis.util.InternationalString;
+import org.apache.sis.internal.jaxb.MarshalContext;
+
+
+/**
+ * JAXB adapter for XML {@code <GO_CharacterString>} element mapped to {@link String}.
+ * This adapter is similar to {@link InternationalStringAdapter}, except that the {@code unmarshall}
+ * method needs to localize {@link InternationalString} instances for the locale specified in the
+ * current marshaller context.
+ *
+ * @author  Cédric Briançon (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-2.5)
+ * @version 0.3
+ * @module
+ */
+public final class StringAdapter extends XmlAdapter<GO_CharacterString, String> {
+    /**
+     * The adapter on which to delegate the marshalling processes.
+     */
+    private final CharSequenceAdapter adapter;
+
+    /**
+     * Empty constructor for JAXB.
+     */
+    private StringAdapter() {
+        adapter = new CharSequenceAdapter();
+    }
+
+    /**
+     * Creates a new adapter which will use the anchor map from the given adapter.
+     *
+     * @param adapter The adaptor on which to delegate the work.
+     */
+    public StringAdapter(final CharSequenceAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Returns a string representation of the given character sequence. If the given
+     * sequence is an instance of {@link InternationalString}, then the locale from
+     * the current unmashalling context is used in order to get a string.
+     *
+     * @param text The text for which to get a string representation, or {@code null}.
+     * @return The string representation of the given text, or {@code null}.
+     */
+    public static String toString(final CharSequence text) {
+        if (text != null) {
+            if (text instanceof InternationalString) {
+                final MarshalContext context = MarshalContext.current();
+                return ((InternationalString) text).toString(context != null ? context.getLocale() : null);
+            }
+            return text.toString();
+        }
+        return null;
+    }
+
+    /**
+     * Converts a string read from a XML stream to the object containing the value.
+     * JAXB calls automatically this method at unmarshalling time.
+     *
+     * @param value The adapter for this metadata value.
+     * @return A {@link String} which represents the metadata value.
+     */
+    @Override
+    public String unmarshal(final GO_CharacterString value) {
+        return toString(adapter.unmarshal(value));
+    }
+
+    /**
+     * Converts a {@linkplain String string} to the object to be marshalled in a XML file or stream.
+     * JAXB calls automatically this method at marshalling time.
+     *
+     * @param value The string value.
+     * @return The adapter for this string.
+     */
+    @Override
+    public GO_CharacterString marshal(final String value) {
+        return adapter.marshal(value);
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java?rev=1425728&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java (added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java Tue Dec 25 08:19:07 2012
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.gco;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.sis.internal.jaxb.MarshalContext;
+
+
+/**
+ * JAXB adapter wrapping a URI value with a {@code <gco:CharacterString>} element,
+ * for ISO-19139 compliance.
+ *
+ * @author  Cédric Briançon (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-2.5)
+ * @version 0.3
+ * @module
+ */
+public final class URIAdapter extends XmlAdapter<GO_CharacterString, URI> {
+    /**
+     * The adapter on which to delegate the marshalling processes.
+     */
+    private final CharSequenceAdapter adapter;
+
+    /**
+     * Empty constructor for JAXB.
+     */
+    private URIAdapter() {
+        adapter = new CharSequenceAdapter();
+    }
+
+    /**
+     * Creates a new adapter which will use the anchor map from the given adapter.
+     *
+     * @param adapter The adaptor on which to delegate the work.
+     */
+    public URIAdapter(final CharSequenceAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Converts a URI read from a XML stream to the object containing the value.
+     * JAXB calls automatically this method at unmarshalling time.
+     *
+     * @param  value The adapter for this metadata value.
+     * @return An {@link URI} which represents the metadata value.
+     * @throws URISyntaxException If the string is not a valid URI.
+     */
+    @Override
+    public URI unmarshal(final GO_CharacterString value) throws URISyntaxException {
+        final String text = StringAdapter.toString(adapter.unmarshal(value));
+        final MarshalContext context = MarshalContext.current();
+        return (text != null) ? MarshalContext.converter(context).toURI(context, text) : null;
+    }
+
+    /**
+     * Converts a {@link URI} to the object to be marshalled in a XML file or stream.
+     * JAXB calls automatically this method at marshalling time.
+     *
+     * @param  value The URI value.
+     * @return The adapter for the given URI.
+     */
+    @Override
+    public GO_CharacterString marshal(final URI value) {
+        return (value != null) ? adapter.marshal(value.toString()) : null;
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java?rev=1425728&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java (added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java Tue Dec 25 08:19:07 2012
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.gmd;
+
+import java.util.Locale;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.sis.internal.jaxb.MarshalContext;
+import org.apache.sis.internal.jaxb.gco.StringAdapter;
+import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
+
+
+/**
+ * JAXB adapter for XML {@code <GO_CharacterString>} or {@code <LanguageCode>} elements
+ * mapped to {@link Locale}. This adapter formats the locale like below:
+ *
+ * {@preformat xml
+ *   <gmd:language>
+ *     <gco:CharacterString>eng</gco:CharacterString>
+ *   </gmd:language>
+ * }
+ *
+ * @author  Cédric Briançon (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-2.5)
+ * @version 0.3
+ * @module
+ *
+ * @see org.apache.sis.internal.jaxb.gmd.LanguageCode
+ * @see org.apache.sis.internal.jaxb.gmd.PT_Locale
+ */
+public final class LocaleAdapter extends XmlAdapter<LanguageCode, Locale> {
+    /**
+     * The adapter on which to delegate the marshalling processes.
+     */
+    private final CharSequenceAdapter adapter;
+
+    /**
+     * Empty constructor for JAXB.
+     */
+    private LocaleAdapter() {
+        adapter = new CharSequenceAdapter();
+    }
+
+    /**
+     * Creates a new adapter which will use the anchor map from the given adapter.
+     *
+     * @param adapter The adaptor on which to delegate the work.
+     */
+    public LocaleAdapter(final CharSequenceAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Converts the locale read from a XML stream to the object containing the value.
+     * JAXB calls automatically this method at unmarshalling time.
+     *
+     * @param  value The adapter for this metadata value.
+     * @return A {@linkplain Locale locale} which represents the metadata value.
+     */
+    @Override
+    public Locale unmarshal(final LanguageCode value) {
+        final MarshalContext context = MarshalContext.current();
+        final Locale candidate = LanguageCode.getLocale(context, value, false);
+        if (candidate != null) {
+            return candidate;
+        }
+        final String text = StringAdapter.toString(adapter.unmarshal(value));
+        return (text != null) ? MarshalContext.converter(context).toLocale(context, text) : null;
+    }
+
+    /**
+     * Converts the {@linkplain Locale locale} to the object to be marshalled in a XML file or stream.
+     * JAXB calls automatically this method at marshalling time.
+     *
+     * @param  value The locale value.
+     * @return The adapter for the given locale.
+     */
+    @Override
+    public LanguageCode marshal(final Locale value) {
+        final MarshalContext context = MarshalContext.current();
+        return LanguageCode.create(context, value,
+                MarshalContext.isFlagSet(context, MarshalContext.SUBSTITUTE_LANGUAGE) ? adapter : null);
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocaleAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java?rev=1425728&r1=1425727&r2=1425728&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java Tue Dec 25 08:19:07 2012
@@ -29,7 +29,7 @@ import java.util.Objects;
 
 /**
  * The {@code Anchor} element, which is included in {@code CharacterString} elements.
- * This class extends {@link InternationalString} in an opportunist way, in order to allow
+ * This class implements {@link InternationalString} in an opportunist way, in order to allow
  * direct usage with public API expecting {@link CharSequence} or {@link InternationalString}
  * object.
  *