sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1547398 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
Date Tue, 03 Dec 2013 14:21:37 GMT
Author: desruisseaux
Date: Tue Dec  3 14:21:37 2013
New Revision: 1547398

URL: http://svn.apache.org/r1547398
Log:
Patch by Guilhem L├ęgal needed for allowing two different GML versions to co-exist.
We do not yet know if this patch is temporary or if we will be able to find a solution for
avoiding code duplication.

Added:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java?rev=1547398&r1=1547397&r2=1547398&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
[UTF-8] Tue Dec  3 14:21:37 2013
@@ -20,6 +20,7 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.annotation.XmlElementDecl;
 import javax.xml.bind.annotation.XmlRegistry;
 import javax.xml.namespace.QName;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.util.Workaround;
 
@@ -31,7 +32,7 @@ import org.apache.sis.util.Workaround;
  *
  * @author  Guilhem Legal (Geomatys)
  * @since   0.3 (derived from geotk-3.15)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @XmlRegistry
@@ -39,17 +40,20 @@ public class ObjectFactory {
     /**
      * The qualified name of {@code <AbstractGeometry>}.
      */
-    protected static final QName AbstractGeometry_QNAME = new QName(Namespaces.GML, "AbstractGeometry");
+    protected static final QName AbstractGeometry_QNAME   = new QName(Namespaces.GML, "AbstractGeometry"),
+                                 AbstractGeometry31_QNAME = new QName(LegacyNamespaces.GML,
"AbstractGeometry");
 
     /**
      * The qualified name of {@code <AbstractGML>}.
      */
-    protected static final QName AbstractGML_QNAME = new QName(Namespaces.GML, "AbstractGML");
+    protected static final QName AbstractGML_QNAME   = new QName(Namespaces.GML, "AbstractGML"),
+                                 AbstractGML31_QNAME = new QName(LegacyNamespaces.GML, "AbstractGML");
 
     /**
      * The qualified name of {@code <AbstractObject>}.
      */
-    protected static final QName AbstractObject_QNAME = new QName(Namespaces.GML, "AbstractObject");
+    protected static final QName AbstractObject_QNAME   = new QName(Namespaces.GML, "AbstractObject"),
+                                 AbstractObject31_QNAME = new QName(LegacyNamespaces.GML,
"AbstractObject");
 
     /**
      * Creates an instance of {@code JAXBElement<Object>}}.
@@ -57,12 +61,23 @@ public class ObjectFactory {
      * @param  value The {@code Object} value to wrap.
      * @return The wrapped value.
      */
-    @XmlElementDecl(name = "AbstractObject")
+    @XmlElementDecl(name = "AbstractObject", namespace = Namespaces.GML)
     public JAXBElement<Object> createObject(final Object value) {
         return new JAXBElement<>(AbstractObject_QNAME, Object.class, null, value);
     }
 
     /**
+     * A {@link #createObject(Object)} version for the legacy GML namespace.
+     *
+     * @param  value The {@code Object} value to wrap.
+     * @return The wrapped value in the legacy namespace.
+     */
+    @XmlElementDecl(name = "AbstractObject", namespace = LegacyNamespaces.GML)
+    public JAXBElement<Object> createObject31(final Object value) {
+        return new JAXBElement<>(AbstractObject31_QNAME, Object.class, null, value);
+    }
+
+    /**
      * Create an instance of {@code JAXBElement<AbstractGMLType>}}.
      * The type declared in the method signature should be {@code AbstractGMLType}.
      * However it is declared here as {@code Object} in order to avoid a dependency
@@ -73,6 +88,7 @@ public class ObjectFactory {
      */
     @Workaround(library = "JAXB", version = "2.1")
     @XmlElementDecl(name = "AbstractGML",
+            namespace = Namespaces.GML,
             substitutionHeadName = "AbstractObject",
             substitutionHeadNamespace = Namespaces.GML) // Not necessary according javadoc,
but appears to be in practice (JAXB 2.1 bug?)
     public JAXBElement<Object> createAbstractGML(final Object value) {
@@ -80,6 +96,21 @@ public class ObjectFactory {
     }
 
     /**
+     * A {@link #createAbstractGML(Object)} version for the legacy GML namespace.
+     *
+     * @param  value The GML {@code AbstractGMLType} value to wrap.
+     * @return The wrapped value in the legacy namespace.
+     */
+    @Workaround(library = "JAXB", version = "2.1")
+    @XmlElementDecl(name = "AbstractGML",
+            namespace = LegacyNamespaces.GML,
+            substitutionHeadName = "AbstractObject",
+            substitutionHeadNamespace = LegacyNamespaces.GML) // Not necessary according
javadoc, but appears to be in practice (JAXB 2.1 bug?)
+    public JAXBElement<Object> createAbstractGML31(final Object value) {
+        return new JAXBElement<>(AbstractGML31_QNAME, Object.class, null, value);
+    }
+
+    /**
      * Create an instance of {@code JAXBElement<AbstractGeometryType>}}.
      * The type declared in the method signature should be {@code AbstractGeometryType}.
      * However it is declared here as {@code Object} in order to avoid a dependency
@@ -90,9 +121,25 @@ public class ObjectFactory {
      */
     @Workaround(library = "JAXB", version = "2.1")
     @XmlElementDecl(name = "AbstractGeometry",
+            namespace = Namespaces.GML,
             substitutionHeadName = "AbstractGML",
             substitutionHeadNamespace = Namespaces.GML) // Not necessary according javadoc,
but appears to be in practice (JAXB 2.1 bug?)
     public JAXBElement<Object> createAbstractGeometry(final Object value) {
         return new JAXBElement<>(AbstractGeometry_QNAME, Object.class, null, value);
     }
+
+    /**
+     * A {@link #createAbstractGeometry(Object)} version for the legacy GML namespace.
+     *
+     * @param  value The {@code AbstractGeometryType} value to wrap.
+     * @return The wrapped value in the legacy namespace.
+     */
+    @Workaround(library = "JAXB", version = "2.1")
+    @XmlElementDecl(name = "AbstractGeometry",
+            namespace = LegacyNamespaces.GML,
+            substitutionHeadName = "AbstractGML",
+            substitutionHeadNamespace = LegacyNamespaces.GML) // Not necessary according
javadoc, but appears to be in practice (JAXB 2.1 bug?)
+    public JAXBElement<Object> createAbstractGeometry31(final Object value) {
+        return new JAXBElement<>(AbstractGeometry31_QNAME, Object.class, null, value);
+    }
 }

Added: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java?rev=1547398&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
(added)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
[UTF-8] Tue Dec  3 14:21:37 2013
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+
+/**
+ * Legacy XML namespaces.
+ * This class is hopefully temporary, if we can find a way to share the same Java classes
between different versions.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class LegacyNamespaces {
+    /**
+     * The {@value} URL, which was used for all GML versions before 3.2.
+     */
+    public static final String GML = "http://www.opengis.net/gml";
+
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private LegacyNamespaces() {
+    }
+}

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

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8



Mime
View raw message