[geotk] Reading MD_BrowseGraphic element

Vincent Gaudissart Vincent.Gaudissart at c-s.fr
Fri Jul 5 04:18:46 PDT 2013


Hello,


I'm desperately trying to find a way to read the content of the 
MD_BrowseGraphic element as defined below without touching the 
GeoToolkitsources :

                <gmd:graphicOverview>
                   <gmd:MD_BrowseGraphic>
                      <gmd:fileName>
                         <gmx:FileName 
src="XXXXXXXXXXXTHUMB.JPG">XXXXXXXXXXXTHUMB</gmx:FileName>
                      </gmd:fileName>
                      <gmd:fileDescription>
                         <mf:DG_BrowseGraphicType 
codeList="codelist.xml#DG_BrowseGraphicType" codeListValue="thumbnail" 
codeSpace="CARGENE">Thumbnail</mf:DG_BrowseGraphicType>
                      </gmd:fileDescription>
                      <gmd:fileType>
                         <gmx:MimeFileType type="image/jpg">JPEG 
image</gmx:MimeFileType>
                      </gmd:fileType>
                   </gmd:MD_BrowseGraphic>
                </gmd:graphicOverview>


I created a FileName class and FileNameAdapter class as you can seebelow:


FileName :
----------------------------------------
package test.gmx;

import java.net.URI;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import org.geotoolkit.util.Utilities;
import org.geotoolkit.xml.Namespaces;

@XmlType(name = "FileName_Type", namespace = Namespaces.GMX)
public class FileName {
     @XmlValue
     private String filename;

     @XmlAttribute(name = "src", namespace = Namespaces.GMX)
     private URI src;

     /**
      * An empty constructor used by JAXB.
      */
     public FileName() {
     }

     /**
      * Build a new Schema Component.
      */
     public FileName(final URI src) {
         filename = src.getPath();
         this.src = src;
     }

     public URI getSrc() {
         return src;
     }

     public String getFileName() {
         return filename;
     }

     /**
      * Verify if this entry is identical to the specified object.
      */
     @Override
     public boolean equals(final Object object) {
         if (object == this) {
             return true;
         }
         if (object instanceof FileName) {
             final FileName that = (FileName) object;
             return Utilities.equals(this.src, that.src);
         }
         return false;
     }

     @Override
     public String toString() {
         return src.toString();
     }
}


----------------------------------------
FileNameAdapter :
----------------------------------------
package test.gmx;

import java.net.URI;
import java.net.URISyntaxException;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public final class FileNameAdapter extends XmlAdapter<FileName, URI> {

     /**
      * Empty constructor for JAXB.
      */
     FileNameAdapter() {
     }

     /**
      * 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 adapter for this metadata value.
      * @return An {@link URI} which represents the metadata value.
      * @throws URISyntaxException If the string is not a valid URI.
      */
     @Override
     public URI unmarshal(final FileName value) throws URISyntaxException {
         return value.getSrc();
     }

     /**
      * Converts a {@link URI} 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.
      * @return The adapter for the given URI.
      */
     @Override
     public FileName marshal(final URI value) {
         return new FileName(value);
     }
}


----------------------------------------
Package_info:
----------------------------------------

@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = 
Namespaces.GMX, xmlns = { @XmlNs(prefix = "gmx", namespaceURI = 
Namespaces.GMX) })
@XmlAccessorType(XmlAccessType.NONE)
@XmlJavaTypeAdapters({
@XmlJavaTypeAdapter(InternationalStringConverter.class),
         @XmlJavaTypeAdapter(value = 
fr.cs.kheper.metadata.mgcp.gmx.FileNameAdapter.class, type = 
org.geotoolkit.metadata.iso.identification.DefaultBrowseGraphic.class) })
package test.gmx;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;

import org.geotoolkit.internal.jaxb.gco.InternationalStringConverter;
import org.geotoolkit.xml.Namespaces;


Whatever changes I make, they have no effect or I get the following error:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 
counts of IllegalAnnotationExceptions
@XmlAttribute/@XmlValue need to reference a Java type that maps to text 
in XML.
     this problem is related to the following location:
         at private java.net.URI test.gmx.FileName.src
         at test.gmx.FileName

Can - you help me read this item and its contents?

Thank you in advance,
-- 
------------------------------------------------------------------------
<www.c-s.fr> 	*Vincent GAUDISSART*
Architecte Système d'Information
*Division ESPACE & Renseignement* 
<https://thor.si.c-s.fr/blogs/cs-blogs-business/>*- Département 
APPLICATIONS*

*CS Systèmes d'Information*
Parc de la Grande Plaine - 5, Rue Brindejonc des Moulinais - BP 15872
31506 Toulouse Cedex 05 - FRANCE
Tel : +33 561 17 62 72 / Accueil : +33 561 17 66 66
Email : vincent.gaudissart at c-s.fr 	

------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20130705/a0c77d52/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_cs.png
Type: image/png
Size: 19066 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20130705/a0c77d52/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qrcode.png
Type: image/png
Size: 824 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20130705/a0c77d52/attachment-0003.png>


More information about the Geotoolkit mailing list