sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1614508 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/ ...
Date Tue, 29 Jul 2014 23:03:48 GMT
Author: desruisseaux
Date: Tue Jul 29 23:03:47 2014
New Revision: 1614508

URL: http://svn.apache.org/r1614508
Log:
Added tests and fixed XML (un)marshallig bugs accordingly.

Added:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
      - copied, changed from r1614193, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java   (with props)
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java   (with props)
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java   (with props)
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java

Copied: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java (from r1614193, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.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?p2=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java&r1=1614193&r2=1614508&rev=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.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] Tue Jul 29 23:03:47 2014
@@ -16,28 +16,53 @@
  */
 package org.apache.sis.internal.jaxb.metadata.direct;
 
-import org.apache.sis.util.iso.DefaultMemberName;
-import org.opengis.util.MemberName;
+import org.opengis.util.GenericName;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.opengis.util.ScopedName;
 
 
 /**
  * JAXB adapter mapping implementing class to the GeoAPI interface. See
  * package documentation for more information about JAXB and interface.
  *
- * @author  Guilhem Legal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
  * @version 0.5
  * @module
+ *
+ * @see org.apache.sis.internal.jaxb.gco.GO_GenericName
  */
-public final class GO_MemberName extends MetadataAdapter<MemberName, DefaultMemberName> {
+public final class GO_ScopedName extends XmlAdapter<Name, ScopedName> {
     /**
      * Converts a GeoAPI interface to the SIS implementation for XML marshalling.
      *
-     * @param  value The bound type value, here the GeoAPI interface.
+     * @param  name The bound type value, here the GeoAPI interface.
      * @return The adapter for the given value, here the SIS implementation.
      */
     @Override
-    public DefaultMemberName marshal(MemberName value) {
-        return DefaultMemberName.castOrCopy(value);
+    public Name marshal(final ScopedName name) {
+        if (name != null) {
+            final Name wrapper = new Name();
+            wrapper.set(name);
+            return wrapper;
+        }
+        return null;
+    }
+
+    /**
+     * Returns the scope name from the given string.
+     *
+     * @param  wrapper 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();
+            if (parsed instanceof ScopedName) {
+                return (ScopedName) parsed;
+            }
+        }
+        return null;
     }
 }

Added: 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-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java?rev=1614508&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java (added)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -0,0 +1,75 @@
+/*
+ * 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.metadata.direct;
+
+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.XmlRootElement;
+import org.apache.sis.xml.Namespaces;
+import org.apache.sis.util.iso.Names;
+
+
+/**
+ * A name to be marshalled instead than the {@link org.apache.sis.util.iso} object.
+ *
+ * @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 {
+    /**
+     * The scoped name.
+     */
+    @XmlValue
+    private String name;
+
+    /**
+     * The code space, or {@code null} if none.
+     */
+    @XmlAttribute
+    private 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();
+        final NameSpace scope = name.scope();
+        if (scope != null && !scope.isGlobal()) {
+            codeSpace = scope.name().toString();
+        }
+    }
+
+    /**
+     * Returns the name from the current value.
+     *
+     * @return The unmarshalled name.
+     */
+    public GenericName get() {
+        return Names.parseGenericName(codeSpace, ":", name);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -46,7 +46,16 @@
  *
  * @author  Guilhem Legal (Geomatys)
  * @since   0.3 (derived from geotk-3.15)
- * @version 0.3
+ * @version 0.5
  * @module
  */
+@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMD, xmlns = {
+    @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
+    @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO)
+})
 package org.apache.sis.internal.jaxb.metadata.direct;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema;
+import org.apache.sis.xml.Namespaces;

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -19,13 +19,19 @@ package org.apache.sis.metadata.iso.serv
 import java.util.Collection;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.ScopedName;
+import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.identification.DataIdentification;
 import org.opengis.metadata.service.CoupledResource;
 import org.opengis.metadata.service.OperationMetadata;
 import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.jaxb.metadata.direct.GO_ScopedName;
+
+import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
 
 
 /**
@@ -38,10 +44,12 @@ import org.apache.sis.metadata.iso.ISOMe
  * @module
  */
 @XmlType(name = "SV_CoupledResource_Type", propOrder = {
-    "scopedName",
+    "operationName",
+    "identifier",
+    "scopedName" /*,
     "resourceReferences",
     "resources",
-    "operation"
+    "operation" */
 })
 @XmlRootElement(name = "SV_CoupledResource")
 public class DefaultCoupledResource extends ISOMetadata implements CoupledResource {
@@ -145,7 +153,8 @@ public class DefaultCoupledResource exte
      * @return identifier of the resource, or {@code null} if none.
      */
     @Override
-    @XmlElement(name = "scopedName")
+    @XmlElementRef
+    @XmlJavaTypeAdapter(GO_ScopedName.class)
     public ScopedName getScopedName() {
         return scopedName;
     }
@@ -166,7 +175,7 @@ public class DefaultCoupledResource exte
      * @return References to the resource on which the services operates.
      */
     @Override
-    @XmlElement(name = "resourceReference")
+/// @XmlElement(name = "resourceReference")
     public Collection<Citation> getResourceReferences() {
         return resourceReferences = nonNullCollection(resourceReferences, Citation.class);
     }
@@ -186,7 +195,7 @@ public class DefaultCoupledResource exte
      * @return tightly coupled resources.
      */
     @Override
-    @XmlElement(name = "resource")
+/// @XmlElement(name = "resource")
     public Collection<DataIdentification> getResources() {
         return resources = nonNullCollection(resources, DataIdentification.class);
     }
@@ -206,7 +215,7 @@ public class DefaultCoupledResource exte
      * @return The service operation, or {@code null} if none.
      */
     @Override
-    @XmlElement(name = "operation")
+/// @XmlElement(name = "operation")
     public OperationMetadata getOperation() {
         return operation;
     }
@@ -220,4 +229,47 @@ public class DefaultCoupledResource exte
         checkWritePermission();
         this.operation = newValue;
     }
+
+
+
+    // Bridges for elements from legacy ISO 19119
+
+    /**
+     * For JAXB marhalling of ISO 19119 document only.
+     */
+    @XmlElement(name = "operationName")
+    final InternationalString getOperationName() {
+        if (LEGACY_XML) {
+            final OperationMetadata operation = getOperation();
+            if (operation != null) {
+                return operation.getOperationName();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * For JAXB unmarhalling of ISO 19119 document only. Sets {@link #operation} to a temporary
+     * {@link OperationName} placeholder. That temporary instance will be replaced by the real
+     * one when the enclosing {@link DefaultServiceIdentification} is unmarshalled.
+     */
+    final void setOperationName(final InternationalString name) {
+        if (operation == null) {
+            operation = new OperationName(name);
+        }
+    }
+
+    /**
+     * Returns the resource identifier, which is assumed to be the name as a string.
+     */
+    @XmlElement(name = "identifier")
+    final String getIdentifier() {
+        if (LEGACY_XML) {
+            final ScopedName name = getScopedName();
+            if (name != null) {
+                return name.tip().toString();
+            }
+        }
+        return null;
+    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -24,6 +24,7 @@ import org.opengis.metadata.service.Oper
 import org.opengis.metadata.service.OperationMetadata;
 import org.opengis.util.InternationalString;
 import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.util.iso.Types;
 
 
 /**
@@ -74,10 +75,10 @@ public class DefaultOperationChainMetada
      * @param name      The name as used by the service for this chain.
      * @param operation Information about the operations applied by the chain.
      */
-    public DefaultOperationChainMetadata(final InternationalString name,
+    public DefaultOperationChainMetadata(final CharSequence name,
                                          final OperationMetadata operation)
     {
-        this.name       = name;
+        this.name       = Types.toInternationalString(name);
         this.operations = singleton(operation, OperationMetadata.class);
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.metadata.iso.service;
 
-import java.util.Set;
 import java.util.List;
 import java.util.Collection;
 import javax.xml.bind.annotation.XmlType;
@@ -84,7 +83,7 @@ public class DefaultOperationMetadata ex
     /**
      * The parameters that are required for this interface.
      */
-    private Set<Parameter> parameters;
+    private Collection<Parameter> parameters;
 
     /**
      * List of operation that must be completed immediately.
@@ -271,8 +270,8 @@ public class DefaultOperationMetadata ex
      */
     @Override
     @XmlElement(name = "parameters")
-    public Set<Parameter> getParameters() {
-        return parameters = nonNullSet(parameters, Parameter.class);
+    public Collection<Parameter> getParameters() {
+        return parameters = nonNullCollection(parameters, Parameter.class);
     }
 
     /**
@@ -280,8 +279,8 @@ public class DefaultOperationMetadata ex
      *
      * @param newValues The new set of parameters that are required for this interface.
      */
-    public void setParameters(final Set<? extends Parameter> newValues) {
-        parameters = writeSet(newValues, parameters, Parameter.class);
+    public void setParameters(final Collection<? extends Parameter> newValues) {
+        parameters = writeCollection(newValues, parameters, Parameter.class);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -27,7 +27,6 @@ import org.opengis.metadata.service.Para
 import org.opengis.metadata.service.ParameterDirection;
 import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName;
-import org.apache.sis.util.iso.Types;
 
 import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
 
@@ -47,7 +46,7 @@ import static org.apache.sis.internal.ja
     "name",
     "direction",
     "description",
-    "optionality",
+    "optionalityLabel",
     "repeatability",
     "valueType"
 })
@@ -76,12 +75,12 @@ public class DefaultParameter extends IS
     /**
      * Indication if the parameter is required.
      */
-    private InternationalString optionality;
+    private Boolean optionality;
 
     /**
      * Indication if more than one value of the parameter may be provided.
      */
-    private boolean repeatability;
+    private Boolean repeatability;
 
     /**
      * Constructs an initially empty parameter.
@@ -97,11 +96,11 @@ public class DefaultParameter extends IS
      * @param repeatability Indication if more than one value of the parameter may be provided.
      */
     public DefaultParameter(final MemberName name,
-                            final CharSequence optionality,
+                            final boolean optionality,
                             final boolean repeatability)
     {
         this.name          = name;
-        this.optionality   = Types.toInternationalString(optionality);
+        this.optionality   = optionality;
         this.repeatability = repeatability;
     }
 
@@ -220,8 +219,8 @@ public class DefaultParameter extends IS
      * @return Whether the parameter is required.
      */
     @Override
-    @XmlElement(name = "optionality", required = true)
-    public InternationalString getOptionality() {
+/// @XmlElement(name = "optionality", required = true)
+    public Boolean getOptionality() {
         return optionality;
     }
 
@@ -230,7 +229,7 @@ public class DefaultParameter extends IS
      *
      * @param newValue Whether the parameter is required.
      */
-    public void setOptionality(final InternationalString newValue) {
+    public void setOptionality(final Boolean newValue) {
         checkWritePermission();
         this.optionality = newValue;
     }
@@ -242,7 +241,7 @@ public class DefaultParameter extends IS
      */
     @Override
     @XmlElement(name = "repeatability", required = true)
-    public boolean getRepeatability() {
+    public Boolean getRepeatability() {
         return repeatability;
     }
 
@@ -251,7 +250,7 @@ public class DefaultParameter extends IS
      *
      * @param newValue Whether more than one value of the parameter may be provided.
      */
-    public void setRepeatability(final boolean newValue) {
+    public void setRepeatability(final Boolean newValue) {
         checkWritePermission();
         this.repeatability = newValue;
     }
@@ -261,6 +260,21 @@ public class DefaultParameter extends IS
     // Bridges for elements from legacy ISO 19119
 
     /**
+     * Returns the optionality as a "Optional" or "Mandatory" string.
+     */
+    @XmlElement(name = "optionality", required = true)
+    final String getOptionalityLabel() {
+        return (optionality == null) ? null : (optionality) ? "Optional" : "Mandatory";
+    }
+
+    /**
+     * Sets optionality to {@code true} if the given string is equals, ignoring case, to {@code "Optional"}.
+     */
+    final void setOptionalityLabel(final String label) {
+        optionality = (label == null) ? null : label.equalsIgnoreCase("Optional");
+    }
+
+    /**
      * For JAXB marhalling of ISO 19119 document only.
      * Note that there is not setter method, since we expect the same information
      * to be provided in the {@link #name} attribute type.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -17,8 +17,9 @@
 package org.apache.sis.metadata.iso.service;
 
 import java.util.Collection;
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.util.GenericName;
 import org.opengis.metadata.citation.Citation;
@@ -47,15 +48,15 @@ import org.apache.sis.metadata.iso.ident
 @XmlType(name = "MD_ServiceIdentification_Type", propOrder = { // ISO 19139 still use the old prefix.
     "serviceType",
     "serviceTypeVersions",
-    "accessProperties",
-    "couplingType",
+/// "accessProperties",
     "coupledResources",
-    "operatedDatasets",
-    "profiles",
-    "serviceStandards",
+    "couplingType",
+/// "operatedDatasets",
+/// "profiles",
+/// "serviceStandards",
     "containsOperations",
     "operatesOn",
-    "containsChain"
+/// "containsChain"
 })
 @XmlRootElement(name = "SV_ServiceIdentification")
 public class DefaultServiceIdentification extends AbstractIdentification implements ServiceIdentification {
@@ -240,7 +241,7 @@ public class DefaultServiceIdentificatio
      * @return Information about the availability of the service, or {@code null} if none.
      */
     @Override
-    @XmlElement(name = "accessProperties")
+/// @XmlElement(name = "accessProperties")
     public StandardOrderProcess getAccessProperties() {
         return accessProperties;
 
@@ -303,7 +304,7 @@ public class DefaultServiceIdentificatio
      * @return Reference(s) to the resource on which the service operates.
      */
     @Override
-    @XmlElement(name = "operatedDataset")
+/// @XmlElement(name = "operatedDataset")
     public Collection<Citation> getOperatedDatasets() {
         return operatedDatasets = nonNullCollection(operatedDatasets, Citation.class);
     }
@@ -323,7 +324,7 @@ public class DefaultServiceIdentificatio
      * @return Profile(s) to which the service adheres.
      */
     @Override
-    @XmlElement(name = "profile")
+/// @XmlElement(name = "profile")
     public Collection<Citation> getProfiles() {
         return profiles = nonNullCollection(profiles, Citation.class);
     }
@@ -343,7 +344,7 @@ public class DefaultServiceIdentificatio
      * @return Standard(s) to which the service adheres.
      */
     @Override
-    @XmlElement(name = "serviceStandard")
+/// @XmlElement(name = "serviceStandard")
     public Collection<Citation> getServiceStandards() {
         return serviceStandards = nonNullCollection(serviceStandards, Citation.class);
     }
@@ -403,7 +404,7 @@ public class DefaultServiceIdentificatio
      * @return Information about the chain applied by the service.
      */
     @Override
-    @XmlElement(name = "containsChain")
+/// @XmlElement(name = "containsChain")
     public Collection<OperationChainMetadata> getContainsChain() {
         return containsChain = nonNullCollection(containsChain, OperationChainMetadata.class);
     }
@@ -416,4 +417,13 @@ public class DefaultServiceIdentificatio
     public void setContainsChain(final Collection<? extends OperationChainMetadata>  newValues) {
         containsChain = writeCollection(newValues, containsChain, OperationChainMetadata.class);
     }
+
+    /**
+     * Invoked after JAXB has unmarshalled this object.
+     */
+    private void afterUnmarshal(final Unmarshaller u, final Object parent) {
+        if (containsOperations != null && coupledResources != null) {
+            OperationName.resolve(containsOperations, coupledResources);
+        }
+    }
 }

Added: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java?rev=1614508&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java (added)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -0,0 +1,126 @@
+/*
+ * 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.metadata.iso.service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+import java.io.Serializable;
+import org.opengis.metadata.citation.OnlineResource;
+import org.opengis.metadata.service.CoupledResource;
+import org.opengis.metadata.service.DistributedComputingPlatform;
+import org.opengis.metadata.service.OperationMetadata;
+import org.opengis.metadata.service.Parameter;
+import org.opengis.util.InternationalString;
+
+
+/**
+ * An {@code OperationMetadata} placeholder to be replaced later by a reference to an other {@link OperationMetadata}.
+ * This temporary place holder is used when the operation name is unmarshalled before the actual operation definition.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.5
+ * @since   0.5
+ * @module
+ */
+final class OperationName implements OperationMetadata, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -7958898214063034276L;
+
+    /**
+     * The operation name.
+     */
+    private final InternationalString operationName;
+
+    /**
+     * Creates a new placeholder for the operation of the given name.
+     */
+    OperationName(final InternationalString operationName) {
+        this.operationName = operationName;
+    }
+
+    /**
+     * Returns the operation name.
+     */
+    @Override public InternationalString                      getOperationName()                 {return operationName;}
+    @Override public InternationalString                      getInvocationName()                {return null;}
+    @Override public InternationalString                      getOperationDescription()          {return null;}
+    @Override public Collection<DistributedComputingPlatform> getDistributedComputingPlatforms() {return Collections.emptySet();}
+    @Override public Collection<OnlineResource>               getConnectPoints()                 {return Collections.emptySet();}
+    @Override public Collection<Parameter>                    getParameters()                    {return Collections.emptySet();}
+    @Override public List<OperationMetadata>                  getDependsOn()                     {return Collections.emptyList();}
+
+    /**
+     * Returns a string representation of this placeholder.
+     */
+    @Override
+    public String toString() {
+        return "OperationMetadata[“" + operationName + "”]";
+    }
+
+    /**
+     * For every instance of {@link DefaultCoupledResource} associated to an operation of kind {@code OperationName},
+     * replaces the operation by a "real" {@link DefaultOperationMetadata} of the same name, if any.
+     *
+     * <p>This method updates the elements in the {@code coupledResources} collection in-place.
+     * The other collection is unmodified.</p>
+     *
+     * <p>This method is invoked at unmarshalling time for resolving the {@code OperationMetadata} instance which
+     * were identified only by a name in a {@code <srv:operationName>} element.</p>
+     */
+    static void resolve(final Collection<OperationMetadata> containsOperations, final Collection<CoupledResource> coupledResources) {
+        final Map<String,OperationMetadata> byName = new HashMap<>();
+        for (final OperationMetadata operation : containsOperations) {
+            final InternationalString name = operation.getOperationName();
+            add(byName, name.toString(Locale.ROOT), operation);
+            add(byName, name.toString(/*default*/), operation);
+        }
+        for (final CoupledResource resource : coupledResources) {
+            if (resource instanceof DefaultCoupledResource) {
+                OperationMetadata operation = resource.getOperation();
+                if (operation instanceof OperationName) {
+                    final InternationalString name = operation.getOperationName();
+                    operation = byName.get(name.toString(Locale.ROOT));
+                    if (operation == null) {
+                        operation = byName.get(name.toString());
+                        if (operation == null) {
+                            continue;
+                        }
+                    }
+                    ((DefaultCoupledResource) resource).setOperation(operation);
+                }
+            }
+        }
+    }
+
+    /**
+     * Adds the given operation in the given map under the given name. If an entry already exists for the given name,
+     * then this method sets the value to {@code null} for meaning that we have duplicated values for that name.
+     */
+    private static void add(final Map<String,OperationMetadata> byName, final String name, final OperationMetadata operation) {
+        final boolean exists = byName.containsKey(name);
+        final OperationMetadata previous = byName.put(name, operation);
+        if (previous != operation && (previous != null || exists)) {
+            byName.put(name, null); // Mark the entry as duplicated.
+        }
+    }
+}

Propchange: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java?rev=1614508&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java (added)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -0,0 +1,82 @@
+/*
+ * 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.metadata.iso.service;
+
+import org.opengis.util.ScopedName;
+import org.opengis.metadata.citation.OnlineResource;
+import org.opengis.metadata.service.DistributedComputingPlatform;
+import org.opengis.metadata.service.OperationMetadata;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.xml.NilReason;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static java.util.Collections.singleton;
+import static org.apache.sis.internal.system.DefaultFactories.SIS_NAMES;
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link DefaultCoupledResource}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+@DependsOn(DefaultParameterTest.class)
+public final strictfp class DefaultCoupledResourceTest extends TestCase {
+    /**
+     * Creates the resource to use for testing purpose.
+     */
+    static DefaultCoupledResource create() {
+        final DefaultOperationMetadata operation = new DefaultOperationMetadata("Get Map",
+                DistributedComputingPlatform.WEB_SERVICES, null);
+        operation.setParameters(singleton(DefaultParameterTest.create()));
+        operation.setConnectPoints(singleton(NilReason.MISSING.createNilObject(OnlineResource.class)));
+
+        final DefaultCoupledResource resource = new DefaultCoupledResource();
+        resource.setScopedName((ScopedName) SIS_NAMES.createGenericName(null, "mySpace", "ABC-123"));
+        resource.setOperation(operation);
+        return resource;
+    }
+
+    /**
+     * Tests {@link OperationName#resolve(Collection, Collection)}.
+     */
+    @Test
+    public void testOperationNameResolve() {
+        final DefaultCoupledResource resource  = DefaultCoupledResourceTest.create();
+        final OperationMetadata      operation = resource.getOperation();
+        /*
+         * Test OperationName replacement when the name matches.
+         */
+        resource.setOperation(new OperationName(operation.getOperationName()));
+        assertNotSame("Before resolve", operation, resource.getOperation());
+        OperationName.resolve(singleton(operation), singleton(resource));
+        assertSame("After resolve", operation, resource.getOperation());
+        /*
+         * If the name doesn't match, no replacement shall be done.
+         */
+        final OperationName other = new OperationName(new SimpleInternationalString("Other"));
+        resource.setOperation(other);
+        assertSame("Before resolve", other, resource.getOperation());
+        OperationName.resolve(singleton(operation), singleton(resource));
+        assertSame("After resolve", other, resource.getOperation());
+    }
+}

Propchange: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -17,10 +17,14 @@
 package org.apache.sis.metadata.iso.service;
 
 import javax.xml.bind.JAXBException;
+import org.opengis.util.TypeName;
+import org.opengis.util.MemberName;
+import org.opengis.metadata.service.ParameterDirection;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.xml.Namespaces;
 import org.junit.Test;
 
+import static org.apache.sis.internal.system.DefaultFactories.SIS_NAMES;
 import static org.apache.sis.test.Assert.*;
 
 
@@ -34,6 +38,39 @@ import static org.apache.sis.test.Assert
  */
 public final strictfp class DefaultParameterTest extends XMLTestCase {
     /**
+     * Creates the parameter to use for testing purpose.
+     */
+    static DefaultParameter create() {
+        final TypeName   valueType = SIS_NAMES.createTypeName(null, "CharacterString");
+        final MemberName paramName = SIS_NAMES.createMemberName(null, "Version", valueType);
+        final DefaultParameter param = new DefaultParameter(paramName, true, false);
+        assertSame("valueType", valueType, param.getValueType());
+        param.setDirection(ParameterDirection.IN);
+        return param;
+    }
+
+    /**
+     * Tests {@link DefaultParameter#getOptionalityLabel()} and {@link DefaultParameter#setOptionalityLabel(String)}.
+     */
+    @Test
+    public void testOptionalityLabel() {
+        final DefaultParameter param = create();
+        assertEquals("Optional", param.getOptionalityLabel());
+
+        param.setOptionality(false);
+        assertEquals("Mandatory", param.getOptionalityLabel());
+
+        param.setOptionality(null);
+        assertNull(param.getOptionalityLabel());
+
+        param.setOptionalityLabel("Optional");
+        assertTrue(param.getOptionality());
+
+        param.setOptionalityLabel("Mandatory");
+        assertFalse(param.getOptionality());
+    }
+
+    /**
      * Tests marshalling of an empty parameter. The main purpose is to ensure that
      * the XML does not contains spurious elements like empty enumeration wrapper.
      *
@@ -42,13 +79,6 @@ public final strictfp class DefaultParam
     @Test
     public void testMarshalEmpty() throws JAXBException {
         final String xml = marshal(new DefaultParameter());
-        assertXmlEquals(
-                "<srv:SV_Parameter xmlns:srv=\"" + Namespaces.SRV + '"' +
-                                 " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
-                "  <srv:repeatability>\n" +
-                "    <gco:Boolean>false</gco:Boolean>\n" +
-                "  </srv:repeatability>\n" +
-                "</srv:SV_Parameter>\n",
-                xml, "xlmns:*");
+        assertXmlEquals("<srv:SV_Parameter xmlns:srv=\"" + Namespaces.SRV + "\"/>", xml, "xlmns:*");
     }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -17,13 +17,8 @@
 package org.apache.sis.metadata.iso.service;
 
 import javax.xml.bind.JAXBException;
-import org.opengis.util.TypeName;
-import org.opengis.util.MemberName;
 import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.citation.OnlineResource;
 import org.opengis.metadata.service.CouplingType;
-import org.opengis.metadata.service.DistributedComputingPlatform;
-import org.opengis.metadata.service.ParameterDirection;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.XMLTestCase;
@@ -43,8 +38,9 @@ import static org.apache.sis.internal.sy
  * @module
  */
 @DependsOn({
-    org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class,
-    DefaultParameterTest.class
+    DefaultParameterTest.class,
+    DefaultCoupledResourceTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class
 })
 public final strictfp class DefaultServiceIdentificationTest extends XMLTestCase {
     /**
@@ -56,24 +52,15 @@ public final strictfp class DefaultServi
      * Creates the service identification to use for testing purpose.
      */
     private static DefaultServiceIdentification create() {
-        final TypeName   valueType = SIS_NAMES.createTypeName(null, "CharacterString");
-        final MemberName paramName = SIS_NAMES.createMemberName(null, "Version", valueType);
-        final DefaultParameter param = new DefaultParameter(paramName, "Optional", false);
-        assertSame("valueType", valueType, param.getValueType());
-        param.setDirection(ParameterDirection.IN);
-
-        final DefaultOperationMetadata md = new DefaultOperationMetadata("Get Map",
-                DistributedComputingPlatform.WEB_SERVICES, null);
-        md.setParameters(singleton(param));
-        md.setConnectPoints(singleton(NilReason.MISSING.createNilObject(OnlineResource.class)));
-
+        final DefaultCoupledResource resource = DefaultCoupledResourceTest.create();
         final DefaultServiceIdentification id = new DefaultServiceIdentification(
                 SIS_NAMES.createGenericName(null, "Web Map Server"),    // serviceType
                 NilReason.MISSING.createNilObject(Citation.class),      // citation
                 "A dummy service for testing purpose.");                // abstract
         id.setServiceTypeVersions(singleton("1.0"));
+        id.setCoupledResources(singleton(resource));
         id.setCouplingType(CouplingType.LOOSE);
-        id.setContainsOperations(singleton(md));
+        id.setContainsOperations(singleton(resource.getOperation()));
         return id;
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -74,6 +74,7 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
     org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class,
     org.apache.sis.metadata.iso.service.DefaultParameterTest.class,
+    org.apache.sis.metadata.iso.service.DefaultCoupledResourceTest.class,
     org.apache.sis.metadata.iso.service.DefaultServiceIdentificationTest.class,
     org.apache.sis.metadata.iso.quality.AbstractElementTest.class,
     org.apache.sis.metadata.iso.quality.AbstractPositionalAccuracyTest.class,

Modified: sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml Tue Jul 29 23:03:47 2014
@@ -33,12 +33,27 @@
   <srv:serviceType>
     <gco:LocalName>Web Map Server</gco:LocalName>
   </srv:serviceType>
+
   <srv:serviceTypeVersion>
     <gco:CharacterString>1.0</gco:CharacterString>
   </srv:serviceTypeVersion>
+
+  <srv:coupledResource>
+    <srv:SV_CoupledResource>
+      <srv:operationName>
+        <gco:CharacterString>Get Map</gco:CharacterString>
+      </srv:operationName>
+      <srv:identifier>
+        <gco:CharacterString>ABC-123</gco:CharacterString>
+      </srv:identifier>
+      <gco:ScopedName>mySpace:ABC-123</gco:ScopedName>
+    </srv:SV_CoupledResource>
+  </srv:coupledResource>
+
   <srv:couplingType>
     <srv:SV_CouplingType codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#SV_CouplingType" codeListValue="loose">Loose</srv:SV_CouplingType>
   </srv:couplingType>
+
   <srv:containsOperations>
     <srv:SV_OperationMetadata>
       <srv:operationName>

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -19,8 +19,6 @@ package org.apache.sis.util.iso;
 import java.util.List;
 import java.util.Iterator;
 import java.util.ConcurrentModificationException;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
 import org.opengis.util.NameSpace;
 import org.opengis.util.LocalName;
 import org.opengis.util.ScopedName;
@@ -56,8 +54,7 @@ import org.apache.sis.internal.util.Unmo
  * @see DefaultNameSpace
  * @see DefaultLocalName
  */
-@XmlType(name = "ScopedName") // Actually 'gml:CodeType', but the later is used elsewhere.
-@XmlRootElement(name = "ScopedName")
+// No JAXB annotation, because we can't use @XmlValue in this class.
 public class DefaultScopedName extends AbstractName implements ScopedName {
     /**
      * Serial number for inter-operability with different versions.
@@ -90,14 +87,6 @@ public class DefaultScopedName extends A
     }
 
     /**
-     * Empty constructor to be used by JAXB only. Despite its "final" declaration,
-     * the {@link #parsedNames} field will be set by JAXB during unmarshalling.
-     */
-    private DefaultScopedName() {
-        parsedNames = null;
-    }
-
-    /**
      * Creates a new scoped names from the given list of local names. This constructor is
      * not public because it does not check if the given local names have the proper scope.
      *

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java?rev=1614508&r1=1614507&r2=1614508&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] Tue Jul 29 23:03:47 2014
@@ -94,7 +94,7 @@ public final class Names extends Static 
      * @return The namespace object.
      */
     private static NameSpace createNameSpace(final CharSequence namespace, final String separator) {
-        if (namespace == null) {
+        if (namespace == null || namespace.length() == 0) {
             return null;
         }
         return DefaultFactories.NAMES.createNameSpace(
@@ -103,6 +103,23 @@ public final class Names extends Static 
     }
 
     /**
+     * Creates a local or scoped name in the given namespace.
+     * The character sequences can be either {@link String} or {@link InternationalString} instances.
+     * The {@code namespace} character sequences is taken verbatim, while {@code scopedName} is parsed
+     * as described in {@linkplain DefaultNameFactory#createGenericName(NameSpace, CharSequence...) name factory}.
+     *
+     * @param  namespace  The namespace, or {@code null} for the global namespace.
+     * @param  separator  The separator between the namespace and the scoped name.
+     * @param  scopedName The name to parse.
+     * @return A local or scoped name in the given namespace.
+     */
+    public static GenericName parseGenericName(final CharSequence namespace, final String separator, final CharSequence scopedName) {
+        ensureNonNull("localPart", scopedName);
+        ensureNonNull("separator", separator);
+        return DefaultFactories.NAMES.parseGenericName(createNameSpace(namespace, separator), scopedName);
+    }
+
+    /**
      * Creates a name which is local in the given namespace.
      * The character sequences can be either {@link String} or {@link InternationalString} instances.
      * Those character sequences are taken verbatim; they are <em>not</em> parsed into their components.



Mime
View raw message