sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1514070 - in /sis/branches/JDK7/core: sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/ sis-metadata/src/test/java/org/apache/sis/test/suite/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/ sis-utility/src/main...
Date Wed, 14 Aug 2013 22:25:06 GMT
Author: desruisseaux
Date: Wed Aug 14 22:25:06 2013
New Revision: 1514070

URL: http://svn.apache.org/r1514070
Log:
First draft of <gmx:FileName> support (SIS-119).

Added:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
  (with props)
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.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/gco/package-info.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java

Added: 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=1514070&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata.iso.identification;
+
+import java.net.URI;
+import javax.xml.bind.JAXBException;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.xml.XML;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Test {@link DefaultBrowseGraphic}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class DefaultBrowseGraphicTest extends TestCase {
+    /**
+     * Tests XML marshalling of {@code <gmx:FileName>} inside {@code <gmd:MD_BrowseGraphic>}.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testFileName() throws JAXBException {
+        final URI uri = URI.create("file:/catalog/image.png");
+        final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(uri);
+        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:MD_BrowseGraphic>", xml, "xmlns:*");
+        /*
+         * Unmarshal the element back to a Java object and compare to the original.
+         */
+        assertEquals(browse, XML.unmarshal(xml));
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @Suite.SuiteClasses({
@@ -36,6 +36,7 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.identification.DefaultKeywordsTest.class,
     org.apache.sis.metadata.iso.identification.DefaultRepresentativeFractionTest.class,
     org.apache.sis.metadata.iso.identification.DefaultResolutionTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
     org.apache.sis.metadata.iso.spatial.DefaultGeorectifiedTest.class,
     org.apache.sis.metadata.iso.maintenance.DefaultScopeDescriptionTest.class,
     org.apache.sis.metadata.iso.quality.AbstractElementTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -43,7 +43,7 @@ import org.apache.sis.xml.ReferenceResol
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class Context extends MarshalContext {
@@ -68,6 +68,20 @@ public final class Context extends Marsh
     public static final int SUBSTITUTE_COUNTRY = 4;
 
     /**
+     * The bit flag for enabling substitution of filenames by character strings.
+     *
+     * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
+     */
+    public static final int SUBSTITUTE_FILENAME = 8;
+
+    /**
+     * The bit flag for enabling substitution of mime types by character strings.
+     *
+     * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
+     */
+    public static final int SUBSTITUTE_MIMETYPE = 16;
+
+    /**
      * The thread-local context. Elements are created in the constructor, and removed in
a
      * {@code finally} block by the {@link #finish()} method. This {@code ThreadLocal} shall
      * not contain any value when no (un)marshalling is in progress.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -41,7 +41,7 @@ import org.apache.sis.internal.jaxb.gmd.
  * @author  Guilhem Legal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see StringAdapter
@@ -71,7 +71,7 @@ public final class CharSequenceAdapter e
      * in a XML file or stream. JAXB calls automatically this method at marshalling time.
      *
      * @param  value The string value.
-     * @return The wrapper for the given character sequence.
+     * @return The wrapper for the given character sequence, or {@code null}.
      */
     @Override
     public GO_CharacterString marshal(final CharSequence value) {
@@ -83,11 +83,11 @@ public final class CharSequenceAdapter e
      * in a XML file or stream.
      *
      * @param  value The character representation of the object being marshalled.
-     * @return The wrapper for the given character sequence.
+     * @return The wrapper for the given character sequence, or {@code null}.
      */
     public static GO_CharacterString wrap(CharSequence value) {
         if (value instanceof String) {
-            return wrap(value, (String) value); // Slightly more efficient variant of this
method.
+            return wrap(Context.current(), value, (String) value); // Slightly more efficient
variant of this method.
         }
         /*
          * <gmd:someElement xsi:type="gmd:PT_FreeText_PropertyType">
@@ -147,25 +147,38 @@ public final class CharSequenceAdapter e
      * This method is a copy of {@link #wrap(CharSequence)} simplified for the case when
we know
      * that the character sequence being marshalled is a string.
      *
-     * @param  object The object being marshalled (e.g. {@code URI} or {@code Locale}).
-     * @param  string The string representation of the object being marshalled.
-     * @return The wrapper for the given character sequence.
+     * @param  context The current (un)marshalling context, or {@code null} if none.
+     * @param  object  The object being marshalled (e.g. {@code URI} or {@code Locale}).
+     * @param  string  The string representation of the object being marshalled.
+     * @return The wrapper for the given character sequence, or {@code null}.
      */
-    public static GO_CharacterString wrap(final Object object, String string) {
+    public static GO_CharacterString wrap(final Context context, final Object object, final
String string) {
+        final CharSequence text = value(context, object, string);
+        return (text != null) ? new GO_CharacterString(text) : null;
+    }
+
+    /**
+     * Same as {@link #wrap(Object, String)}, but returns directly the {@link GO_CharacterString#text}
+     * value without wrapping in a {@code GO_CharacterString} instance.
+     *
+     * @param  context The current (un)marshalling context, or {@code null} if none.
+     * @param  object  The object being marshalled (e.g. {@code URI} or {@code Locale}).
+     * @param  string  The string representation of the object being marshalled.
+     * @return The text value for the given character sequence, or {@code null}.
+     */
+    public static CharSequence value(final Context context, final Object object, String string)
{
         string = CharSequences.trimWhitespaces(string);
         if (string == null || string.isEmpty()) {
             return null;
         }
-        CharSequence value = string;
-        final Context context = Context.current();
         final XLink linkage = Context.resolver(context).anchor(context, object, string);
         if (linkage != null) {
             if (linkage instanceof Anchor) {
-                value = (Anchor) linkage;
+                return (Anchor) linkage;
             } else {
-                value = new Anchor(linkage, string);
+                return new Anchor(linkage, string);
             }
         }
-        return new GO_CharacterString(value);
+        return string;
     }
 }

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=1514070&r1=1514069&r2=1514070&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] Wed Aug 14 22:25:06 2013
@@ -16,32 +16,75 @@
  */
 package org.apache.sis.internal.jaxb.gco;
 
+import java.util.logging.Level;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
-
 import org.apache.sis.xml.Namespaces;
-import org.apache.sis.internal.jaxb.gmd.PT_FreeText;
-import org.apache.sis.internal.jaxb.gmd.LanguageCode;
-import org.apache.sis.internal.jaxb.gmd.Country;
+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.util.CharSequences;
+import org.apache.sis.util.resources.Messages;
 
 
 /**
- * JAXB wrapper for string value in a {@code <gco:CharacterString>} or {@code <gmx:Anchor>}
element,
- * for ISO-19139 compliance.
+ * JAXB wrapper for string value in a {@code <gco:CharacterString>}, {@code <gmx:Anchor>},
+ * {@code <gmx:FileName>} or {@code <gmx:MimeFileType>} element, for ISO-19139
compliance.
+ *
+ * <p>{@code FileName} and {@code MimeFileType} are possible substitutions for {@code
CharacterString}.
+ * They make sense only in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic}
or
+ * other classes using URI, but the XML schema does not prevent their usage in place of other
strings.
+ * Consequently we unconditionally accept {@code FileName} and {@code MimeFileType} at unmarshalling
time.
+ * However marshalling will use the appropriate element for the kind of property to marshal.</p>
  *
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see org.apache.sis.internal.jaxb.gmd.PT_FreeText
  */
 @XmlType(name = "CharacterString_PropertyType")
-@XmlSeeAlso({PT_FreeText.class, LanguageCode.class, Country.class})
+@XmlSeeAlso({
+    org.apache.sis.internal.jaxb.gmd.PT_FreeText.class,
+    org.apache.sis.internal.jaxb.gmd.LanguageCode.class,
+    org.apache.sis.internal.jaxb.gmd.Country.class
+})
 public class GO_CharacterString {
+    /*
+     * Numerical values below are ordered: if two or more values are defined (thoerically
not legal,
+     * but we try to be robust), the value associated to the highest constant has precedence.
+     */
+    /**
+     * Value assigned to {@link #type} if the character string
+     * shall be marshalled as a {@code <gmx:MimeFileType>} element.
+     */
+    public static final byte MIME_TYPE = 1;
+
+    /**
+     * Value assigned to {@link #type} if the character string
+     * shall be marshalled as a {@code <gmx:FileName>} element.
+     */
+    public static final byte FILENAME = 2;
+
+    /**
+     * Value assigned to {@link #type} if the current {@link #text}
+     * has been found in a {@code <gco:CharacterString>} element.
+     */
+    private static final byte ANCHOR = 3;
+
+    /**
+     * The XML element names for each possible {@link #type} values.
+     */
+    private static final String[] NAMES = new String[4];
+    static {
+        NAMES[0]         = "CharacterString";
+        NAMES[MIME_TYPE] = "MimeFileType";
+        NAMES[FILENAME]  = "FileName";
+        NAMES[ANCHOR]    = "Anchor";
+    }
+
     /**
      * The text or anchor value, or {@code null} if none. May be an instance
      * of {@link Anchor}, which needs to be handled in a special way.
@@ -49,13 +92,22 @@ public class GO_CharacterString {
     private CharSequence text;
 
     /**
+     * 0 if the text shall be marshalled as a {@code <gco:CharacterString>} or an anchor,
+     * or one of the static constants in this class otherwise.
+     *
+     * @see #FILENAME
+     * @see #MIME_TYPE
+     */
+    public byte type;
+
+    /**
      * Empty constructor for JAXB and subclasses.
      */
-    protected GO_CharacterString() {
+    public GO_CharacterString() {
     }
 
     /**
-     * Builds an wrapper for the given text.
+     * Builds a wrapper for the given text.
      *
      * @param text The string to marshal, or {@code null} if none.
      */
@@ -64,38 +116,89 @@ public class GO_CharacterString {
     }
 
     /**
-     * Builds an wrapper as a copy of the given one.
+     * Sets the {@link #text} field to the given value.
+     * If the given value overwrites a previous one, a warning is emitted.
      *
-     * @param text The wrapper to copy, or {@code null} if none.
+     * @param value    The value to set.
+     * @param property 0 or one of the {@link #MIME_TYPE}, {@link #FILENAME} or {@link #ANCHOR}
constants.
      */
-    protected GO_CharacterString(final GO_CharacterString text) {
-        if (text != null) {
-            this.text = text.text;
+    private void setText(final CharSequence value, byte property) {
+        if (text != null && !value.equals(text)) {
+            /*
+             * The given value overwrite a previous one. Determine which value will be discarded
+             * using the 'type' value as a criterion, then emit a warning.
+             */
+            byte discarded = type;
+            boolean noset = false;
+            if (discarded > property) {
+                discarded = property;
+                property  = type;
+                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]));
+            if (noset) {
+                return;
+            }
         }
+        text = value;
+        type = property;
     }
 
     /**
-     * Returns the text. This method is called by JAXB at marshalling time.
+     * Returns the text in a {@code <gco:CharacterString>} element, or {@code null}
if none.
      *
      * @return The text, or {@code null}.
      */
     @XmlElement(name = "CharacterString")
     public final String getCharacterString() {
-        final CharSequence text = this.text;
-        return (text == null || text instanceof Anchor) ? null : text.toString();
+        if (type == 0) {
+            final CharSequence text = this.text;
+            if (text != null && !(text instanceof Anchor)) {
+                return text.toString();
+            }
+        }
+        return null;
     }
 
     /**
      * Sets the value to the given string. This method is called by JAXB at unmarshalling
time.
      *
-     * @param text The new text.
+     * @param value The new text.
      */
-    public final void setCharacterString(String text) {
-        text = CharSequences.trimWhitespaces(text);
-        if (text != null && text.isEmpty()) {
-            text = null;
+    public final void setCharacterString(String value) {
+        value = CharSequences.trimWhitespaces(value);
+        if (value != null && !value.isEmpty()) {
+            setText(value, (byte) 0);
+        }
+    }
+
+    /**
+     * Returns the text in a {@code <gco:FileName>} element, or {@code null} if none.
+     */
+    @XmlElement(name = "FileName", namespace = Namespaces.GMX)
+    final FileName getFileName() {
+        if (type == FILENAME) {
+            final CharSequence text = this.text;
+            if (text != null && !(text instanceof Anchor)) {
+                return new FileName(text.toString());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Invoked by JAXB for setting the filename.
+     */
+    final void setFileName(final FileName file) {
+        if (file != null) {
+            final String value = CharSequences.trimWhitespaces(file.toString());
+            if (value != null && !value.isEmpty()) {
+                setText(value, FILENAME);
+            }
         }
-        this.text = text;
     }
 
     /**
@@ -117,7 +220,7 @@ public class GO_CharacterString {
      * @param anchor The new anchor.
      */
     public final void setAnchor(final Anchor anchor) {
-        this.text = anchor;
+        setText(anchor, ANCHOR);
     }
 
     /**

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=1514070&r1=1514069&r2=1514070&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] Wed Aug 14 22:25:06 2013
@@ -105,6 +105,6 @@ public final class StringAdapter extends
      */
     @Override
     public GO_CharacterString marshal(final String value) {
-        return CharSequenceAdapter.wrap(value, value);
+        return CharSequenceAdapter.wrap(Context.current(), value, value);
     }
 }

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=1514070&r1=1514069&r2=1514070&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] Wed Aug 14 22:25:06 2013
@@ -23,20 +23,19 @@ import org.apache.sis.internal.jaxb.Cont
 
 
 /**
- * JAXB adapter wrapping a URI value with a {@code <gco:CharacterString>} element,
- * for ISO-19139 compliance.
+ * JAXB adapter wrapping a URI value with a {@code <gmx:FileName>} element, for ISO-19139
compliance.
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class URIAdapter extends XmlAdapter<GO_CharacterString, URI> {
     /**
      * Empty constructor for JAXB.
      */
-    private URIAdapter() {
+    public URIAdapter() {
     }
 
     /**
@@ -66,6 +65,16 @@ public final class URIAdapter extends Xm
      */
     @Override
     public GO_CharacterString marshal(final URI value) {
-        return (value != null) ? CharSequenceAdapter.wrap(value, value.toString()) : null;
+        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;
+            }
+        }
+        return null;
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -79,7 +79,7 @@
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -45,7 +45,7 @@ import org.apache.sis.internal.jaxb.gco.
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @XmlType(name = "Country_PropertyType")
@@ -63,10 +63,10 @@ public final class Country extends GO_Ch
     }
 
     /**
-     * Builds a {@code <gco:CharacterString>} element.
+     * Builds a {@code <gco:Country>} element.
      * For private use by {@link #create(Context, Locale)} only.
      */
-    private Country(final GO_CharacterString code) {
+    private Country(final CharSequence code) {
         super(code);
     }
 
@@ -99,7 +99,7 @@ public final class Country extends GO_Ch
                  * Marshal the locale as a <gco:CharacterString> instead than <Country>,
                  * using the user-supplied anchors if any.
                  */
-                final GO_CharacterString string = CharSequenceAdapter.wrap(locale, codeListValue);
+                final CharSequence string = CharSequenceAdapter.value(context, locale, codeListValue);
                 if (string != null) {
                     return new Country(string);
                 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -61,10 +61,10 @@ public final class LanguageCode extends 
     }
 
     /**
-     * Builds a {@code <gco:CharacterString>} element.
+     * Builds a {@code <gco:LanguageCode>} element.
      * For private use by {@link #create(Context, Locale)} only.
      */
-    private LanguageCode(final GO_CharacterString code) {
+    private LanguageCode(final CharSequence code) {
         super(code);
     }
 
@@ -97,7 +97,7 @@ public final class LanguageCode extends 
                  * Marshal the locale as a <gco:CharacterString> instead than <LanguageCode>,
                  * using the user-supplied anchors if any.
                  */
-                final GO_CharacterString string = CharSequenceAdapter.wrap(locale, codeListValue);
+                final CharSequence string = CharSequenceAdapter.value(context, locale, codeListValue);
                 if (string != null) {
                     return new LanguageCode(string);
                 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -96,6 +96,9 @@ public final class Anchor extends XLink 
 
     /**
      * Returns the text as a string, or {@code null} if none.
+     *
+     * @param  locale Ignored in current implementation.
+     * @return The anchor text, or {@code null} if none.
      */
     @Override
     public String toString(final Locale locale) {
@@ -120,7 +123,7 @@ public final class Anchor extends XLink 
 
     /**
      * Returns the sequence of characters in the given range of index.
-     * The returned object still an anchor with the same attribute values.
+     * The returned object is an anchor with the same attribute values.
      * It is caller responsibility to determine if those attributes are still
      * appropriate for the sub-sequence.
      */
@@ -131,7 +134,7 @@ public final class Anchor extends XLink 
             original = "";
         }
         final String substring = original.substring(start, end);
-        if (substring == original) {
+        if (substring == original) { // Identity comparison is ok here.
             return this;
         }
         return new Anchor(this, substring);

Added: 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=1514070&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
(added)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -0,0 +1,87 @@
+/*
+ * 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.gmx;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+/**
+ * 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}.
+ * Example:
+ *
+ * {@preformat xml
+ *   <fileName>
+ *      <gmx:FileName src="../path/wkj98723.jpg">Overview</gmx:FileName>
+ *   </fileName>
+ * }
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ *
+ * @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 {
+    /**
+     * The value of the {@code src} attribute, which is the file path.
+     */
+    @XmlAttribute
+    private String src;
+
+    /**
+     * A human-readable description of the filename. If {@link #src} if null,
+     * then this will be taken as the file path.
+     */
+    @XmlValue
+    private String value;
+
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public FileName() {
+    }
+
+    /**
+     * Creates a new {@code <gml:FileName>} for the given URI.
+     *
+     * @param uri The string representation of the URI.
+     */
+    public FileName(final String uri) {
+        src   = uri;
+        value = uri.substring(uri.lastIndexOf('/') + 1);
+    }
+
+    /**
+     * Returns the file path, 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.
+     */
+    @Override
+    public String toString() {
+        return (src != null) ? src : value;
+    }
+}

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

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

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java
[UTF-8] Wed Aug 14 22:25:06 2013
@@ -20,7 +20,7 @@
  *
  * @author  Guilhem Legal (Geomatys)
  * @since   0.3 (derived from geotk-2.5)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8]
Wed Aug 14 22:25:06 2013
@@ -326,6 +326,10 @@ abstract class Pooled {
                                 mask |= Context.SUBSTITUTE_LANGUAGE;
                             } else if (CharSequences.equalsIgnoreCase(substitute, "country"))
{
                                 mask |= Context.SUBSTITUTE_COUNTRY;
+                            } else if (CharSequences.equalsIgnoreCase(substitute, "filename"))
{
+                                mask |= Context.SUBSTITUTE_FILENAME;
+                            } else if (CharSequences.equalsIgnoreCase(substitute, "mimetype"))
{
+                                mask |= Context.SUBSTITUTE_MIMETYPE;
                             }
                         }
                     }
@@ -369,9 +373,11 @@ abstract class Pooled {
             case XML.WARNING_LISTENER: return warningListener;
             case XML.STRING_SUBSTITUTES: {
                 int n = 0;
-                final String[] substitutes = new String[2];
+                final String[] substitutes = new String[4];
                 if ((bitMasks & Context.SUBSTITUTE_LANGUAGE) != 0) substitutes[n++] =
"language";
                 if ((bitMasks & Context.SUBSTITUTE_COUNTRY)  != 0) substitutes[n++] =
"country";
+                if ((bitMasks & Context.SUBSTITUTE_FILENAME) != 0) substitutes[n++] =
"filename";
+                if ((bitMasks & Context.SUBSTITUTE_MIMETYPE) != 0) substitutes[n++] =
"mimetype";
                 return (n != 0) ? ArraysExt.resize(substitutes, n) : null;
             }
             default: {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1514070&r1=1514069&r2=1514070&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] Wed
Aug 14 22:25:06 2013
@@ -237,8 +237,10 @@ public final class XML extends Static {
      * The value for this property shall be a {@code String[]} array of any of the following
values:
      *
      * <ul>
-     *   <li>"{@code language}"</li>
-     *   <li>"{@code country}"</li>
+     *   <li>"{@code language}" for substituting {@code <gmd:LanguageCode>} elements</li>
+     *   <li>"{@code country}"  for substituting {@code <gmd:Country>} elements</li>
+     *   <li>"{@code filename}" for substituting {@code <gmx:FileName>} elements</li>
+     *   <li>"{@code mimetype}" for substituting {@code <gmx:MimeFileType>} elements</li>
      * </ul>
      *
      * {@section Example}



Mime
View raw message