sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1614706 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/ sis-util...
Date Wed, 30 Jul 2014 16:33:49 GMT
Author: desruisseaux
Date: Wed Jul 30 16:33:48 2014
New Revision: 1614706

URL: http://svn.apache.org/r1614706
Log:
Replaced the 'Name' temporary object by a more generic <gml:CodeType>.
This allowed us to get support for the 'codeSpace' attribute in NameAdapter.

Added:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/CodeType.java
      - copied, changed from r1614668, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
Removed:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -16,9 +16,10 @@
  */
 package org.apache.sis.internal.jaxb.metadata.direct;
 
-import org.opengis.util.GenericName;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.opengis.util.ScopedName;
+import org.opengis.util.GenericName;
+import org.apache.sis.internal.jaxb.gml.CodeType;
 
 
 /**
@@ -32,7 +33,7 @@ import org.opengis.util.ScopedName;
  *
  * @see org.apache.sis.internal.jaxb.gco.GO_GenericName
  */
-public final class GO_ScopedName extends XmlAdapter<Name, ScopedName> {
+public final class GO_ScopedName extends XmlAdapter<CodeType.ScopedName, ScopedName>
{
     /**
      * Converts a GeoAPI interface to the SIS implementation for XML marshalling.
      *
@@ -40,11 +41,11 @@ public final class GO_ScopedName extends
      * @return The adapter for the given value, here the SIS implementation.
      */
     @Override
-    public Name marshal(final ScopedName name) {
+    public CodeType.ScopedName marshal(final ScopedName name) {
         if (name != null) {
-            final Name wrapper = new Name();
-            wrapper.set(name);
-            return wrapper;
+            final CodeType.ScopedName code = new CodeType.ScopedName();
+            code.setName(name);
+            return code;
         }
         return null;
     }
@@ -52,13 +53,13 @@ public final class GO_ScopedName extends
     /**
      * Returns the scope name from the given string.
      *
-     * @param  wrapper The metadata value.
+     * @param  code The metadata value.
      * @return The value to marshal (which is the same).
      */
     @Override
-    public ScopedName unmarshal(final Name wrapper) {
-        if (wrapper != null) {
-            final GenericName parsed = wrapper.get();
+    public ScopedName unmarshal(final CodeType.ScopedName code) {
+        if (code != null) {
+            final GenericName parsed = code.getName();
             if (parsed instanceof ScopedName) {
                 return (ScopedName) parsed;
             }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -17,7 +17,6 @@
 package org.apache.sis.internal.jaxb.gco;
 
 import org.opengis.util.GenericName;
-import org.apache.sis.util.iso.AbstractName;
 
 
 /**
@@ -49,12 +48,12 @@ public final class GO_GenericName extend
     /**
      * Wraps a name at marshalling-time.
      */
-    private GO_GenericName(final AbstractName value) {
+    private GO_GenericName(final GenericName value) {
         name = value;
     }
 
     /**
-     * Does the link between an {@link AbstractName} and the adapter associated.
+     * Does the link between an {@link GenericName} and the adapter associated.
      * JAXB calls automatically this method at marshalling-time.
      *
      * @param  value The implementing class for this metadata value.
@@ -62,7 +61,7 @@ public final class GO_GenericName extend
      */
     @Override
     public GO_GenericName marshal(final GenericName value) {
-        return (value != null) ? new GO_GenericName(AbstractName.castOrCopy(value)) : null;
+        return (value != null) ? new GO_GenericName(value) : null;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -17,7 +17,6 @@
 package org.apache.sis.internal.jaxb.gco;
 
 import org.opengis.util.LocalName;
-import org.apache.sis.util.iso.DefaultLocalName;
 
 
 /**
@@ -48,7 +47,7 @@ public final class GO_LocalName extends 
     /**
      * Wraps a name at marshalling-time.
      */
-    private GO_LocalName(final DefaultLocalName value) {
+    private GO_LocalName(final LocalName value) {
         name = value;
     }
 
@@ -61,7 +60,7 @@ public final class GO_LocalName extends 
      */
     @Override
     public GO_LocalName marshal(final LocalName value) {
-        return (value != null) ? new GO_LocalName(DefaultLocalName.castOrCopy(value)) : null;
+        return (value != null) ? new GO_LocalName(value) : null;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -16,15 +16,15 @@
  */
 package org.apache.sis.internal.jaxb.gco;
 
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.opengis.util.TypeName;
 import org.opengis.util.LocalName;
 import org.opengis.util.ScopedName;
 import org.opengis.util.MemberName;
 import org.opengis.util.GenericName;
-import org.apache.sis.internal.system.DefaultFactories;
-import org.apache.sis.util.iso.AbstractName;
+import org.apache.sis.internal.jaxb.gml.CodeType;
+import org.apache.sis.util.iso.DefaultLocalName;
 import org.apache.sis.util.iso.DefaultTypeName;
 import org.apache.sis.util.iso.DefaultMemberName;
 import org.apache.sis.util.resources.Errors;
@@ -46,7 +46,7 @@ import org.apache.sis.util.resources.Err
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.5
  * @module
  */
 abstract class NameAdapter<ValueType extends NameAdapter<ValueType,BoundType>, BoundType
extends GenericName>
@@ -55,7 +55,7 @@ abstract class NameAdapter<ValueType ext
     /**
      * The generic name to be marshalled.
      */
-    AbstractName name;
+    GenericName name;
 
     /**
      * Empty constructor for subclasses only.
@@ -75,118 +75,70 @@ abstract class NameAdapter<ValueType ext
     }
 
     /**
-     * Returns the {@code LocalName} generated from the metadata value.
-     * The local name is returned only if it is not a {@link TypeName} or a {@link MemberName}
-     * (otherwise, the corresponding {@code getXXX()} method needs to be invoked instead.
+     * Returns the {@code LocalName} or {@code ScopedName} to marshall. Returns {@code null} if
the name
+     * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getNameType()}
instead.
      *
-     * @return The current local name, or {@code null} if none.
-     *
-     * @see #getTypeName()
-     * @see #getMemberName()
-     */
-    @XmlElement(name = "LocalName")
-    public final String getLocalName() {
-        final AbstractName name = this.name;
-        return (name instanceof LocalName) && !(name instanceof TypeName)
-                && !(name instanceof MemberName) ? name.toString() : null;
-    }
-
-    /**
-     * Sets the value for the {@code LocalName}.
-     * This method is called at unmarshalling-time by JAXB.
-     *
-     * @param  value The new name.
-     * @throws IllegalStateException If a name is already defined.
+     * @return The code for the current name, or {@code null} if none.
      */
-    public final void setLocalName(final String value) throws IllegalStateException {
-        ensureUndefined();
-        if (value == null) {
-            name = null;
+    @XmlElementRef
+    public final CodeType getCodeType() {
+        final GenericName name = this.name;
+        final CodeType code;
+        if (name instanceof LocalName) {
+            if (name instanceof TypeName || name instanceof MemberName) {
+                return null;
+            } else {
+                code = new CodeType.LocalName();
+            }
+        } else if (name instanceof ScopedName) {
+            code = new CodeType.ScopedName();
         } else {
-            /*
-             * Following cast should be safe because the SIS_NAMES factory is fixed to a
-             * DefaultNameFactory instance, which is known to create AbstractName instances.
-             */
-            name = (AbstractName) DefaultFactories.SIS_NAMES.createLocalName(null, value);
+            return null;
         }
+        code.setName(name);
+        return code;
     }
 
     /**
-     * Returns the {@code ScopedName} generated from the metadata value.
-     * This method is called at marshalling-time by JAXB.
-     *
-     * @return The current name, or {@code null} if none.
-     */
-    @XmlElement(name = "ScopedName")
-    public final String getScopedName() {
-        final AbstractName name = this.name;
-        return (name instanceof ScopedName) ? name.toString() : null;
-    }
-
-    /**
-     * Sets the value for the {@code ScopedName}.
+     * Sets the value for the {@code LocalName} or {@code ScopedName}.
      * This method is called at unmarshalling-time by JAXB.
      *
-     * @param  value The new name.
+     * @param  code The new name.
      * @throws IllegalStateException If a name is already defined.
      */
-    public final void setScopedName(final String value) throws IllegalStateException {
+    public final void setCodeType(final CodeType code) throws IllegalStateException {
         ensureUndefined();
-        if (value == null) {
-            name = null;
-        } else {
-            /*
-             * Following cast should be safe because the SIS_NAMES factory is fixed to a
-             * DefaultNameFactory instance, which is known to create AbstractName instances.
-             */
-            name = (AbstractName) DefaultFactories.SIS_NAMES.parseGenericName(null, value);
+        if (code != null) {
+            name = code.getName();
         }
     }
 
     /**
-     * Returns the {@code TypeName} generated from the metadata value.
-     * This method is called at marshalling-time by JAXB.
+     * Returns the {@code TypeName} or {@code MemberName} to marshall. Returns {@code null}
if the name
+     * is a {@link LocalName} or {@link ScopedName}, in order to use {@link #getCodeType()}
instead.
      *
      * @return The current name, or {@code null} if none.
      */
-    @XmlElement(name = "TypeName")
-    public final DefaultTypeName getTypeName() {
-        final AbstractName name = this.name;
-        return (name instanceof DefaultTypeName) ? (DefaultTypeName) name : null;
-    }
-
-    /**
-     * Sets the value for the {@code TypeName}.
-     * This method is called at unmarshalling-time by JAXB.
-     *
-     * @param  value The new name.
-     * @throws IllegalStateException If a name is already defined.
-     */
-    public final void setTypeName(final DefaultTypeName value) throws IllegalStateException
{
-        ensureUndefined();
-        name = value;
-    }
-
-    /**
-     * Returns the {@code MemberName} generated from the metadata value.
-     * This method is called at marshalling-time by JAXB.
-     *
-     * @return The current name, or {@code null} if none.
-     */
-    @XmlElement(name = "MemberName")
-    public final DefaultMemberName getMemberName() {
-        final AbstractName name = this.name;
-        return (name instanceof MemberName) ? (DefaultMemberName) name : null;
+    @XmlElementRef
+    public final DefaultLocalName getNameType() {
+        final GenericName name = this.name;
+        if (name instanceof TypeName) {
+            return DefaultTypeName.castOrCopy((TypeName) name);
+        } else if (name instanceof MemberName) {
+            return DefaultMemberName.castOrCopy((MemberName) name);
+        } else {
+            return null;
+        }
     }
 
     /**
-     * Sets the value for the {@code MemberName}.
+     * Sets the value from the {@code TypeName} or {@code MemberName}.
      * This method is called at unmarshalling-time by JAXB.
      *
      * @param  value The new name.
      * @throws IllegalStateException If a name is already defined.
      */
-    public final void setMemberName(final DefaultMemberName value) throws IllegalStateException
{
+    public final void setNameType(final DefaultLocalName value) throws IllegalStateException
{
         ensureUndefined();
         name = value;
     }

Copied: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/CodeType.java
(from r1614668, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/CodeType.java?p2=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/CodeType.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java&r1=1614668&r2=1614706&rev=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/CodeType.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -14,50 +14,75 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.jaxb.metadata.direct;
+package org.apache.sis.internal.jaxb.gml;
 
-import org.opengis.util.NameSpace;
-import org.opengis.util.GenericName;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
 import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.sis.xml.Namespaces;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import org.opengis.util.NameSpace;
+import org.opengis.util.GenericName;
 import org.apache.sis.util.iso.Names;
+import org.apache.sis.xml.Namespaces;
 
 
 /**
- * A name to be marshalled instead than the {@link org.apache.sis.util.iso} object.
+ * A generalized type to be used for a term, keyword or name.
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * {@preformat xml
+ *   <complexType name="CodeType">
+ *     <simpleContent>
+ *       <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *         <attribute name="codeSpace" type="{http://www.w3.org/2001/XMLSchema}anyURI"
/>
+ *       </extension>
+ *     </simpleContent>
+ *   </complexType>
+ * }
+ *
+ * {@code CodeType}s are used for:
+ *
+ * <ul>
+ *   <li>{@code GenericName}</li>
+ *   <li>{@link LocalName}</li>
+ *   <li>{@link ScopedName}</li>
+ * </ul>
+ *
+ * {@code CodeType}s are not used for {@code MemberName} and {@code TypeName}.
+ * The two later use a quite different XML structure, with an {@code aName} element instead
than a XML value.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
  * @version 0.5
  * @module
- *
- * @see org.apache.sis.internal.jaxb.gco.GO_GenericName
- *
- * @todo This class could be shared for other kind if names (not just scoped names).
  */
-@XmlRootElement(name = "ScopedName", namespace = Namespaces.GCO)
-public final class Name {
+@XmlSeeAlso({
+    CodeType.LocalName.class,
+    CodeType.ScopedName.class
+})
+public class CodeType {
     /**
-     * The scoped name.
+     * The term.
      */
     @XmlValue
-    private String name;
+    String value;
 
     /**
-     * The code space, or {@code null} if none.
+     * Dictionary, thesaurus, classification scheme, authority, or pattern for the {@linkplain
#term},
+     * or {@code null} if none.
      */
     @XmlAttribute
-    private String codeSpace;
+    @XmlSchemaType(name = "anyURI")
+    String codeSpace;
 
     /**
      * Sets the value from the given name.
      *
      * @param name The name to marshal.
      */
-    public void set(final GenericName name) {
-        this.name = name.toString();
+    public final void setName(final GenericName name) {
+        this.value = name.toString();
         final NameSpace scope = name.scope();
         if (scope != null && !scope.isGlobal()) {
             codeSpace = scope.name().toString();
@@ -69,7 +94,24 @@ public final class Name {
      *
      * @return The unmarshalled name.
      */
-    public GenericName get() {
-        return Names.parseGenericName(codeSpace, ":", name);
+    public GenericName getName() {
+        return Names.parseGenericName(codeSpace, ":", value);
+    }
+
+    /**
+     * The {@code CodeType} as a {@code gco:LocalName}.
+     */
+    @XmlRootElement(name = "LocalName", namespace = Namespaces.GCO)
+    public static final class LocalName extends CodeType {
+        @Override public GenericName getName() {
+            return Names.createLocalName(codeSpace, ":", value);
+        }
+    }
+
+    /**
+     * The {@code CodeType} as a {@code gco:ScopedName}.
+     */
+    @XmlRootElement(name = "ScopedName", namespace = Namespaces.GCO)
+    public static final class ScopedName extends CodeType {
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -20,7 +20,7 @@ import java.util.List;
 import java.util.Collections;
 import java.util.Locale;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.NameSpace;
 import org.opengis.util.LocalName;
@@ -68,7 +68,10 @@ import java.util.Objects;
  * since "CodeType" is used for various classes (including GenericName and ScopedName).
  * (Un)marhalling of this class needs to be handled by a JAXB adapter.
  */
-@XmlTransient
+@XmlSeeAlso({
+    DefaultTypeName.class,
+    DefaultMemberName.class
+})
 public class DefaultLocalName extends AbstractName implements LocalName {
     /**
      * Serial number for inter-operability with different versions.

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java?rev=1614706&r1=1614705&r2=1614706&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] Wed Jul 30 16:33:48 2014
@@ -24,6 +24,7 @@ import org.opengis.util.TypeName;
 import org.opengis.util.LocalName;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
+import org.opengis.util.NameSpace;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
@@ -42,7 +43,7 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.5
  * @module
  */
 @DependsOn(DefaultNameFactoryTest.class)
@@ -97,7 +98,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(actual));
+        assertEquals(name, unmarshall(expected));
     }
 
     /**
@@ -120,7 +121,31 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(actual));
+        assertEquals(name, unmarshall(expected));
+    }
+
+    /**
+     * Tests XML of a {@link LocalName} with a scope.
+     *
+     * @throws JAXBException Should not happen.
+     */
+    @Test
+    @DependsOnMethod("testLocalName")
+    public void testLocalNameWithScope() throws JAXBException {
+        final NameFactory factory = DefaultFactories.SIS_NAMES;
+        final NameSpace scope = factory.createNameSpace(factory.createLocalName(null, "A
code space"), null);
+        final LocalName name = factory.createLocalName(scope, "A name in a scope");
+        assertEquals("A name in a scope", name.toString());
+        final String expected =
+                "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
+                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                "  <gml:alias>\n" +
+                "    <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName>\n"
+
+                "  </gml:alias>\n" +
+                "</gml:IO_IdentifiedObject>\n";
+        final String actual = marshal(name);
+        assertXmlEquals(expected, actual, "xmlns:*");
+        assertEquals(name, unmarshall(expected));
     }
 
     /**
@@ -146,7 +171,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(actual));
+        assertEquals(name, unmarshall(expected));
     }
 
     /**
@@ -168,7 +193,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(actual));
+        assertEquals(name, unmarshall(expected));
     }
 
     /**



Mime
View raw message