sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1514388 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/ sis...
Date Thu, 15 Aug 2013 17:27:48 GMT
Author: desruisseaux
Date: Thu Aug 15 17:27:47 2013
New Revision: 1514388

URL: http://svn.apache.org/r1514388
Log:
Add support for <gmx:MimeFileType> (completion of SIS-119).

Added:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java
      - copied, changed from r1514070, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java
      - copied, changed from r1514070, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -20,9 +20,11 @@ import java.net.URI;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.identification.BrowseGraphic;
 import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.jaxb.gmx.MimeFileTypeAdapter;
 
 
 /**
@@ -32,7 +34,7 @@ import org.apache.sis.metadata.iso.ISOMe
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @XmlType(name = "MD_BrowseGraphic_Type", propOrder = {
@@ -171,6 +173,7 @@ public class DefaultBrowseGraphic extend
      */
     @Override
     @XmlElement(name = "fileType")
+    @XmlJavaTypeAdapter(MimeFileTypeAdapter.class)
     public String getFileType() {
         return fileType;
     }

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -63,6 +63,8 @@ public strictfp class LoggingWatcher ext
      * for the log messages before the tests are run. This installation will cause the
      * {@link #isLoggable(LogRecord)} method to be invoked when a message is logged.
      *
+     * @param description A description of the JUnit test which is starting.
+     *
      * @see #isLoggable(LogRecord)
      */
     @Override
@@ -75,6 +77,8 @@ public strictfp class LoggingWatcher ext
     /**
      * Invoked when a test method finishes (whether passing or failing)
      * This method removes the filter which had been set for testing purpose.
+     *
+     * @param description A description of the JUnit test that finished.
      */
     @Override
     protected final void finished(final Description description) {

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -17,12 +17,22 @@
 package org.apache.sis.metadata.iso.identification;
 
 import java.net.URI;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.logging.LogRecord;
 import javax.xml.bind.JAXBException;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+import org.apache.sis.util.logging.WarningListener;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.XML;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
+import static java.util.Collections.singletonMap;
 
 
 /**
@@ -33,11 +43,33 @@ import static org.apache.sis.test.Assert
  * @version 0.4
  * @module
  */
-public final class DefaultBrowseGraphicTest extends TestCase {
+public final strictfp class DefaultBrowseGraphicTest extends TestCase {
+    /**
+     * Tests XML marshalling of {@code <gmx:MimeFileType>} inside {@code <gmd:MD_BrowseGraphic>}.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    public void testMimeFileType() throws JAXBException {
+        final DefaultBrowseGraphic browse = new DefaultBrowseGraphic();
+        browse.setFileType("image/tiff");
+        final String xml = XML.marshal(browse);
+        assertXmlEquals(
+                "<gmd:MD_BrowseGraphic>\n" +
+                "  <gmd:fileType>\n" +
+                "    <gmx:MimeFileType type=\"image/tiff\">image/tiff</gmx:MimeFileType>\n"
+
+                "  </gmd:fileType>\n" +
+                "</gmd:MD_BrowseGraphic>", xml, "xmlns:*");
+        /*
+         * Unmarshal the element back to a Java object and compare to the original.
+         */
+        assertEquals(browse, XML.unmarshal(xml));
+    }
+
     /**
      * Tests XML marshalling of {@code <gmx:FileName>} inside {@code <gmd:MD_BrowseGraphic>}.
      *
-     * @throws JAXBException Should never happen.
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
      */
     @Test
     public void testFileName() throws JAXBException {
@@ -55,4 +87,186 @@ public final class DefaultBrowseGraphicT
          */
         assertEquals(browse, XML.unmarshal(xml));
     }
+
+    /**
+     * Tests unmarshalling of {@code <gmx:FileName>} without {@code src} attribute.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    @DependsOnMethod("testFileName")
+    public void testFileNameWithoutSrc() throws JAXBException {
+        final DefaultBrowseGraphic browse = (DefaultBrowseGraphic) XML.unmarshal(
+                "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                                     " xmlns:gmx=\"" + Namespaces.GMX + "\">\n" +
+                "  <gmd:fileName>\n" +
+                "    <gmx:FileName>file:/catalog/image.png</gmx:FileName>\n"
+
+                "  </gmd:fileName>\n" +
+                "</gmd:MD_BrowseGraphic>");
+
+        assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName());
+    }
+
+    /**
+     * Tests XML marshalling of {@code <gmx:FileName>} and {@code <gmx:MimeFileType>}
together.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    @DependsOnMethod({"testFileName", "testMimeFileType"})
+    public void testFileNameAndType() throws JAXBException {
+        final URI uri = URI.create("file:/catalog/image.png");
+        final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(uri);
+        browse.setFileType("image/tiff");
+        final String xml = XML.marshal(browse);
+        assertXmlEquals(
+                "<gmd:MD_BrowseGraphic>\n" +
+                "  <gmd:fileName>\n" +
+                "    <gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>\n"
+
+                "  </gmd:fileName>\n" +
+                "  <gmd:fileType>\n" +
+                "    <gmx:MimeFileType type=\"image/tiff\">image/tiff</gmx:MimeFileType>\n"
+
+                "  </gmd:fileType>\n" +
+                "</gmd:MD_BrowseGraphic>", xml, "xmlns:*");
+        /*
+         * Unmarshal the element back to a Java object and compare to the original.
+         */
+        assertEquals(browse, XML.unmarshal(xml));
+    }
+
+    /**
+     * Tests XML marshalling of filename substituted by {@code <gco:CharacterString>}
+     * inside {@code <gmd:MD_BrowseGraphic>}.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    @DependsOnMethod("testFileNameAndType")
+    public void testStringSubstitution() throws JAXBException {
+        final URI uri = URI.create("file:/catalog/image.png");
+        final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(uri);
+        browse.setFileType("image/tiff");
+        final StringWriter buffer = new StringWriter();
+        XML.marshal(browse, new StreamResult(buffer),
+                singletonMap(XML.STRING_SUBSTITUTES, new String[] {"filename", "mimetype"}));
+        final String xml = buffer.toString();
+        assertXmlEquals(
+                "<gmd:MD_BrowseGraphic>\n" +
+                "  <gmd:fileName>\n" +
+                "    <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n"
+
+                "  </gmd:fileName>\n" +
+                "  <gmd:fileType>\n" +
+                "    <gco:CharacterString>image/tiff</gco:CharacterString>\n"
+
+                "  </gmd:fileType>\n" +
+                "</gmd:MD_BrowseGraphic>", xml, "xmlns:*");
+        /*
+         * Unmarshal the element back to a Java object and compare to the original.
+         */
+        assertEquals(browse, XML.unmarshal(xml));
+    }
+
+    /**
+     * Tests the unmarshaller with the same URI in both {@code <gco:CharacterString>}
and {@code <gmx:FileName>}.
+     * Since the URI is the same, the unmarshaller should not produce any warning since there
is no ambiguity.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    @DependsOnMethod("testStringSubstitution")
+    public void testDuplicatedValues() throws JAXBException {
+        final Warning listener = new Warning();
+        final DefaultBrowseGraphic browse = listener.unmarshal(
+                "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                                     " xmlns:gmx=\"" + Namespaces.GMX + '"' +
+                                     " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                "  <gmd:fileName>\n" +
+                "    <gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>\n"
+
+                "    <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n"
+
+                "  </gmd:fileName>\n" +
+                "</gmd:MD_BrowseGraphic>");
+
+        assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName());
+        assertFalse("Expected no warning.", listener.receivedWarning);
+    }
+
+    /**
+     * Ensures that the unmarshaller produces a warning when {@code <gco:CharacterString>}
and
+     * {@code <gmx:FileName>} both exist inside the same {@code <gmd:MD_BrowseGraphic>}.
+     *
+     * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
+     */
+    @Test
+    @DependsOnMethod("testStringSubstitution")
+    public void testWarnings() throws JAXBException {
+        testWarnings("<gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>",
+                     "<gco:CharacterString>file:/catalog/image2.png</gco:CharacterString>");
+        /*
+         * Test again with the same element value, but in reverse order.
+         * We do that for ensuring that FileName still has precedence.
+         */
+        testWarnings("<gco:CharacterString>file:/catalog/image2.png</gco:CharacterString>",
+                     "<gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>");
+    }
+
+    /**
+     * Implementation of {@link #testWarnings()} using the given {@code <gmd:fileName>}
values.
+     */
+    private void testWarnings(final String first, final String second) throws JAXBException
{
+        final Warning listener = new Warning();
+        final DefaultBrowseGraphic browse = listener.unmarshal(
+                "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                                     " xmlns:gmx=\"" + Namespaces.GMX + '"' +
+                                     " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                "  <gmd:fileName>\n" +
+                "    " + first + "\n" +
+                "    " + second + "\n" +
+                "  </gmd:fileName>\n" +
+                "</gmd:MD_BrowseGraphic>");
+
+        assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName());
+        assertTrue("Expected a warning.", listener.receivedWarning);
+    }
+
+    /**
+     * A warning listener to be registered by {@link #testWarnings()}.
+     */
+    private static final class Warning implements WarningListener<Object> {
+        /**
+         * {@code true} if a warning has been sent by the XML unmarshaller.
+         */
+        boolean receivedWarning;
+
+        /**
+         * Fixed to {@code Object.class} as required by {@link XML#WARNING_LISTENER} contract.
+         */
+        @Override
+        public Class<Object> getSourceClass() {
+            return Object.class;
+        }
+
+        /**
+         * Invoked when a warning occurred. Ensures that no warning were previously sent,
+         * then ensure that the warning content the expected message.
+         */
+        @Override
+        public void warningOccured(final Object source, final LogRecord warning) {
+            assertFalse("No other warning were expected.", receivedWarning);
+            if (verbose) {
+                // In verbose mode, log the warning for allowing the developer to
+                // check the message. In normal mode, the test will be silent.
+                Logging.getLogger(warning.getLoggerName()).log(warning);
+            }
+            assertArrayEquals("FileName shall have precedence over CharacterString.",
+                    new Object[] {"CharacterString", "FileName"}, warning.getParameters());
+            receivedWarning = true;
+        }
+
+        /**
+         * Unmarshals the given object while listening to warnings.
+         */
+        public DefaultBrowseGraphic unmarshal(final String xml) throws JAXBException {
+            return (DefaultBrowseGraphic) XML.unmarshal(new StreamSource(new StringReader(xml)),
+                    singletonMap(XML.WARNING_LISTENER, this));
+        }
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.jaxb.gco;
 
 import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
@@ -24,6 +25,7 @@ import org.apache.sis.xml.Namespaces;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.gmx.Anchor;
 import org.apache.sis.internal.jaxb.gmx.FileName;
+import org.apache.sis.internal.jaxb.gmx.MimeFileType;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Messages;
 
@@ -136,9 +138,12 @@ public class GO_CharacterString {
                 noset     = true;
             }
             final Context context = Context.current();
-            Context.warningOccured(context, value,
-                    Messages.getResources(context != null ? context.getLocale() : null).getLogRecord(Level.WARNING,
-                    Messages.Keys.DiscardedExclusiveProperty_2, NAMES[discarded], NAMES[property]));
+            final LogRecord record = Messages.getResources(context != null ? context.getLocale()
: null)
+                    .getLogRecord(Level.WARNING, Messages.Keys.DiscardedExclusiveProperty_2,
+                                  NAMES[discarded], NAMES[property]);
+            record.setSourceClassName(getClass().getCanonicalName());
+            record.setSourceMethodName("setText");
+            Context.warningOccured(context, value, record);
             if (noset) {
                 return;
             }
@@ -176,7 +181,7 @@ public class GO_CharacterString {
     }
 
     /**
-     * Returns the text in a {@code <gco:FileName>} element, or {@code null} if none.
+     * Returns the text in a {@code <gmx:FileName>} element, or {@code null} if none.
      */
     @XmlElement(name = "FileName", namespace = Namespaces.GMX)
     final FileName getFileName() {
@@ -202,6 +207,32 @@ public class GO_CharacterString {
     }
 
     /**
+     * Returns the text in a {@code <gmx:MimeFileType>} element, or {@code null} if
none.
+     */
+    @XmlElement(name = "MimeFileType", namespace = Namespaces.GMX)
+    final MimeFileType getMimeFileType() {
+        if (type == MIME_TYPE) {
+            final CharSequence text = this.text;
+            if (text != null && !(text instanceof Anchor)) {
+                return new MimeFileType(text.toString());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Invoked by JAXB for setting the MIME type.
+     */
+    final void setMimeFileType(final MimeFileType type) {
+        if (type != null) {
+            final String value = CharSequences.trimWhitespaces(type.toString());
+            if (value != null && !value.isEmpty()) {
+                setText(value, MIME_TYPE);
+            }
+        }
+    }
+
+    /**
      * Returns the text associated with a reference.
      * This method is called by JAXB at marshalling time.
      *

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -34,11 +34,11 @@ import org.apache.sis.internal.jaxb.Cont
  * @version 0.3
  * @module
  */
-public final class StringAdapter extends XmlAdapter<GO_CharacterString, String> {
+public class StringAdapter extends XmlAdapter<GO_CharacterString, String> {
     /**
-     * Empty constructor for JAXB.
+     * Empty constructor for JAXB or subclasses.
      */
-    private StringAdapter() {
+    public StringAdapter() {
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -43,7 +43,7 @@ public final class URIAdapter extends Xm
      * JAXB calls automatically this method at unmarshalling time.
      *
      * @param  value The wrapper for the URI value, or {@code null}.
-     * @return An {@link URI} which represents the URI value, or {@code null}.
+     * @return A {@link URI} which represents the URI value, or {@code null}.
      * @throws URISyntaxException If the string is not a valid URI.
      */
     @Override

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -50,7 +50,7 @@ public final class FileName {
     private String src;
 
     /**
-     * A human-readable description of the filename. If {@link #src} if null,
+     * A human-readable description of the filename. If {@link #src} is null,
      * then this will be taken as the file path.
      */
     @XmlValue

Copied: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java
(from r1514070, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java?p2=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java&p1=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java&r1=1514070&r2=1514388&rev=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -23,14 +23,14 @@ import javax.xml.bind.annotation.XmlRoot
 
 
 /**
- * The {@code <gmx:FileName>} element, which may be used as a substitute of {@code
<gco:CharacterString>}.
- * This is used for the URI in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic}.
+ * The {@code <gmx:MimeFileType>} element, which may be used as a substitute of {@code
<gco:CharacterString>}.
+ * This is used in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic}.
  * Example:
  *
  * {@preformat xml
- *   <fileName>
- *      <gmx:FileName src="../path/wkj98723.jpg">Overview</gmx:FileName>
- *   </fileName>
+ *   <fileType>
+ *     <gmx:MimeFileType type="image/tiff">Graphic TIFF</gmx:MimeFileType>
+ *   </fileType>
  * }
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -40,18 +40,18 @@ import javax.xml.bind.annotation.XmlRoot
  *
  * @see <a href="https://issues.apache.org/jira/browse/SIS-119">SIS-119</a>
  */
-@XmlType(name = "FileName_PropertyType")
-@XmlRootElement(name = "FileName")
-public final class FileName {
+@XmlType(name = "MimeFileType_PropertyType")
+@XmlRootElement(name = "MimeFileType")
+public final class MimeFileType {
     /**
-     * The value of the {@code src} attribute, which is the file path.
+     * The value of the {@code type} attribute, which is the mime type.
      */
     @XmlAttribute
-    private String src;
+    private String type;
 
     /**
-     * A human-readable description of the filename. If {@link #src} if null,
-     * then this will be taken as the file path.
+     * A human-readable description of the mime type. If {@link #type} is null,
+     * then this will be taken as the mime type.
      */
     @XmlValue
     private String value;
@@ -59,29 +59,29 @@ public final class FileName {
     /**
      * Empty constructor for JAXB only.
      */
-    public FileName() {
+    public MimeFileType() {
     }
 
     /**
-     * Creates a new {@code <gml:FileName>} for the given URI.
+     * Creates a new {@code <gml:MimeFileType>} for the given type.
      *
-     * @param uri The string representation of the URI.
+     * @param type The MIME type.
      */
-    public FileName(final String uri) {
-        src   = uri;
-        value = uri.substring(uri.lastIndexOf('/') + 1);
+    public MimeFileType(final String type) {
+        this.type  = type;
+        this.value = type; // May provide a more human-redeable value in a future SIS version.
     }
 
     /**
-     * Returns the file path, or {@code null} if none.
+     * Returns the MIME type, or {@code null} if none.
      *
      * {@note Returning <code>null</code> is usually not recommended for a <code>toString()</code>
method,
      *        but this class is for internal usage only.}
      *
-     * @return The file path, or {@code null} if none.
+     * @return The MIME type, or {@code null} if none.
      */
     @Override
     public String toString() {
-        return (src != null) ? src : value;
+        return (type != null) ? type : value;
     }
 }

Copied: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java
(from r1514070, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java?p2=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java&p1=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java&r1=1514070&r2=1514388&rev=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -14,66 +14,45 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.jaxb.gco;
+package org.apache.sis.internal.jaxb.gmx;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.gco.StringAdapter;
+import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
+import org.apache.sis.internal.jaxb.gco.GO_CharacterString;
 
 
 /**
- * JAXB adapter wrapping a URI value with a {@code <gmx:FileName>} element, for ISO-19139
compliance.
+ * JAXB adapter wrapping a {@code String} value with a {@code <gmx:MimeFileType>} element.
  *
- * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.3 (derived from geotk-2.5)
+ * @since   0.4
  * @version 0.4
  * @module
  */
-public final class URIAdapter extends XmlAdapter<GO_CharacterString, URI> {
+public final class MimeFileTypeAdapter extends StringAdapter {
     /**
      * Empty constructor for JAXB.
      */
-    public URIAdapter() {
+    public MimeFileTypeAdapter() {
     }
 
     /**
-     * Converts a URI read from a XML stream to the object containing the value.
-     * JAXB calls automatically this method at unmarshalling time.
-     *
-     * @param  value The wrapper for the URI value, or {@code null}.
-     * @return An {@link URI} which represents the URI value, or {@code null}.
-     * @throws URISyntaxException If the string is not a valid URI.
-     */
-    @Override
-    public URI unmarshal(final GO_CharacterString value) throws URISyntaxException {
-        final String text = StringAdapter.toString(value);
-        if (text != null) {
-            final Context context = Context.current();
-            return Context.converter(context).toURI(context, text);
-        }
-        return null;
-    }
-
-    /**
-     * Converts a {@link URI} to the object to be marshalled in a XML file or stream.
+     * Converts a MIME type to the object to be marshalled in a XML file or stream.
      * JAXB calls automatically this method at marshalling time.
      *
-     * @param  value The URI value, or {@code null}.
-     * @return The wrapper for the given URI, or {@code null}.
+     * @param  value The MIME type, or {@code null}.
+     * @return The wrapper for the given MIME type, or {@code null}.
      */
     @Override
-    public GO_CharacterString marshal(final URI value) {
-        if (value != null) {
-            final Context context = Context.current();
-            final GO_CharacterString wrapper = CharSequenceAdapter.wrap(context, value, value.toString());
-            if (wrapper != null) {
-                if (!Context.isFlagSet(context, Context.SUBSTITUTE_FILENAME)) {
-                    wrapper.type = GO_CharacterString.FILENAME;
-                }
-                return wrapper;
+    public GO_CharacterString marshal(final String value) {
+        final Context context = Context.current();
+        final GO_CharacterString wrapper = CharSequenceAdapter.wrap(context, value, value);
+        if (wrapper != null) {
+            if (!Context.isFlagSet(context, Context.SUBSTITUTE_MIMETYPE)) {
+                wrapper.type = GO_CharacterString.MIME_TYPE;
             }
+            return wrapper;
         }
         return null;
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1514388&r1=1514387&r2=1514388&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
[UTF-8] Thu Aug 15 17:27:47 2013
@@ -89,17 +89,17 @@ import java.util.Objects;
  *
  * {@example "<code>0480439</code>" with the "<code>DDDMMmm</code>"
pattern will be parsed as 48°04.39′.}
  *
- * The {@code ?} modifier specify that the preceding field can be omitted if its value is
zero.
+ * The {@code ?} modifier specifies that the preceding field can be omitted if its value
is zero.
  * Any field can be omitted for {@link Angle} object, but only trailing fields are omitted
for
  * {@li{@link Longitude} and {@link Latitude}.
  *
- * {@example "<code>DD°MM′?SS″?</code>" will format an angle of 12.01°
as {@code 12°36″}, but a longitude of 12.01°N
- *           as {@code 12°00′36″N} (not {@code 12°36″N}).}
+ * {@example "<code>DD°MM′?SS″?</code>" will format an angle of 12.01°
as <code>12°36″</code>,
+ *           but a longitude of 12.01°N as <code>12°00′36″N</code> (not
<code>12°36″N</code>).}
  *
  * The above special case exists because some kind of angles are expected to be very small
(e.g. rotation angles in
  * {@linkplain org.apache.sis.referencing.datum.BursaWolfParameters Bursa-Wolf parameters}
are given in arc-seconds),
  * while longitude and latitude values are usually distributed over their full ±180° or
±90° range. Since longitude
- * or latitude values without the degrees field are unusual, omitting that field is almost
guaranteed to increase the
+ * or latitude values without the degrees field are unusual, omitting that field is likely
to increase the
  * risk of confusion in those cases.
  *
  * {@section Examples}



Mime
View raw message