sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1776249 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-referencing/src/test/java/org/apache/sis/referencing/report/ core/sis-utility/src/main/java/org/apache/sis/internal/simple/ core/sis-utility...
Date Wed, 28 Dec 2016 09:24:17 GMT
Author: desruisseaux
Date: Wed Dec 28 09:24:17 2016
New Revision: 1776249

URL: http://svn.apache.org/viewvc?rev=1776249&view=rev
Log:
First draft of a mapping from ISO 19115 metadata to GPX.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Link.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Store.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -93,7 +93,7 @@ public abstract class AbstractMetadata i
      * Implementation of this method shall not depend on the object state,
      * since this method may be indirectly invoked by copy constructors.
      *
-     * @return The metadata standard implemented.
+     * @return the metadata standard implemented.
      */
     public abstract MetadataStandard getStandard();
 
@@ -102,7 +102,7 @@ public abstract class AbstractMetadata i
      * interfaces defined in the {@linkplain #getStandard() metadata standard} implemented
      * by this class.
      *
-     * @return The standard interface implemented by this implementation class.
+     * @return the standard interface implemented by this implementation class.
      *
      * @see MetadataStandard#getInterface(Class)
      */
@@ -160,7 +160,7 @@ public abstract class AbstractMetadata i
      * {@linkplain ValueExistencePolicy#NON_NULL non null} properties, and sets to {@code
null}
      * the properties for which {@link #isEmpty()} returned {@code true}.
      *
-     * @throws UnmodifiableMetadataException If this metadata is not modifiable.
+     * @throws UnmodifiableMetadataException if this metadata is not modifiable.
      */
     public void prune() {
         // See comment in 'isEmpty()' about NULL_COLLECTION semaphore purpose.
@@ -207,7 +207,7 @@ public abstract class AbstractMetadata i
      *   return getStandard().asValueMap(this, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
      * }
      *
-     * @return A view of this metadata object as a map.
+     * @return a view of this metadata object as a map.
      *
      * @see MetadataStandard#asValueMap(Object, KeyNamePolicy, ValueExistencePolicy)
      */
@@ -275,7 +275,7 @@ public abstract class AbstractMetadata i
      *   return getStandard().asTreeTable(this, ValueExistencePolicy.NON_EMPTY);
      * }
      *
-     * @return A tree table representation of the specified metadata.
+     * @return a tree table representation of the specified metadata.
      *
      * @see MetadataStandard#asTreeTable(Object, ValueExistencePolicy)
      */
@@ -289,8 +289,8 @@ public abstract class AbstractMetadata i
      * for better performances, or for comparing "hidden" properties not specified
      * by the GeoAPI (or other standard) interface.
      *
-     * @param  object The object to compare with this metadata.
-     * @param  mode The strictness level of the comparison.
+     * @param  object  the object to compare with this metadata.
+     * @param  mode    the strictness level of the comparison.
      * @return {@code true} if the given object is equal to this metadata.
      */
     @Override
@@ -311,7 +311,7 @@ public abstract class AbstractMetadata i
      * If a subclass needs to override the behavior of this method, then
      * override {@link #equals(Object, ComparisonMode)} instead.
      *
-     * @param  object The object to compare with this metadata for equality.
+     * @param  object  the object to compare with this metadata for equality.
      * @return {@code true} if the given object is strictly equals to this metadata.
      */
     @Override

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -125,8 +125,8 @@ abstract strictfp class HTMLGenerator im
     /**
      * Escapes the {@code &}, {@code <} and {@code >} characters.
      *
-     * @param  text The text to escape, or {@code null}.
-     * @return The escaped text, or {@code null} if the given text was null.
+     * @param  text  the text to escape, or {@code null}.
+     * @return the escaped text, or {@code null} if the given text was null.
      */
     static CharSequence escape(CharSequence text) {
         text = CharSequences.replace(text, "&", "&amp;");
@@ -150,8 +150,8 @@ abstract strictfp class HTMLGenerator im
     /**
      * Opens a new HTML tag and increase the indentation.
      *
-     * @param  tag The HTML tag without brackets (e.g. {@code "h2"}).
-     * @return The value to give to {@link #closeTags(int)} for closing the tags.
+     * @param  tag  the HTML tag without brackets (e.g. {@code "h2"}).
+     * @return the value to give to {@link #closeTags(int)} for closing the tags.
      * @throws IOException if an error occurred while writing to the file.
      */
     final int openTag(final String tag) throws IOException {
@@ -169,7 +169,7 @@ abstract strictfp class HTMLGenerator im
     /**
      * Closes the last HTML tag if it is equals to the given element, and opens a new tag
on the same line.
      *
-     * @param  tag The HTML tag without brackets (e.g. {@code "h2"}).
+     * @param  tag  the HTML tag without brackets (e.g. {@code "h2"}).
      * @throws IOException if an error occurred while writing to the file.
      */
     final void reopenTag(final String tag) throws IOException {
@@ -190,7 +190,7 @@ abstract strictfp class HTMLGenerator im
     /**
      * Closes the HTML tag identified by the given number, together will all child tags.
      *
-     * @param  openedTag The value returned by the {@link #openTag(String)} matching the
tag to close.
+     * @param  openedTag  the value returned by the {@link #openTag(String)} matching the
tag to close.
      * @throws IOException if an error occurred while writing to the file.
      */
     final void closeTags(final int openedTag) throws IOException {
@@ -209,8 +209,8 @@ abstract strictfp class HTMLGenerator im
      * The {@code &}, {@code <} and {@code >} characters are <strong>not</strong>
escaped.
      * For escaping those characters, invoke <code>println(tag, {@linkplain #escape(CharSequence)
escape}(value))</code>.
      *
-     * @param  tag The HTML tag without brackets (e.g. {@code "h1"}).
-     * @param  value The text to write, or {@code null} for none.
+     * @param  tag    the HTML tag without brackets (e.g. {@code "h1"}).
+     * @param  value  the text to write, or {@code null} for none.
      * @throws IOException if an error occurred while writing to the file.
      */
     final void println(final String tag, final CharSequence value) throws IOException {
@@ -233,7 +233,7 @@ abstract strictfp class HTMLGenerator im
      * The {@code &}, {@code <} and {@code >} characters are <strong>not</strong>
escaped.
      * For escaping those characters, invoke <code>println({@linkplain #escape(CharSequence)
escape}(value))</code>.
      *
-     * @param  value The text to write, or {@code null} if none.
+     * @param  value  the text to write, or {@code null} if none.
      * @throws IOException if an error occurred while writing to the file.
      */
     final void println(final CharSequence value) throws IOException {
@@ -258,8 +258,8 @@ abstract strictfp class HTMLGenerator im
     /**
      * Returns the localized version of the given string, or {@code null} if none.
      *
-     * @param  text The text to localize, or {@code null}.
-     * @return The localized test, or {@code null}.
+     * @param  text  the text to localize, or {@code null}.
+     * @return the localized test, or {@code null}.
      *
      * @see #LOCALE
      */
@@ -270,7 +270,7 @@ abstract strictfp class HTMLGenerator im
     /**
      * Returns {@code true} if the given object is deprecated.
      *
-     * @param  object The object to test.
+     * @param  object  the object to test.
      * @return {@code true} if the given object is deprecated.
      */
     static boolean isDeprecated(final Object object) {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -114,7 +114,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Locale> getLanguages() {
-        return Collections.emptySet();
+        return Collections.emptySet();                  // We use 'Set' because we handle
'Locale' like a CodeList.
     }
 
     /**
@@ -132,7 +132,7 @@ public class SimpleMetadata implements M
     @Override
     @Deprecated
     public Collection<Locale> getLocales() {
-        return Collections.emptySet();
+        return Collections.emptySet();                  // We use 'Set' because we handle
'Locale' like a CodeList.
     }
 
     /**
@@ -141,7 +141,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Charset> getCharacterSets() {
-        return Collections.emptySet();
+        return Collections.emptySet();                  // We use 'Set' because we handle
'Charset' like a CodeList.
     }
 
     /**
@@ -226,7 +226,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Responsibility> getContacts() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -234,7 +234,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<CitationDate> getDateInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -271,7 +271,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Citation> getMetadataStandards() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -279,7 +279,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Citation> getMetadataProfiles() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -287,7 +287,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Citation> getAlternativeMetadataReferences() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -295,7 +295,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<OnlineResource> getMetadataLinkages() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -313,7 +313,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<SpatialRepresentation> getSpatialRepresentationInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -321,7 +321,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<ReferenceSystem> getReferenceSystemInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -329,7 +329,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<MetadataExtensionInformation> getMetadataExtensionInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -358,7 +358,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<ContentInformation> getContentInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -366,7 +366,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Distribution> getDistributionInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -374,7 +374,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<DataQuality> getDataQualityInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -382,7 +382,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<PortrayalCatalogueReference> getPortrayalCatalogueInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -390,7 +390,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Constraints> getMetadataConstraints() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -398,7 +398,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<ApplicationSchemaInformation> getApplicationSchemaInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -406,7 +406,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<AcquisitionInformation> getAcquisitionInformation() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -422,7 +422,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Lineage> getResourceLineages() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
 
@@ -464,7 +464,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<InternationalString> getCredits() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -473,7 +473,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Progress> getStatus() {
-        return Collections.emptySet();
+        return Collections.emptySet();              // We use 'Set' because 'Progress' is
a CodeList.
     }
 
     /**
@@ -482,7 +482,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Responsibility> getPointOfContacts() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -502,7 +502,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Resolution> getSpatialResolutions() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -511,7 +511,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Duration> getTemporalResolutions() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -531,7 +531,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Extent> getExtents() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -540,7 +540,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Citation> getAdditionalDocumentations() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -558,7 +558,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<MaintenanceInformation> getResourceMaintenances() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -567,7 +567,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<BrowseGraphic> getGraphicOverviews() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -576,7 +576,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Format> getResourceFormats() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -585,7 +585,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Keywords> getDescriptiveKeywords() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -595,7 +595,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Usage> getResourceSpecificUsages() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -604,7 +604,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Constraints> getResourceConstraints() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -613,7 +613,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<AssociatedResource> getAssociatedResources() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -622,7 +622,7 @@ public class SimpleMetadata implements M
     @Override
     @Deprecated
     public Collection<AggregateInformation> getAggregationInfo() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -664,7 +664,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<InternationalString> getAlternateTitles() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -673,7 +673,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<CitationDate> getDates() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -700,7 +700,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Identifier> getIdentifiers() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -710,7 +710,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<Responsibility> getCitedResponsibleParties() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -739,7 +739,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<InternationalString> getOtherCitationDetails() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -775,7 +775,7 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<OnlineResource> getOnlineResources() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 
     /**
@@ -784,6 +784,6 @@ public class SimpleMetadata implements M
      */
     @Override
     public Collection<BrowseGraphic> getGraphics() {
-        return Collections.emptySet();
+        return Collections.emptyList();
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
Wed Dec 28 09:24:17 2016
@@ -94,7 +94,7 @@ import org.apache.sis.internal.system.Lo
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class Types extends Static {
@@ -810,4 +810,18 @@ public final class Types extends Static
         }
         return copy;
     }
+
+    /**
+     * Returns the given international string in the given locale, or {@code null} if the
given string is null.
+     * If the given locale is {@code null}, then the {@code i18n} default locale is used.
+     *
+     * @param  i18n    the international string to get as a localized string, or {@code null}
if none.
+     * @param  locale  the desired locale, or {@code null} for the {@code i18n} default
locale.
+     * @return the localized string, or {@code null} if {@code i18n} is {@code null}.
+     *
+     * @since 0.8
+     */
+    public static String toString(final InternationalString i18n, final Locale locale) {
+        return (i18n == null) ? null : (locale == null) ? i18n.toString() : i18n.toString(locale);
+    }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -21,10 +21,10 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.Locale;
 import java.util.Objects;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
-import org.apache.sis.util.iso.SimpleInternationalString;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.CitationDate;
@@ -43,6 +43,8 @@ import org.opengis.metadata.extent.Exten
 import org.opengis.metadata.identification.BrowseGraphic;
 import org.opengis.metadata.maintenance.Scope;
 import org.opengis.util.InternationalString;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.iso.Types;
 
 
 /**
@@ -104,6 +106,43 @@ public final class Copyright implements
     }
 
     /**
+     * Copies properties from the given ISO 19115 metadata.
+     */
+    private Copyright(final LegalConstraints c, final Locale locale) {
+resp:   for (final Responsibility r : c.getResponsibleParties()) {
+            for (final Party p : r.getParties()) {
+                author = Types.toString(p.getName(), locale);
+                if (author != null) break resp;
+            }
+        }
+        for (final Citation ci : c.getReferences()) {
+            for (final CitationDate d : ci.getDates()) {
+                final Date date = d.getDate();
+                if (date != null) {
+                    year = date.getYear() + 1900;
+                    break;
+                }
+            }
+            for (final OnlineResource r : ci.getOnlineResources()) {
+                license = r.getLinkage();
+                if (license != null) break;
+            }
+        }
+    }
+
+    /**
+     * Returns the given ISO 19115 metadata as a {@code Copyright} instance.
+     * This method copies the data only if needed.
+     *
+     * @param  c       the ISO 19115 metadata, or {@code null}.
+     * @param  locale  the locale to use for localized strings.
+     * @return the GPX metadata, or {@code null}.
+     */
+    public static Copyright castOrCopy(final LegalConstraints c, final Locale locale) {
+        return (c == null || c instanceof Copyright) ? (Copyright) c : new Copyright(c, locale);
+    }
+
+    /**
      * ISO 19115 metadata property fixed to {@link Restriction#COPYRIGHT}.
      *
      * @return restrictions or limitations on obtaining the data.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Link.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Link.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Link.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Link.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -18,6 +18,7 @@ package org.apache.sis.internal.gpx;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Locale;
 import java.util.Objects;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -27,6 +28,7 @@ import org.opengis.metadata.citation.OnL
 import org.opengis.metadata.citation.OnlineResource;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.util.iso.Types;
 
 
 /**
@@ -128,6 +130,26 @@ public final class Link implements Onlin
     }
 
     /**
+     * Copies properties from the given ISO 19115 metadata.
+     */
+    private Link(final OnlineResource r, final Locale locale) {
+        uri  = r.getLinkage();
+        text = Types.toString(r.getName(), locale);
+    }
+
+    /**
+     * Returns the given ISO 19115 metadata as a {@code Link} instance.
+     * This method copies the data only if needed.
+     *
+     * @param  r       the ISO 19115 metadata, or {@code null}.
+     * @param  locale  the locale to use for localized strings.
+     * @return the GPX metadata, or {@code null}.
+     */
+    public static Link castOrCopy(final OnlineResource r, final Locale locale) {
+        return (r == null || r instanceof Link) ? (Link) r : new Link(r, locale);
+    }
+
+    /**
      * ISO 19115 metadata property determined by the {@link #uri} field.
      *
      * @return location for on-line access using a URL address or similar scheme.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -16,25 +16,29 @@
  */
 package org.apache.sis.internal.gpx;
 
-import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 import java.util.Objects;
 import java.io.IOException;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlElement;
 
+import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.CitationDate;
 import org.opengis.metadata.citation.DateType;
 import org.opengis.metadata.citation.OnlineResource;
 import org.opengis.metadata.citation.Responsibility;
 import org.opengis.metadata.constraint.Constraints;
+import org.opengis.metadata.constraint.LegalConstraints;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.identification.Keywords;
+import org.opengis.metadata.identification.Identification;
 import org.opengis.util.InternationalString;
+import org.apache.sis.util.iso.Types;
 
 import org.apache.sis.io.TableAppender;
 import org.apache.sis.internal.simple.SimpleMetadata;
@@ -112,19 +116,19 @@ public final class Metadata extends Simp
     public Copyright copyright;
 
     /**
-     * URLs associated with the location described in the file.
+     * URLs associated with the location described in the file, or {@code null} if none.
      *
      * @see #getOnlineResources()
      */
     @XmlElement(name = Tags.LINK)
-    public final List<Link> links = new ArrayList<>();
+    public List<Link> links;
 
     /**
      * The creation date of the file.
      *
      * @see #getDates()
      *
-     * @todo We could like to use {@link java.time}, but it does not yet word out-of-the-box
with JAXB
+     * @todo We would like to use {@link java.time}, but it does not yet work out-of-the-box
with JAXB
      *       (we need adapter). Furthermore current GeoAPI interfaces does not yet use {@code
java.time}.
      */
     @XmlElement(name = Tags.TIME)
@@ -156,6 +160,81 @@ public final class Metadata extends Simp
     }
 
     /**
+     * Copies properties from the given ISO 19115 metadata.
+     */
+    private Metadata(final org.opengis.metadata.Metadata md, final Locale locale) {
+        for (final Identification id : md.getIdentificationInfo()) {
+            final Citation c = id.getCitation();
+            if (c != null) {
+                if (name == null) {
+                    name = Types.toString(c.getTitle(), locale);
+                }
+                if (time == null) {
+                    for (final CitationDate d : c.getDates()) {
+                        time = d.getDate();
+                        if (time != null) break;
+                    }
+                }
+                for (final OnlineResource r : c.getOnlineResources()) {
+                    final Link link = Link.castOrCopy(r, locale);
+                    if (link != null) {
+                        if (links == null) {
+                            links = new ArrayList<>();
+                        }
+                        links.add(link);
+                    }
+                }
+            }
+            if (description == null) {
+                description = Types.toString(id.getAbstract(), locale);
+            }
+            for (final Responsibility r : id.getPointOfContacts()) {
+                final Person p = Person.castOrCopy(r, locale);
+                if (p != null) {
+                    if (p.isCreator) {
+                        if (creator == null) {
+                            creator = p.name;
+                        }
+                    } else if (author == null) {
+                        author = p;
+                    }
+                }
+            }
+            if (copyright == null) {
+                for (final Constraints cr : id.getResourceConstraints()) {
+                    if (cr instanceof LegalConstraints) {
+                        copyright = Copyright.castOrCopy((LegalConstraints) cr, locale);
+                        if (copyright != null) break;
+                    }
+                }
+            }
+            for (final Keywords k : id.getDescriptiveKeywords()) {
+                for (final InternationalString kw : k.getKeywords()) {
+                    final String s = Types.toString(kw, locale);
+                    if (s != null) {
+                        if (keywords == null) {
+                            keywords = new ArrayList<>();
+                        }
+                        keywords.add(s);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns the given ISO 19115 metadata as a {@code Metadata} instance.
+     * This method copies the data only if needed.
+     *
+     * @param  md      the ISO 19115 metadata, or {@code null}.
+     * @param  locale  the locale to use for localized strings.
+     * @return the GPX metadata, or {@code null}.
+     */
+    public static Metadata castOrCopy(final org.opengis.metadata.Metadata md, final Locale
locale) {
+        return (md == null || md instanceof Metadata) ? (Metadata) md : new Metadata(md,
locale);
+    }
+
+    /**
      * ISO 19115 metadata property determined by the {@link #name} field.
      * This is part of the information returned by {@link #getCitation()}.
      *
@@ -186,24 +265,12 @@ public final class Metadata extends Simp
     @Override
     public Collection<Keywords> getDescriptiveKeywords() {
         if (keywords != null) {
-            return new KW(keywords);
+            return Collections.singleton(new DefaultKeywords(keywords.toArray(new String[keywords.size()])));
         }
         return super.getDescriptiveKeywords();
     }
 
     /**
-     * The list to be returned by {@link #getDescriptiveKeywords()}.
-     * Each keywords is created when first needed.
-     */
-    private static final class KW extends AbstractList<Keywords> {
-        private final List<String> keywords;
-
-        KW(final List<String> keywords)      {this.keywords = keywords;}
-        @Override public int      size()     {return keywords.size();}
-        @Override public Keywords get(int i) {return new DefaultKeywords(keywords.get(i));}
-    }
-
-    /**
      * ISO 19115 metadata property determined by the {@link #author} field.
      * This is part of the information returned by {@link #getIdentificationInfo()}.
      *
@@ -263,7 +330,7 @@ public final class Metadata extends Simp
      */
     @Override
     public Collection<OnlineResource> getOnlineResources() {
-        return Collections.unmodifiableList(links);
+        return (links != null) ? Collections.unmodifiableList(links) : super.getOnlineResources();
     }
 
     /**
@@ -279,7 +346,8 @@ public final class Metadata extends Simp
         }
         if (obj instanceof Metadata) {
             final Metadata that = (Metadata) obj;
-            return Objects.equals(this.name,        that.name)        &&
+            return Objects.equals(this.creator,     that.creator)     &&
+                   Objects.equals(this.name,        that.name)        &&
                    Objects.equals(this.description, that.description) &&
                    Objects.equals(this.author,      that.author)      &&
                    Objects.equals(this.copyright,   that.copyright)   &&
@@ -298,7 +366,7 @@ public final class Metadata extends Simp
      */
     @Override
     public int hashCode() {
-        return Objects.hash(name, description, author, copyright, links, time, keywords,
bounds);
+        return Objects.hash(creator, name, description, author, copyright, links, time, keywords,
bounds);
     }
 
     /**
@@ -313,6 +381,7 @@ public final class Metadata extends Simp
         final TableAppender table = new TableAppender(buffer);
         table.setMultiLinesCells(true);
         table.appendHorizontalSeparator();
+        append(table, "Creator",     creator);
         append(table, "Name",        name);
         append(table, "Description", description);
         append(table, "Author",      author);

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -18,10 +18,10 @@ package org.apache.sis.internal.gpx;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Locale;
 import java.util.Objects;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.sis.util.iso.SimpleInternationalString;
 import org.opengis.metadata.citation.Address;
 import org.opengis.metadata.citation.Contact;
 import org.opengis.metadata.citation.OnlineResource;
@@ -31,6 +31,8 @@ import org.opengis.metadata.citation.Rol
 import org.opengis.metadata.citation.Telephone;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.util.InternationalString;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.iso.Types;
 
 
 /**
@@ -69,7 +71,7 @@ public final class Person implements Res
     /**
      * {@code true} if this name is the creator, {@code false} if it is the author.
      */
-    private boolean isCreator;
+    boolean isCreator;
 
     /**
      * Email address.
@@ -103,6 +105,34 @@ public final class Person implements Res
     }
 
     /**
+     * Returns the given ISO 19115 metadata as a {@code Person} instance.
+     * This method copies the data only if needed.
+     *
+     * @param  r       the ISO 19115 metadata, or {@code null}.
+     * @param  locale  the locale to use for localized strings.
+     * @return the GPX metadata, or {@code null}.
+     */
+    public static Person castOrCopy(final Responsibility r, final Locale locale) {
+        if (r == null || r instanceof Person) {
+            return (Person) r;
+        }
+        final Role role = r.getRole();
+        final boolean isCreator = Role.ORIGINATOR.equals(role);
+        if (isCreator || Role.AUTHOR.equals(role)) {
+            for (final Party p : r.getParties()) {
+                final String name = Types.toString(p.getName(), locale);
+                if (name != null) {
+                    final Person pr = new Person();
+                    pr.name = name;
+                    pr.isCreator = isCreator;
+                    return pr;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * ISO 19115 metadata property fixed to {@link Role#ORIGINATOR} or {@link Role#AUTHOR}.
      *
      * @return function performed by the responsible party.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -283,7 +283,11 @@ parse:  while (reader.hasNext()) {
      * This is a convenience method for GPX 1.0 metadata parsing.
      */
     private Link link() {
-        final List<Link> links = metadata().links;
+        final Metadata metadata = metadata();
+        List<Link> links = metadata.links;
+        if (links == null) {
+            metadata.links = links = new ArrayList<>();
+        }
         final Link first;
         if (links.isEmpty()) {
             first = new Link();

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Store.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Store.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -180,8 +180,7 @@ public final class Store extends StaxDat
     public synchronized void write(final Metadata metadata, final Stream<? extends Feature>
features)
             throws DataStoreException
     {
-        // TODO: convert the metadata if needed.
-        try (final Writer writer = new Writer(this, (org.apache.sis.internal.gpx.Metadata)
metadata)) {
+        try (final Writer writer = new Writer(this, org.apache.sis.internal.gpx.Metadata.castOrCopy(metadata,
locale))) {
             writer.writeStartDocument();
             if (features != null) {
                 features.forEachOrdered(writer);

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -62,6 +62,28 @@ public abstract class StaxDataStore exte
     protected final String name;
 
     /**
+     * The locale to use for locale-sensitive data (<strong>not</strong> for
logging or warning messages),
+     * or {@code null} if unspecified.
+     *
+     * @see OptionKey#LOCALE
+     */
+    protected final Locale locale;
+
+    /**
+     * The timezone to use when parsing or formatting dates and times without explicit timezone,
+     * or {@code null} if unspecified.
+     *
+     * @see OptionKey#TIMEZONE
+     */
+    protected final TimeZone timezone;
+
+    /**
+     * The character encoding of the file content, or {@code null} if unspecified.
+     * This is often (but not always) ignored at reading time, but taken in account at writing
time.
+     */
+    protected final Charset encoding;
+
+    /**
      * Configuration information for JAXB (un)marshaller (actually the SIS wrappers) or for
the STAX factories.
      * This object is a read-only map which may contain the following entries:
      *
@@ -79,12 +101,6 @@ public abstract class StaxDataStore exte
     final Config configuration;
 
     /**
-     * The character encoding of the file content, or {@code null} if unspecified.
-     * This is often (but not always) ignored at reading time, but taken in account at writing
time.
-     */
-    final Charset encoding;
-
-    /**
      * The storage object given by the user. May be {@link Path}, {@link java.net.URL}, {@link
InputStream},
      * {@link java.io.OutputStream}, {@link java.io.Reader}, {@link java.io.Writer}, {@link
XMLStreamReader},
      * {@link XMLStreamWriter}, {@link org.w3c.dom.Node} or some other types that the STAX
framework can handle.
@@ -161,8 +177,10 @@ public abstract class StaxDataStore exte
         super(provider, connector);
         name            = connector.getStorageName();
         storage         = connector.getStorage();
+        locale          = connector.getOption(OptionKey.LOCALE);
+        timezone        = connector.getOption(OptionKey.TIMEZONE);
         encoding        = connector.getOption(OptionKey.ENCODING);
-        configuration   = new Config(connector);
+        configuration   = new Config();
         storageToWriter = OutputType.forType(storage.getClass());
         storageToReader = InputType.forType(storage.getClass());
         if (storageToReader == null) {
@@ -207,27 +225,9 @@ public abstract class StaxDataStore exte
      */
     private final class Config extends AbstractMap<String,Object> implements XMLReporter,
WarningListener<Object> {
         /**
-         * The locale to use for locale-sensitive data (<strong>not</strong>
for logging or warning messages),
-         * or {@code null} if unspecified.
-         *
-         * @see OptionKey#LOCALE
-         */
-        private final Locale locale;
-
-        /**
-         * The timezone to use when parsing or formatting dates and times without explicit
timezone,
-         * or {@code null} if unspecified.
-         *
-         * @see OptionKey#TIMEZONE
-         */
-        private final TimeZone timezone;
-
-        /**
          * Fetches configuration information from the given object.
          */
-        Config(final StorageConnector connector) {
-            locale   = connector.getOption(OptionKey.LOCALE);
-            timezone = connector.getOption(OptionKey.TIMEZONE);
+        Config() {
         }
 
         /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -190,7 +190,7 @@ public final strictfp class ReaderTest e
         assertBoundsEquals(-20, 30, 10, 40, md.bounds);
         assertNull("author",                md.author);
         assertNull("copyright",             md.copyright);
-        assertTrue("links.isEmpty()",       md.links.isEmpty());
+        assertNull("links",                 md.links);
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java?rev=1776249&r1=1776248&r2=1776249&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
[UTF-8] Wed Dec 28 09:24:17 2016
@@ -158,9 +158,9 @@ public final strictfp class WriterTest e
         metadata.keywords    = Arrays.asList("sample", "metadata");
         metadata.bounds      = bounds;
         metadata.time        = date("2010-03-01 00:00:00");
-        metadata.links.add(new Link(new URI("http://first-address.org")));
-        metadata.links.add(new Link(new URI("http://second-address.org")));
-        metadata.links.add(new Link(new URI("http://third-address.org")));
+        metadata.links       = Arrays.asList(new Link(new URI("http://first-address.org")),
+                                             new Link(new URI("http://second-address.org")),
+                                             new Link(new URI("http://third-address.org")));
         metadata.links.get(2).type = "website";
         metadata.links.get(0).text = "first";
 



Mime
View raw message