Author: desruisseaux
Date: Wed Aug  9 16:40:59 2017
New Revision: 1804579

URL: http://svn.apache.org/viewvc?rev=1804579&view=rev
Log:
Port a small part of Cullen Rombach's work on ISO 19115-3 upgrade. The main 
port will happen in the ISO-19115-3 branch, we we port here a small part which 
is only indirectly related to the upgrade and do not have immediate impact on 
XML namespaces.

Modified:
    
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
    
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
    
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
    
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java

Modified: 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java?rev=1804579&r1=1804578&r2=1804579&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
 [UTF-8] Wed Aug  9 16:40:59 2017
@@ -21,6 +21,7 @@ import java.util.Locale;
 import java.util.Objects;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.util.InternationalString;
 import org.apache.sis.xml.XLink;
 
@@ -36,11 +37,13 @@ import org.apache.sis.xml.XLink;
  *
  * @author  Guilhem Legal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @author  Cullen Rombach (Image Matters)
+ * @version 0.8
  * @since   0.3
  * @module
  */
 @XmlType(name = "Anchor_Type")
+@XmlRootElement(name = "Anchor")
 public final class Anchor extends XLink implements InternationalString {
     /**
      * Defined as a matter of principle (this class is not expected to be 
serialized).

Modified: 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1804579&r1=1804578&r2=1804579&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
 [UTF-8] Wed Aug  9 16:40:59 2017
@@ -46,7 +46,8 @@ import static org.apache.sis.util.collec
  * }
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.4
+ * @author  Cullen Rombach (Image Matters)
+ * @version 0.8
  * @since   0.3
  * @module
  */
@@ -275,11 +276,11 @@ filter: for (final Locale locale : local
             return unique(new Locale.Builder().setLanguageTag(code).build());
         }
         /*
-         * Old syntax (e.g. "en_US"). Split in (language, country, variant) 
components,
+         * Old syntax (e.g. "en_US" or "eng; USA"). Split in (language, 
country, variant) components,
          * then convert the 3-letters codes to the 2-letters ones.
          */
         String language, country = "", variant = "";
-        if (p1 < 0) {
+        if (p1 < 0 && (p1 = code.indexOf(';', fromIndex)) < 0) {
             p1 = code.length();
         } else {
             final int s = p1 + 1;

Modified: 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java?rev=1804579&r1=1804578&r2=1804579&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
 [UTF-8] Wed Aug  9 16:40:59 2017
@@ -53,7 +53,8 @@ import org.apache.sis.internal.util.Abst
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 0.8
  *
  * @see DefaultRecordType
  * @see DefaultRecordSchema
@@ -96,6 +97,59 @@ public class DefaultRecord implements Re
     }
 
     /**
+     * Creates a new record initialized to a shallow copy of the given record.
+     * The members contained in the given record are <strong>not</strong> 
recursively copied.
+     *
+     * @param  record  the record to copy (can not be null).
+     *
+     * @since 0.8
+     */
+    public DefaultRecord(final Record record) {
+        this(record.getRecordType());
+        for (final Map.Entry<MemberName,Integer> entry : 
definition.memberIndices().entrySet()) {
+            final MemberName name = entry.getKey();
+            final Object value = record.locate(name);
+            if (value != null) {
+                final int index = entry.getValue();
+                final Class<?> valueClass = definition.getValueClass(index);
+                if (valueClass != null && !valueClass.isInstance(value)) {
+                    throw new 
ClassCastException(Errors.format(Errors.Keys.IllegalPropertyValueClass_3,
+                            name, valueClass, value.getClass()));
+                }
+                Array.set(values, index, value);
+            }
+        }
+    }
+
+    /**
+     * Returns a SIS implementation with the name and members of the given 
arbitrary implementation.
+     * This method performs the first applicable action in the following 
choices:
+     *
+     * <ul>
+     *   <li>If the given object is {@code null}, then this method returns 
{@code null}.</li>
+     *   <li>Otherwise if the given object is already an instance of {@code 
DefaultRecord},
+     *       then it is returned unchanged.</li>
+     *   <li>Otherwise a new {@code DefaultRecord} instance is created using 
the
+     *       {@linkplain #DefaultRecord(Record) copy constructor} and returned.
+     *       Note that this is a shallow copy operation, since the members 
contained
+     *       in the given object are not recursively copied.</li>
+     * </ul>
+     *
+     * @param  other The object to get as a SIS implementation, or {@code 
null} if none.
+     * @return A SIS implementation containing the members of the given object
+     *         (may be the given object itself), or {@code null} if the 
argument was {@code null}.
+     *
+     * @since 0.8
+     */
+    public static DefaultRecord castOrCopy(final Record other) {
+        if (other == null || other instanceof DefaultRecord) {
+            return (DefaultRecord) other;
+        } else {
+            return new DefaultRecord(other);
+        }
+    }
+
+    /**
      * Returns the type definition of this record.
      *
      * @return the type definition of this record.

Modified: 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java?rev=1804579&r1=1804578&r2=1804579&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
 [UTF-8] Wed Aug  9 16:40:59 2017
@@ -446,6 +446,7 @@ public class DefaultRecordType extends R
     /**
      * Empty constructor only used by JAXB.
      */
+    @SuppressWarnings("unused")
     private DefaultRecordType() {
         typeName  = null;
         container = null;


Reply via email to