Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -19,12 +19,13 @@ package org.apache.sis.internal.jaxb.gmd import java.util.Locale; import javax.xml.bind.annotation.XmlElement; import org.apache.sis.util.Debug; +import org.apache.sis.xml.Namespaces; /** * A set of strings localized in different languages. This adapter represents the - * {@code <gmd:textGroup>} element defined for embedded translations in ISO-19139 - * standard. See {@link PT_FreeText} class javadoc for an example. + * {@code <lan:textGroup>} element defined in ISO 19139:2007. + * See {@link PT_FreeText} class javadoc for an example. * * <p>If a localized string has a {@code null} locale, then this string will not be * included in this text group because that string should be already included in @@ -35,40 +36,41 @@ import org.apache.sis.util.Debug; * <p>The {@code TextGroup} name suggests that this object can contain many localized strings. * However it appears that despite its name, {@code TextGroup} shall always contains exactly 1 * localized strings and the whole {@code TextGroup} element shall be repeated for each additional - * languages. SIS uses the ISO 19139 compliant form for marshalling, but accepts both forms during - * unmarshalling. More specifically, the name suggests that the format should be:</p> + * languages. SIS uses the ISO 19139:2007 compliant form for marshalling, but accepts both forms + * during unmarshalling. More specifically, the name suggests that the format should be:</p> * * {@preformat xml * <gco:CharacterString>Apache SIS, projet OpenSource</gco:CharacterString> - * <gmd:PT_FreeText> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</gmd:LocalisedCharacterString> - * <gmd:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</gmd:LocalisedCharacterString> - * <gmd:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * </gmd:PT_FreeText> + * <lan:PT_FreeText> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</lan:LocalisedCharacterString> + * <lan:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</lan:LocalisedCharacterString> + * <lan:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * </lan:PT_FreeText> * } * * But the actual official format is: * * {@preformat xml * <gco:CharacterString>Apache SIS, projet OpenSource</gco:CharacterString> - * <gmd:PT_FreeText> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * </gmd:PT_FreeText> + * <lan:PT_FreeText> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</lan:LocalisedCharacterString> + * </lan:textGroup> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * </lan:PT_FreeText> * } * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see LocalisedCharacterString * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-152">GEOTK-152</a> @@ -82,11 +84,11 @@ final class TextGroup { * JAXB uses this field at marshalling-time in order to wrap {@code N} * {@code <LocalisedCharacterString>} elements inside a single {@code <textGroup>} element. * - * <p>In ISO 19139 compliant documents, the length of this array shall be exactly 1, + * <p>In ISO 19139:2007 compliant documents, the length of this array shall be exactly 1, * as in the second example of class javadoc. However SIS allows arbitrary length * (as in the first example of class javadoc) for compatibility and convenience reasons.</p> */ - @XmlElement(name = "LocalisedCharacterString") + @XmlElement(name = "LocalisedCharacterString", namespace = Namespaces.LAN) protected LocalisedCharacterString[] localized; /** @@ -97,9 +99,9 @@ final class TextGroup { /** * Constructs a {@linkplain TextGroup text group} for a single locale. This constructor - * puts exactly one string in the {@code TextGroup}, as required by ISO 19139. However - * it would be possible to declare an other constructor allowing the more compact form - * (the smaller ) if there is a need for that in the future. + * puts exactly one string in the {@code TextGroup}, as required by ISO 19139:2007. + * However it would be possible to declare an other constructor allowing the more compact form + * (the smaller) if there is a need for that in the future. * * @param locale the string language. * @param text the string.
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -21,15 +21,17 @@ * lists (except base classes), which are defined in their own package. * * @author Cédric Briançon (Geomatys) - * @version 0.7 + * @author Martin Desruisseaux (Geomatys) + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * * @since 0.3 * @module */ -@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), +@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.MDB, xmlns = { + @XmlNs(prefix = "mdb", namespaceURI = Namespaces.MDB), @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO) }) @XmlAccessorType(XmlAccessType.NONE) Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -35,11 +35,11 @@ import org.apache.sis.measure.Units; /** * A measurement value together with its unit of measure. - * This is used for marshalling an element defined by ISO-19103. + * This is used for marshalling an element defined by ISO 19103. * * <p>This class duplicates {@code org.apache.sis.measure.Measure}, but we have to do that way * because that {@code Measure} extends {@link Number} and we are not allowed to use the - * {@code @XmlValue} annotation on a class that extends an other class.</p> + * {@code @XmlValue} annotation on a class that extends another class.</p> * * <div class="section">XML marshalling</div> * Measures are used in different ways by the ISO 19115 (Metadata) and GML standards. @@ -48,7 +48,7 @@ import org.apache.sis.measure.Units; * * {@preformat xml * <gmd:distance> - * <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance> + * <gco:Distance uom="http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])">1000.0</gco:Distance> * </gmd:distance> * } * @@ -63,7 +63,7 @@ import org.apache.sis.measure.Units; * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * * @see org.apache.sis.internal.jaxb.gml.MeasureList * @see org.apache.sis.internal.jaxb.gco.UnitAdapter @@ -121,7 +121,7 @@ public final class Measure { } /** - * Constructs a string representation of the units as defined in the ISO-19103 standard. + * Constructs a string representation of the units as defined in the ISO 19103 standard. * This method is invoked during XML marshalling. For example if the units are "metre", * then this method returns one of the following strings, in preference order: * @@ -129,10 +129,11 @@ public final class Measure { * urn:ogc:def:uom:EPSG::9001 * } * - * or + * or one of the following: * * {@preformat text * http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m']) + * http://www.isotc211.org/2005/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m']) * } * * @return the string representation of the unit of measure. @@ -165,14 +166,26 @@ public final class Measure { if (unit == null || unit.equals(Units.UNITY)) { return ""; } - final StringBuilder buffer = Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT) - .append(Schemas.UOM_PATH).append("#xpointer(//*[@gml:id='"); + final StringBuilder link; + final Context context = Context.current(); + /* + * We have not yet found an ISO 19115-3 URL for units of measurement. + * If we find one, we should use a block like below: + * + * if (Context.isFlagSet(context, Context.LEGACY_METADATA)) { + * link = ... new URL ... + * } else { + * link = current code + * } + */ + link = Context.schema(context, "gmd", Schemas.METADATA_ROOT_LEGACY); + link.append(Schemas.UOM_PATH).append("#xpointer(//*[@gml:id='"); try { - UCUM.format(unit, buffer); + UCUM.format(unit, link); } catch (IOException e) { throw new AssertionError(e); // Should never happen since we wrote to a StringBuilder. } - return buffer.append("'])").toString(); + return link.append("'])").toString(); } /** Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -27,7 +27,7 @@ import org.apache.sis.util.Classes; /** * JAXB adapter for {@link VerticalCRS}, in order to integrate the value in an element * complying with OGC/ISO standard. Note that the CRS is formatted using the GML schema, - * not the ISO 19139 one. + * not the ISO 19139:2007 one. * * <p>This wrapper does not declare directly the XML element, because doing so would require * the implementation classes in the {@code sis-referencing} module. Instead, this wrapper Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -30,15 +30,15 @@ import org.apache.sis.util.resources.Err /** * JAXB adapter for {@link TemporalPrimitive}, in order to integrate the value in an element complying - * with OGC/ISO standard. Note that the CRS is formatted using the GML schema, not the ISO 19139 one. + * with OGC/ISO standard. Note that the CRS is formatted using the GML schema, not the ISO 19139:2007 one. * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.4 + * @version 1.0 * @since 0.3 * @module */ -public final class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive> { +public class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive> { /** * Empty constructor for JAXB. */ @@ -71,7 +71,7 @@ public final class TM_Primitive extends * @return {@code TemporalPrimitive.class} */ @Override - protected Class<TemporalPrimitive> getBoundType() { + protected final Class<TemporalPrimitive> getBoundType() { return TemporalPrimitive.class; } @@ -82,7 +82,7 @@ public final class TM_Primitive extends * @return the time period, or {@code null}. */ @XmlElement(name = "TimePeriod") - public TimePeriod getTimePeriod() { + public final TimePeriod getTimePeriod() { final TemporalPrimitive metadata = this.metadata; return (metadata instanceof Period) ? new TimePeriod((Period) metadata) : null; } @@ -94,7 +94,7 @@ public final class TM_Primitive extends * @return the time instant, or {@code null}. */ @XmlElement(name = "TimeInstant") - public TimeInstant getTimeInstant() { + public final TimeInstant getTimeInstant() { final TemporalPrimitive metadata = this.metadata; return (metadata instanceof Instant) ? new TimeInstant((Instant) metadata) : null; } @@ -105,7 +105,7 @@ public final class TM_Primitive extends * * @param period the wrapper to set. */ - public void setTimePeriod(final TimePeriod period) { + public final void setTimePeriod(final TimePeriod period) { metadata = null; // Cleaned first in case of failure. if (period != null) { final Context context = Context.current(); @@ -137,7 +137,7 @@ public final class TM_Primitive extends * * @param instant the wrapper to set. */ - public void setTimeInstant(final TimeInstant instant) { + public final void setTimeInstant(final TimeInstant instant) { metadata = null; // Cleaned first in case of failure. if (instant != null) { final Date position = XmlUtilities.toDate(Context.current(), instant.timePosition); @@ -168,4 +168,23 @@ public final class TM_Primitive extends Context.warningOccured(Context.current(), TM_Primitive.class, method, e, true); } } + + /** + * Wraps the value only if marshalling ISO 19115-3 element. + * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element. + */ + public static final class Since2014 extends TM_Primitive { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected TM_Primitive wrap(final TemporalPrimitive value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -23,13 +23,13 @@ import javax.xml.bind.annotation.XmlRoot /** - * The {@code <gmx:FileName>} element, which may be used as a substitute of {@code <gco:CharacterString>}. + * The {@code <gcx: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> + * <gcx:FileName src="../path/wkj98723.jpg">Overview</gcx:FileName> * </fileName> * } * Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -23,13 +23,13 @@ import javax.xml.bind.annotation.XmlRoot /** - * The {@code <gmx:MimeFileType>} element, which may be used as a substitute of {@code <gco:CharacterString>}. + * The {@code <gcx: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 * <fileType> - * <gmx:MimeFileType type="image/tiff">Graphic TIFF</gmx:MimeFileType> + * <gcx:MimeFileType type="image/tiff">Graphic TIFF</gcx:MimeFileType> * </fileType> * } * Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -23,7 +23,7 @@ import org.apache.sis.internal.jaxb.gco. /** - * JAXB adapter wrapping a {@code String} value with a {@code <gmx:MimeFileType>} element. + * JAXB adapter wrapping a {@code String} value with a {@code <gcx:MimeFileType>} element. * * @author Martin Desruisseaux (Geomatys) * @version 0.4 Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -16,18 +16,21 @@ */ /** - * Miscellaneous objects and adapters defined in the {@code "gmx"} namespace. + * Miscellaneous objects and adapters defined in the {@code "gcx"} namespace. + * In legacy ISO 19139:2007, this namespace was to {@code "gmx"}. * * @author Guilhem Legal (Geomatys) - * @version 0.4 + * @author Martin Desruisseaux (Geomatys) + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * * @since 0.3 * @module */ -@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMX, xmlns = { - @XmlNs(prefix = "gmx", namespaceURI = Namespaces.GMX) +@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GCX, xmlns = { + @XmlNs(prefix = "gcx", namespaceURI = Namespaces.GCX) }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapter(InternationalStringConverter.class) Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -33,7 +33,8 @@ * This is used for storing the value in a list of identifiers while preserving the original object.</p> * * @author Cédric Briançon (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -49,7 +49,7 @@ import static org.apache.sis.util.collec * bit tedious to explain, which is an other indication that they should not be in public API. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -61,6 +61,21 @@ public final class CollectionsExt extend } /** + * Returns a queue which is always empty and accepts no element. + * This method will be removed if a future JDK version provides such method in {@link Collections}. + * + * @param <E> the type of elements in the empty collection. + * @return an empty collection. + * + * @see Collections#emptyList() + * @see Collections#emptySet() + */ + @SuppressWarnings("unchecked") + public static <E> Queue<E> emptyQueue() { + return EmptyQueue.INSTANCE; + } + + /** * Returns an empty collection of the given type, or {@code null} if the given type is unknown to this method. * * @param type the desired collection type. @@ -139,20 +154,6 @@ public final class CollectionsExt extend } /** - * Returns a {@linkplain Queue queue} which is always empty and accepts no element. - * - * @param <E> the type of elements in the empty collection. - * @return an empty collection. - * - * @see Collections#emptyList() - * @see Collections#emptySet() - */ - @SuppressWarnings({"unchecked","rawtype"}) - public static <E> Queue<E> emptyQueue() { - return EmptyQueue.INSTANCE; - } - - /** * Returns the given value as a singleton if non-null, or returns an empty set otherwise. * * @param <E> the element type. @@ -364,6 +365,8 @@ public final class CollectionsExt extend * @param <E> the type of elements in the set. * @param set the set to make unmodifiable, or {@code null}. * @return a unmodifiable version of the given set, or {@code null} if the given set was null. + * + * @see #compact(Set) */ public static <E> Set<E> unmodifiableOrCopy(Set<E> set) { if (set != null) { @@ -400,6 +403,8 @@ public final class CollectionsExt extend * @param <V> the type of values in the map. * @param map the map to make unmodifiable, or {@code null}. * @return a unmodifiable version of the given map, or {@code null} if the given map was null. + * + * @see #compact(Map) */ public static <K,V> Map<K,V> unmodifiableOrCopy(Map<K,V> map) { if (map != null) { @@ -593,19 +598,43 @@ public final class CollectionsExt extend * @param <V> the type of values in the map. * @param map the map to compact, or {@code null}. * @return a potentially compacted map, or {@code null} if the given map was null. + * + * @see #unmodifiableOrCopy(Map) */ public static <K,V> Map<K,V> compact(final Map<K,V> map) { if (map != null) { switch (map.size()) { - case 0: return Collections.emptyMap(); - case 1: final Map.Entry<K,V> entry = map.entrySet().iterator().next(); - return Collections.singletonMap(entry.getKey(), entry.getValue()); + case 0: return Collections.emptyMap(); + case 1: final Map.Entry<K,V> entry = map.entrySet().iterator().next(); + return Collections.singletonMap(entry.getKey(), entry.getValue()); } } return map; } /** + * Returns a more compact representation of the given set. This method is similar to + * {@link #unmodifiableOrCopy(Set)} except that it does not wrap the set in an unmodifiable + * view. The intend is to avoid one level of indirection for performance and memory reasons. + * This is okay only if the set is kept in a private field and never escape outside that class. + * + * @param <E> the type of elements in the set. + * @param set the set to compact, or {@code null}. + * @return a unmodifiable version of the given set, or {@code null} if the given set was null. + * + * @see #unmodifiableOrCopy(Set) + */ + public static <E> Set<E> compact(final Set<E> set) { + if (set != null) { + switch (set.size()) { + case 0: return Collections.emptySet(); + case 1: return Collections.singleton(set.iterator().next()); + } + } + return set; + } + + /** * Returns a snapshot of the given list. The returned list will not be affected by changes * in the given list after this method call. This method makes no guaranteed about whether * the returned list is modifiable or not. @@ -627,6 +656,18 @@ public final class CollectionsExt extend } /** + * Returns a clone of the given set. This method is only intended to avoid the "unchecked cast" warning. + * + * @param <E> type of elements in the set. + * @param set the set to clone. + * @return a clone of the given set. + */ + @SuppressWarnings("unchecked") + public static <E> HashSet<E> clone(final HashSet<E> set) { + return (HashSet<E>) set.clone(); + } + + /** * Returns the given value as a collection. Special cases: * * <ul> Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -20,6 +20,7 @@ import java.util.Date; import org.opengis.temporal.Instant; import org.opengis.temporal.Period; import org.opengis.temporal.TemporalFactory; +import org.opengis.temporal.TemporalPrimitive; import org.apache.sis.util.Static; import org.apache.sis.util.resources.Errors; import org.apache.sis.internal.system.DefaultFactories; @@ -31,7 +32,7 @@ import org.apache.sis.internal.system.De * * @author Martin Desruisseaux (Geomatys) * @author Guilhem Legal (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -99,4 +100,28 @@ public final class TemporalUtilities ext final TemporalFactory factory = getTemporalFactory(); return factory.createPeriod(createInstant(factory, begin), createInstant(factory, end)); } + + /** + * Infers a value from the extent as a {@link Date} object. + * This method is used for compatibility with legacy API and may disappear in future SIS version. + * + * @param time the instant or period for which to get a date, or {@code null}. + * @return the requested time as a Java date, or {@code null} if none. + * + * @since 1.0 + */ + public static Date getDate(final TemporalPrimitive time) { + Instant instant; + if (time instanceof Instant) { + instant = (Instant) time; + } else if (time instanceof Period) { + instant = ((Period) time).getEnding(); + if (instant == null) { + instant = ((Period) time).getBeginning(); + } + } else { + return null; + } + return instant.getDate(); + } } Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -134,7 +134,9 @@ public final class Utilities extends Sta return true; } if (object1 == null || object2 == null) { - assert isNotDebug(mode) : "object" + (object1 == null ? '1' : '2') + " is null"; + assert isNotDebug(mode) : ((object1 != null) ? object1.getClass() + : (object2 != null) ? object2.getClass() + : Object.class).getSimpleName() + " #" + (object1 == null ? '1' : '2') + " is null"; return false; } if (object1 instanceof LenientComparable) { Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -205,7 +205,7 @@ public class Cache<K,V> extends Abstract * {@linkplain Reference weak or soft references}.</p> * * @param initialCapacity the initial capacity. - * @param costLimit the maximum number of objects to keep by strong reference. + * @param costLimit the maximum cost of objects to keep by strong reference. * @param soft if {@code true}, use {@link SoftReference} instead of {@link WeakReference}. */ public Cache(int initialCapacity, final long costLimit, final boolean soft) { Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -54,7 +54,7 @@ import org.apache.sis.internal.util.Abst * * @author Martin Desruisseaux (Geomatys) * @author Cullen Rombach (Image Matters) - * @version 0.8 + * @version 1.0 * * @see DefaultRecordType * @see DefaultRecordSchema @@ -80,6 +80,14 @@ public class DefaultRecord implements Re private final Object values; /** + * Constructs an initially empty record. Used by JAXB. + */ + private DefaultRecord() { + definition = null; + values = null; + } + + /** * Creates a new record for the given record type. * The initial values are unspecified - they may be null or zero. * Callers can assign values by a call to {@link #setAll(Object[])}. @@ -162,7 +170,8 @@ public class DefaultRecord implements Re */ @Override public RecordType getRecordType() { - return definition.getRecordType(); + // Should never be null, unless temporarily during unmarshalling. + return (definition != null) ? definition.getRecordType() : null; } /** Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -256,7 +256,7 @@ public final class Errors extends Indexe public static final short EmptyProperty_1 = 32; /** - * An error occurred in file “{0}” at Line {1}. + * An error occurred in file “{0}” at line {1}. */ public static final short ErrorInFileAtLine_2 = 33; @@ -535,6 +535,11 @@ public final class Errors extends Indexe public static final short MissingJAXBContext = 86; /** + * Missing or empty ‘{1}’ attribute in “{0}”. + */ + public static final short MissingOrEmptyAttribute_2 = 182; + + /** * This operation requires the “{0}” module. */ public static final short MissingRequiredModule_1 = 87; Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Sat Feb 24 16:13:58 2018 @@ -63,7 +63,7 @@ EmptyDictionary = The EmptyEnvelope2D = Envelope must be at least two-dimensional and non-empty. EmptyProperty_1 = Property named \u201c{0}\u201d shall not be empty. ErrorIn_2 = Error in \u201c{0}\u201d: {1} -ErrorInFileAtLine_2 = An error occurred in file \u201c{0}\u201d at Line {1}. +ErrorInFileAtLine_2 = An error occurred in file \u201c{0}\u201d at line {1}. ExcessiveArgumentSize_3 = Argument \u2018{0}\u2019 shall not contain more than {1} elements. A number of {2} is excessive. ExcessiveListSize_2 = A size of {1} elements is excessive for the \u201c{0}\u201d list. ExcessiveNumberOfDimensions_1 = For this algorithm, {0} is an excessive number of dimensions. @@ -117,6 +117,7 @@ MismatchedMatrixSize_4 = Mism MissingCharacterInElement_2 = Missing a \u2018{1}\u2019 character in \u201c{0}\u201d element. MissingComponentInElement_2 = Missing a \u201c{1}\u201d component in \u201c{0}\u201d. MissingJAXBContext = JAXB context has not been specified. +MissingOrEmptyAttribute_2 = Missing or empty \u2018{1}\u2019 attribute in \u201c{0}\u201d. MissingRequiredModule_1 = This operation requires the \u201c{0}\u201d module. MissingValueForOption_1 = Missing value for \u201c{0}\u201d option. MissingValueForProperty_1 = Missing value for \u201c{0}\u201d property. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Sat Feb 24 16:13:58 2018 @@ -114,6 +114,7 @@ MismatchedMatrixSize_4 = Une MissingCharacterInElement_2 = Un caract\u00e8re \u2018{1}\u2019 est manquant dans l\u2019\u00e9l\u00e9ment \u00ab\u202f{0}\u202f\u00bb. MissingComponentInElement_2 = Il manque une composante \u00ab\u202f{1}\u202f\u00bb dans l\u2019\u00e9l\u00e9ment \u00ab\u202f{0}\u202f\u00bb. MissingJAXBContext = Le contexte JAXB n\u2019a pas \u00e9t\u00e9 sp\u00e9cifi\u00e9. +MissingOrEmptyAttribute_2 = L\u2019attribut \u2018{1}\u2019 de \u00ab\u202f{0}\u202f\u00bb est manquant ou vide. MissingRequiredModule_1 = Cette op\u00e9ration requiert le module \u00ab\u202f{0}\u202f\u00bb. MissingValueForOption_1 = Aucune valeur n\u2019a \u00e9t\u00e9 d\u00e9finie pour l\u2019option \u00ab\u202f{0}\u202f\u00bb. MissingValueForProperty_1 = Aucune valeur n\u2019a \u00e9t\u00e9 d\u00e9finie pour la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -204,6 +204,11 @@ public final class Messages extends Inde public static final short PropertyHiddenBy_2 = 28; /** + * “{0}” is not the name of a known list of codes. + */ + public static final short UnknownCodeList_1 = 33; + + /** * The text contains unknown elements: */ public static final short UnknownElementsInText = 29; Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties [ISO-8859-1] Sat Feb 24 16:13:58 2018 @@ -44,6 +44,7 @@ LocalesDiscarded = Text OptionalModuleNotFound_1 = Optional module \u201c{0}\u201d requested but not found. PropertyHiddenBy_2 = Property \u201c{0}\u201d is hidden by \u201c{1}\u201d. NonConformFormatting_1 = This \u201c{0}\u201d formatting is a departure from standard format. +UnknownCodeList_1 = \u201c{0}\u201d is not the name of a known list of codes. UnknownElementsInText = The text contains unknown elements: UnknownKeywordInRecord_2 = Loading of \u201c{0}\u201d done, but some records were ignored because of unrecognized keywords: {1} UnparsableValueStoredAsText_2 = Can not parse \u201c{1}\u201d as an instance of \u2018{0}\u2019. The value is stored as plain text instead, but will be ignored by some processing. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties [ISO-8859-1] Sat Feb 24 16:13:58 2018 @@ -51,6 +51,7 @@ LocalesDiscarded = Des t OptionalModuleNotFound_1 = Le module optionnel \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9 demand\u00e9 mais n\u2019a pas \u00e9t\u00e9 trouv\u00e9. PropertyHiddenBy_2 = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb est masqu\u00e9e par \u00ab\u202f{1}\u202f\u00bb. NonConformFormatting_1 = Cette \u00e9criture de \u00ab\u202f{0}\u202f\u00bb d\u00e9vie du format standard. +UnknownCodeList_1 = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas le nom d\u2019une liste de codes connue. UnknownElementsInText = Le texte contient des \u00e9l\u00e9ments inconnus\u00a0: UnknownKeywordInRecord_2 = La lecture de \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9 faite, mais en ignorant certains enregistrements \u00e0 cause de mots-cl\u00e9s non reconnus: {1} UnparsableValueStoredAsText_2 = La valeur \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre interpr\u00e9t\u00e9e comme une instance de \u2018{0}\u2019. Elle est donc m\u00e9moris\u00e9e sous sa forme textuelle, mais sera ignor\u00e9e par certains traitements. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -27,7 +27,7 @@ import org.opengis.metadata.citation.Cit * <a href="http://www.epsg.org">EPSG</a> for Coordinate Reference System objects, or a * well-known acronym like ISBN for <cite>International Standard Book Number</cite>. * - * <p>When an identified object is marshalled in a ISO 19139 compliant XML document, some identifiers + * <p>When an identified object is marshalled in a ISO 19115-3 compliant XML document, some identifiers * are handled in a special way: they appear as {@code gml:id}, {@code gco:uuid} or {@code xlink:href} * attributes of the XML element. Those identifiers can be specified using the {@link IdentifierSpace} * enum values as below:</p> Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -25,7 +25,6 @@ import javax.xml.stream.XMLStreamExcepti import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stax.StAXSource; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.apache.sis.util.Static; @@ -37,7 +36,7 @@ import org.apache.sis.util.Static; * only when first needed, when initializing this class. * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.4 * @module */ @@ -55,7 +54,7 @@ final class InputFactory extends Static /* * Do not provide convenience method for java.io.File, because the caller needs to close the created - * input stream himself (this is not done by XMLStreamReader.close(), despite its method name). + * input stream himself (this is not done by XMLEventReader.close(), despite its method name). */ /** @@ -65,8 +64,8 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final InputStream in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(in); + public static XMLEventReader createXMLEventReader(final InputStream in) throws XMLStreamException { + return FACTORY.createXMLEventReader(in); } /** @@ -76,8 +75,8 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final Reader in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(in); + public static XMLEventReader createXMLEventReader(final Reader in) throws XMLStreamException { + return FACTORY.createXMLEventReader(in); } /** @@ -87,8 +86,8 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final InputSource in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(new SAXSource(in)); + public static XMLEventReader createXMLEventReader(final InputSource in) throws XMLStreamException { + return FACTORY.createXMLEventReader(new SAXSource(in)); } /** @@ -98,8 +97,8 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final XMLEventReader in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(new StAXSource(in)); + public static XMLEventReader createXMLEventReader(final XMLStreamReader in) throws XMLStreamException { + return FACTORY.createXMLEventReader(in); } /** @@ -109,8 +108,8 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final Node in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(new DOMSource(in)); + public static XMLEventReader createXMLEventReader(final Node in) throws XMLStreamException { + return FACTORY.createXMLEventReader(new DOMSource(in)); } /** @@ -120,7 +119,7 @@ final class InputFactory extends Static * @return the reader. * @throws XMLStreamException if the reader can not be created. */ - public static XMLStreamReader createXMLStreamReader(final Source in) throws XMLStreamException { - return FACTORY.createXMLStreamReader(in); + public static XMLEventReader createXMLEventReader(final Source in) throws XMLStreamException { + return FACTORY.createXMLEventReader(in); } } Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -26,7 +26,7 @@ import org.opengis.util.InternationalStr * Context of a marshalling or unmarshalling process. * * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ @@ -83,14 +83,9 @@ public abstract class MarshalContext { * * <table class="sis"> * <caption>Supported schemas</caption> - * <tr> - * <th>Prefix</th> - * <th>Standard</th> - * <th>Typical values</th> - * </tr> - * <tr> - * <td>gml</td> <td>Geographic Markup Language</td> <td>{@code 3.0}, {@code 3.2}</td> - * </tr> + * <tr><th>Prefix</th> <th>Standard</th> <th>Typical values</th></tr> + * <tr><td>gml</td> <td>Geographic Markup Language</td> <td>{@code 3.0}, {@code 3.2}</td></tr> + * <tr><td>gmd</td> <td>Geographic MetaData</td> <td>{@code 2007}, {@code 2016}</td></tr> * </table> * * @param prefix one of the above-cited prefix. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -22,6 +22,7 @@ import java.util.Locale; import javax.xml.XMLConstants; import org.apache.sis.util.Static; import org.apache.sis.util.ArgumentChecks; +import org.apache.sis.internal.jaxb.LegacyNamespaces; /** @@ -33,21 +34,44 @@ import org.apache.sis.util.ArgumentCheck * URLs determined by the SIS version available at compile-time, not runtime, because the * {@code javac} compiler inlines string constants.</p> * - * <p>The following table lists the URLs, their usual prefix, and the SIS versions when each URL changed.</p> + * <p>The following table lists some URLs, their usual prefix, and the SIS versions when each URL changed.</p> * <table class="sis"> * <caption>Namespaces and change log</caption> - * <tr><th>Prefix</th> <th>XML Namespace</th> <th>Changes history</th></tr> - * <tr><td>gco</td> <td>{@value #GCO}</td> <td></td></tr> - * <tr><td>gfc</td> <td>{@value #GFC}</td> <td></td></tr> - * <tr><td>gmd</td> <td>{@value #GMD}</td> <td></td></tr> - * <tr><td>gmi</td> <td>{@value #GMI}</td> <td></td></tr> - * <tr><td>srv</td> <td>{@value #SRV}</td> <td></td></tr> - * <tr><td>gts</td> <td>{@value #GTS}</td> <td></td></tr> - * <tr><td>gmx</td> <td>{@value #GMX}</td> <td></td></tr> - * <tr><td>gml</td> <td>{@value #GML}</td> <td>SIS 0.4</td></tr> - * <tr><td>csw</td> <td>{@value #CSW}</td> <td></td></tr> - * <tr><td>xsi</td> <td>{@value #XSI}</td> <td></td></tr> - * <tr><td>xlink</td> <td>{@value #XLINK}</td> <td></td></tr> + * <tr><th>Prefix</th> <th>Meaning</th> <th>XML Namespace</th> <th>Changes history</th></tr> + * <tr><td>lan</td> <td>Language localization</td> <td>{@value #LAN}</td> <td></td></tr> + * <tr><td>gco</td> <td>Geographic COmmon</td> <td>{@value #GCO}</td> <td>SIS 1.0</td></tr> + * <tr><td>mcc</td> <td>Metadata Common Classes</td> <td>{@value #MCC}</td> <td></td></tr> + * <tr><td>fcc</td> <td>Feature Catalog Common</td> <td>{@value #FCC}</td> <td></td></tr> + * <tr><td>gfc</td> <td>General Feature Catalog</td> <td>{@value #GFC}</td> <td>SIS 1.0</td></tr> + * <tr><td>cat</td> <td>CATalogue</td> <td>{@value #CAT}</td> <td></td></tr> + * <tr><td>mdb</td> <td>Metadata Base</td> <td>{@value #MDB}</td> <td></td></tr> + * <tr><td>cit</td> <td>Citation and responsible party information</td> <td>{@value #CIT}</td> <td></td></tr> + * <tr><td>gex</td> <td>Geospatial EXtent</td> <td>{@value #GEX}</td> <td></td></tr> + * <tr><td>rce</td> <td>Referencing By Coordinates Common</td> <td>{@value #RCE}</td> <td></td></tr> + * <tr><td>mrs</td> <td>Metadata for Reference System</td> <td>{@value #MRS}</td> <td></td></tr> + * <tr><td>msr</td> <td>Metadata for Spatial Representation</td> <td>{@value #MSR}</td> <td></td></tr> + * <tr><td>mrc</td> <td>Metadata for Resource Content</td> <td>{@value #MRC}</td> <td></td></tr> + * <tr><td>mri</td> <td>Metadata for Resource Identification</td> <td>{@value #MRI}</td> <td></td></tr> + * <tr><td>mrd</td> <td>Metadata for Resource Distribution</td> <td>{@value #MRD}</td> <td></td></tr> + * <tr><td>mdt</td> <td>Metadata for Data Transfer</td> <td>{@value #MDT}</td> <td></td></tr> + * <tr><td>mco</td> <td>Metadata for Constraints</td> <td>{@value #MCO}</td> <td></td></tr> + * <tr><td>mac</td> <td>Metadata for Acquisition</td> <td>{@value #MAC}</td> <td></td></tr> + * <tr><td>mrl</td> <td>Metadata for Resource Lineage</td> <td>{@value #MRL}</td> <td></td></tr> + * <tr><td>mmi</td> <td>Metadata for Maintenance Information</td> <td>{@value #MMI}</td> <td></td></tr> + * <tr><td>dqc</td> <td>Data Quality Common Classes</td> <td>{@value #DQC}</td> <td></td></tr> + * <tr><td>mdq</td> <td>Metadata for Data Quality</td> <td>{@value #MDQ}</td> <td></td></tr> + * <tr><td>mds</td> <td>Metadata for Data and Services</td> <td>{@value #MDS}</td> <td></td></tr> + * <tr><td>srv</td> <td>Metadata for Services</td> <td>{@value #SRV}</td> <td>SIS 1.0</td></tr> + * <tr><td>mpc</td> <td>Metadata for Portrayal Catalog</td> <td>{@value #MPC}</td> <td></td></tr> + * <tr><td>mda</td> <td>MetaData Application</td> <td>{@value #MDA}</td> <td></td></tr> + * <tr><td>mas</td> <td>Metadata for Application Schema</td> <td>{@value #MAS}</td> <td></td></tr> + * <tr><td>mex</td> <td>Metadata with Schema Extensions</td> <td>{@value #MEX}</td> <td></td></tr> + * <tr><td>gcx</td> <td>Geospatial Common eXtension</td> <td>{@value #GCX}</td> <td></td></tr> + * <tr><td>gmw</td> <td>Geographic Markup Wrappers</td> <td>{@value #GMW}</td> <td></td></tr> + * <tr><td>gml</td> <td>Geographic Markup Language</td> <td>{@value #GML}</td> <td>SIS 0.4</td></tr> + * <tr><td>csw</td> <td>Catalog Service for the Web</td> <td>{@value #CSW}</td> <td></td></tr> + * <tr><td>xsi</td> <td>XML Schema Instance information</td> <td>{@value #XSI}</td> <td></td></tr> + * <tr><td>xlink</td> <td>Link</td> <td>{@value #XLINK}</td> <td></td></tr> * </table> * * <div class="section">Profiles</div> @@ -61,8 +85,9 @@ import org.apache.sis.util.ArgumentCheck * * @author Cédric Briançon (Geomatys) * @author Quentin Boileau (Geomatys) - * @author Guilhem Legal (Geomatys) - * @version 0.4 + * @author Guilhem Legal (Geomatys) + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @@ -74,60 +99,390 @@ public final class Namespaces extends St } /** - * The <code>{@value}</code> URL. + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/lan/1.0/index.html">Language localization (LAN) version 1.0</a>. + * The usual prefix for this namespace is {@code "lan"}. + * + * @category ISO + * @since 1.0 + */ + public static final String LAN = "http://standards.iso.org/iso/19115/-3/lan/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/gco/1.0/index.html">Geographic COmmon (GCO) version 1.0</a>. * The usual prefix for this namespace is {@code "gco"}. * + * <p>History</p> + * <table class="sis"> + * <caption>Change log</caption> + * <tr><th>SIS version</th> <th>URL</th></tr> + * <tr><td>0.3 to 0.8</td> <td>http://www.isotc211.org/2005/gco</td></tr> + * <tr><td>Since 1.0</td> <td>http://standards.iso.org/iso/19115/-3/gco/1.0</td></tr> + * </table> + * * @category ISO */ - public static final String GCO = "http://www.isotc211.org/2005/gco"; + public static final String GCO = "http://standards.iso.org/iso/19115/-3/gco/1.0"; /** - * The <code>{@value}</code> URL. + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mcc/1.0/index.html">Metadata Common Classes (MCC) version 1.0</a>. + * The usual prefix for this namespace is {@code "mcc"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MCC = "http://standards.iso.org/iso/19115/-3/mcc/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19110/fcc/1.0/index.html">Feature Catalog Common (FCC) version 1.0</a>. + * The usual prefix for this namespace is {@code "fcc"}. + * + * @category ISO + * @since 1.0 + */ + public static final String FCC = "http://standards.iso.org/iso/19110/fcc/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19110/gfc/1.1/index.html">General Feature Catalog (GFC) version 1.1</a>. * The usual prefix for this namespace is {@code "gfc"}. * + * <p>History</p> + * <table class="sis"> + * <caption>Change log</caption> + * <tr><th>SIS version</th> <th>URL</th></tr> + * <tr><td>0.3 to 0.8</td> <td>http://www.isotc211.org/2005/gfc</td></tr> + * <tr><td>Since 1.0</td> <td>http://standards.iso.org/iso/19110/gfc/1.1</td></tr> + * </table> + * * @category ISO */ - public static final String GFC = "http://www.isotc211.org/2005/gfc"; + public static final String GFC = "http://standards.iso.org/iso/19110/gfc/1.1"; /** - * The <code>{@value}</code> URL. - * The usual prefix for this namespace is {@code "gmd"}. + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/cat/1.0/index.html">CATalogue (CAT) version 1.0</a>. + * The usual prefix for this namespace is {@code "cat"}. * * @category ISO + * @since 1.0 */ - public static final String GMD = "http://www.isotc211.org/2005/gmd"; + public static final String CAT = "http://standards.iso.org/iso/19115/-3/cat/1.0"; /** - * The <code>{@value}</code> URL. - * The usual prefix for this namespace is {@code "gmi"}. + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mdb/1.0/index.html">Metadata Base (MDB) version 1.0</a>. + * The usual prefix for this namespace is {@code "mdb"}. * * @category ISO + * @since 1.0 */ - public static final String GMI = "http://www.isotc211.org/2005/gmi"; + public static final String MDB = "http://standards.iso.org/iso/19115/-3/mdb/1.0"; /** - * The <code>{@value}</code> URL. + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/cit/1.0/index.html">Citation and responsible party information (CIT) version 1.0</a>. + * The usual prefix for this namespace is {@code "cit"}. + * + * @category ISO + * @since 1.0 + */ + public static final String CIT = "http://standards.iso.org/iso/19115/-3/cit/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/gex/1.0/index.html">Geospatial EXtent (GEX) version 1.0</a>. + * The usual prefix for this namespace is {@code "gex"}. + * + * @category ISO + * @since 1.0 + */ + public static final String GEX = "http://standards.iso.org/iso/19115/-3/gex/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mrs/1.0/index.html">Metadata for Reference System (MRS) version 1.0</a>. + * The usual prefix for this namespace is {@code "mrs"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MRS = "http://standards.iso.org/iso/19115/-3/mrs/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19111/rce/1.0/index.html">Referencing By Coordinates Common (RCE) version 1.0</a>. + * The usual prefix for this namespace is {@code "rce"}. + * + * @category ISO + * @since 1.0 + */ + public static final String RCE = "http://standards.iso.org/iso/19111/rce/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/msr/1.0/index.html">Metadata for Spatial Representation (MSR) version 1.0</a>. + * The usual prefix for this namespace is {@code "msr"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MSR = "http://standards.iso.org/iso/19115/-3/msr/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mrc/1.0/index.html">Metadata for Resource Content (MRC) version 1.0</a>. + * The usual prefix for this namespace is {@code "mrc"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MRC = "http://standards.iso.org/iso/19115/-3/mrc/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mri/1.0/index.html">Metadata for Resource Identification (MRI) version 1.0</a>. + * The usual prefix for this namespace is {@code "mri"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MRI = "http://standards.iso.org/iso/19115/-3/mri/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mrd/1.0/index.html">Metadata for Resource Distribution (MRD) version 1.0</a>. + * The usual prefix for this namespace is {@code "mrd"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MRD = "http://standards.iso.org/iso/19115/-3/mrd/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mdt/1.0/index.html">Metadata for Data Transfer (MDT) version 1.0</a>. + * The usual prefix for this namespace is {@code "mdt"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MDT = "http://standards.iso.org/iso/19115/-3/mdt/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mco/1.0/index.html">Metadata for Constraints (MCO) version 1.0</a>. + * The usual prefix for this namespace is {@code "mco"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MCO = "http://standards.iso.org/iso/19115/-3/mco/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mac/1.0/index.html">Metadata for Acquisition (MAC) version 1.0</a>. + * The usual prefix for this namespace is {@code "mac"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MAC = "http://standards.iso.org/iso/19115/-3/mac/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mrl/1.0/index.html">Metadata for Resource Lineage (MRL) version 1.0</a>. + * The usual prefix for this namespace is {@code "mrl"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MRL = "http://standards.iso.org/iso/19115/-3/mrl/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mmi/1.0/index.html">Metadata for Maintenance Information (MMI) version 1.0</a>. + * The usual prefix for this namespace is {@code "mmi"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MMI = "http://standards.iso.org/iso/19115/-3/mmi/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19157/-2/dqc/1.0/index.html">Data Quality Common Classes (DQC) version 1.0</a>. + * The usual prefix for this namespace is {@code "dqc"}. + * + * @category ISO + * @since 1.0 + */ + public static final String DQC = "http://standards.iso.org/iso/19157/-2/dqc/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19157/-2/mdq/1.0/index.html">Metadata for Data Quality (MDQ) version 1.0</a>. + * The usual prefix for this namespace is {@code "mdq"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MDQ = "http://standards.iso.org/iso/19157/-2/mdq/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mds/1.0/index.html">Metadata for Data and Services (MDS) version 1.0</a>. + * The usual prefix for this namespace is {@code "mds"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MDS = "http://standards.iso.org/iso/19115/-3/mds/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/srv/2.0/index.html">Metadata for Services (SRV) version 2.0</a>. * The usual prefix for this namespace is {@code "srv"}. * + * <p>History</p> + * <table class="sis"> + * <caption>Change log</caption> + * <tr><th>SIS version</th> <th>URL</th></tr> + * <tr><td>0.3 to 0.8</td> <td>http://www.isotc211.org/2005/srv</td></tr> + * <tr><td>Since 1.0</td> <td>http://standards.iso.org/iso/19115/-3/srv/2.0</td></tr> + * </table> + * + * @category ISO + * @since 1.0 + */ + public static final String SRV = "http://standards.iso.org/iso/19115/-3/srv/2.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mpc/1.0/index.html">Metadata for Portrayal Catalog (MPC) version 1.0</a>. + * The usual prefix for this namespace is {@code "mpc"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MPC = "http://standards.iso.org/iso/19115/-3/mpc/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mda/1.0/index.html">MetaData Application (MDA) version 1.0</a>. + * The usual prefix for this namespace is {@code "mda"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MDA = "http://standards.iso.org/iso/19115/-3/mda/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mas/1.0/index.html">Metadata for Application Schema (MAS) version 1.0</a>. + * The usual prefix for this namespace is {@code "mas"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MAS = "http://standards.iso.org/iso/19115/-3/mas/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/mex/1.0/index.html">Metadata with Schema Extensions (MEX) version 1.0</a>. + * The usual prefix for this namespace is {@code "mex"}. + * * @category ISO + * @since 1.0 */ - public static final String SRV = "http://www.isotc211.org/2005/srv"; + public static final String MEX = "http://standards.iso.org/iso/19115/-3/mex/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/gcx/1.0/index.html">Geospatial Common eXtension (GCX) version 1.0</a>. + * The usual prefix for this namespace is {@code "gcx"}. + * + * @category ISO + * @since 1.0 + */ + public static final String GCX = "http://standards.iso.org/iso/19115/-3/gcx/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/md1/1.0/index.html">Metadata for Data and Services with Geospatial Common Extensions (MD1) version 1.0</a>. + * The usual prefix for this namespace is {@code "md1"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MD1 = "http://standards.iso.org/iso/19115/-3/md1/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/md2/1.0/index.html">Metadata for Data and Services with Geospatial Common Extensions (MD2) version 1.0</a>. + * The usual prefix for this namespace is {@code "md2"}. + * + * @category ISO + * @since 1.0 + */ + public static final String MD2 = "http://standards.iso.org/iso/19115/-3/md2/1.0"; + + /** + * The <code>{@value}</code> URL. This is the namespace of + * <a href="http://standards.iso.org/iso/19115/-3/gmw/1.0/index.html">Geographic Markup Wrappers (GMW) version 1.0</a>. + * The usual prefix for this namespace is {@code "gmw"}. + * + * @category ISO + * @since 1.0 + */ + public static final String GMW = "http://standards.iso.org/iso/19115/-3/gmw/1.0"; /** * The <code>{@value}</code> URL. - * The usual prefix for this namespace is {@code "gts"}. + * The usual prefix for this namespace is {@code "gmd"}. + * + * @category ISO + * + * @deprecated as of ISO 19115-3, splitted in many different namespaces. + */ + @Deprecated + public static final String GMD = LegacyNamespaces.GMD; + + /** + * The <code>{@value}</code> URL. + * The usual prefix for this namespace is {@code "gmi"}. * * @category ISO + * + * @deprecated as of ISO 19115-4, splitted in many different namespaces. */ - public static final String GTS = "http://www.isotc211.org/2005/gts"; + @Deprecated + public static final String GMI = LegacyNamespaces.GMI; /** * The <code>{@value}</code> URL. * The usual prefix for this namespace is {@code "gmx"}. * * @category ISO + * + * @deprecated as of ISO 19115-3, splitted in many different namespaces. */ - public static final String GMX = "http://www.isotc211.org/2005/gmx"; + @Deprecated + public static final String GMX = LegacyNamespaces.GMX; + + /** + * The <code>{@value}</code> URL. + * The usual prefix for this namespace is {@code "gts"}. + * + * @category ISO + * + * @deprecated as of ISO 19115-3, splitted in many different namespaces. + */ + @Deprecated + public static final String GTS = LegacyNamespaces.GTS; /** * The <code>{@value}</code> URL. @@ -139,6 +494,7 @@ public final class Namespaces extends St * <caption>Change log</caption> * <tr><th>SIS version</th> <th>URL</th></tr> * <tr><td>0.3</td> <td>http://www.opengis.net/gml</td></tr> + * <tr><td>Since 0.4</td> <td>http://www.opengis.net/gml/3.2</td></tr> * </table> * * @category OGC @@ -175,6 +531,11 @@ public final class Namespaces extends St * URLs for which the prefix to use directly follows them. */ private static final String[] GENERIC_URLS = { + "http://standards.iso.org/iso/19115/-3/", + "http://standards.iso.org/iso/19115/-2/", + "http://standards.iso.org/iso/19157/-2/", + "http://standards.iso.org/iso/19111/", + "http://standards.iso.org/iso/19110/", "http://www.isotc211.org/2005/", "http://www.opengis.net/", "http://www.w3.org/1999/", @@ -189,7 +550,7 @@ public final class Namespaces extends St private static final Map<String,String> SPECIFIC_URLS; static { final Map<String,String> p = new HashMap<>(40); - p.put(XMLConstants.W3C_XML_SCHEMA_NS_URI, "xsd"); // TODO: should be "xs". + p.put(XMLConstants.W3C_XML_SCHEMA_NS_URI, "xs"); p.put(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi"); p.put("http://www.w3.org/2004/02/skos/core#", "skos"); p.put("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf"); @@ -205,6 +566,8 @@ public final class Namespaces extends St p.put("http://www.opengis.net/citygml/building/1.0", "build"); p.put("http://www.opengis.net/citygml/cityfurniture/1.0", "furniture"); p.put("http://www.opengis.net/citygml/transportation/1.0", "tr"); + p.put("http://www.isotc211.org/2005/gco", "gcol"); // "l" for "legacy" (prior version 1). + p.put("http://www.isotc211.org/2005/srv", "srv1"); p.put("http://www.purl.org/dc/elements/1.1/", "dc2"); p.put("http://www.purl.org/dc/terms/", "dct2"); p.put("http://purl.org/dc/terms/", "dct"); @@ -223,7 +586,7 @@ public final class Namespaces extends St * Returns the preferred prefix for the given namespace URI. * * @param namespace the namespace URI for which the prefix needs to be found. Can not be {@code null}. - * @param defaultValue the default prefix to returned if the given {@code namespace} is not recognized, + * @param defaultValue the default prefix to return if the given {@code namespace} is not recognized, * or {@code null}. * @return the prefix inferred from the namespace URI, or {@code null} if the given namespace is unrecognized * and the {@code defaultValue} is null. @@ -249,4 +612,54 @@ public final class Namespaces extends St } return defaultValue; } + + /** + * Guesses the namespace for a type of the given ISO name. The argument given to this method + * must be a class name defined by ISO 19115 or other standards to be added in the future. + * Those ISO class names usually start with a two letter prefix, e.g. {@code "CI"} + * in {@link org.apache.sis.metadata.iso.citation.DefaultCitation CI_Citation}. + * + * <p>This method uses heuristic rules, first looking at the prefix, then the rest of the name in case of ambiguity. + * A namespace is returned on a <em>best effort</em> basis only; this method may or may not check the full name, and + * values returned by this method may change in future SIS versions (e.g. when new standards become supported by SIS + * or when existing standards are upgraded). This method should be used in last resort only, when this information + * can not be obtained easily in a more reliable way.</p> + * + * @param type a class name defined by ISO 19115 or related standards (e.g. {@code "CI_Citation"}. + * @return a <em>possible</em> namespace for the given type, or {@code null} if unknown. + * + * @since 1.0 + */ + public static String guessForType(final String type) { + /* + * Implementation note: we could invoke TransformingReader.namespace(type) unconditionally, + * but that method may be removed in a future SIS version if we replace TransformingReader + * by XSD (https://issues.apache.org/jira/projects/SIS/issues/SIS-381). By using a switch now, + * we reduce the behavioral change is SIS-381 is applied. It can also reduce classes loading. + */ + if (type != null && type.length() >= 3) { + if (type.charAt(2) == '_') { + switch ((type.charAt(0) << Character.SIZE) | type.charAt(1)) { + case ('C' << Character.SIZE) | 'I': return CIT; + case ('E' << Character.SIZE) | 'X': return GEX; + case ('F' << Character.SIZE) | 'C': return GFC; + case ('L' << Character.SIZE) | 'E': + case ('L' << Character.SIZE) | 'I': return MRL; + case ('D' << Character.SIZE) | 'S': // Usually MDA except for DS_InitiativeTypeCode + case ('M' << Character.SIZE) | 'D': + case ('M' << Character.SIZE) | 'I': return TransformingReader.namespace(type); + case ('M' << Character.SIZE) | 'X': return MDT; + case ('P' << Character.SIZE) | 'T': return LAN; + case ('S' << Character.SIZE) | 'V': return SRV; + case ('C' << Character.SIZE) | 'S': + case ('C' << Character.SIZE) | 'D': + case ('S' << Character.SIZE) | 'C': return GML; + } + } else { + // Needs to handle at least DCPList + return TransformingReader.namespace(type); + } + } + return null; + } } Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -27,8 +27,8 @@ package org.apache.sis.xml; * ({@link NilReason#UNKNOWN UNKNOW}), the information may not exist at all ({@link NilReason#MISSING * MISSING}) or can not be divulged ({@link NilReason#WITHHELD WITHHELD}). * - * <p>Nil objects appear most frequently in XML documents since if a mandatory ISO 19115 attribute - * is absent, then the ISO 19139 standard requires us to said why it is so. The following example + * <p>Nil objects appear most frequently in XML documents because if a mandatory ISO 19115-1 attribute + * is absent, then the ISO 19115-3 standard requires us to said why it is absent. The following example * shows a {@code CI_Citation} fragment with an ordinary {@code CI_Series} element on the left side, * and an unknown {@code CI_Series} element on the right side:</p> * Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -37,7 +37,7 @@ import org.apache.sis.util.Static; * only when first needed, when initializing this class. * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.4 * @module */ @@ -55,7 +55,7 @@ final class OutputFactory extends Static /* * Do not provide convenience method for java.io.File, because the caller needs to close the created - * output stream himself (this is not done by XMLStreamWriter.close(), despite its method name). + * output stream himself (this is not done by XMLEventWriter.close(), despite its method name). */ /** @@ -66,8 +66,8 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(OutputStream out, String encoding) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(out, encoding); + public static XMLEventWriter createXMLEventWriter(OutputStream out, String encoding) throws XMLStreamException { + return FACTORY.createXMLEventWriter(out, encoding); } /** @@ -77,8 +77,8 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(final Writer out) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(out); + public static XMLEventWriter createXMLEventWriter(final Writer out) throws XMLStreamException { + return FACTORY.createXMLEventWriter(out); } /** @@ -89,8 +89,8 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(final ContentHandler out) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(new SAXResult(out)); + public static XMLEventWriter createXMLEventWriter(final ContentHandler out) throws XMLStreamException { + return FACTORY.createXMLEventWriter(new SAXResult(out)); } /** @@ -101,8 +101,8 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(final Node out) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(new DOMResult(out)); + public static XMLEventWriter createXMLEventWriter(final Node out) throws XMLStreamException { + return FACTORY.createXMLEventWriter(new DOMResult(out)); } /** @@ -113,8 +113,8 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(final XMLEventWriter out) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(new StAXResult(out)); + public static XMLEventWriter createXMLEventWriter(final XMLStreamWriter out) throws XMLStreamException { + return FACTORY.createXMLEventWriter(new StAXResult(out)); } /** @@ -125,7 +125,7 @@ final class OutputFactory extends Static * @return the writer. * @throws XMLStreamException if the writer can not be created. */ - public static XMLStreamWriter createXMLStreamWriter(final Result out) throws XMLStreamException { - return FACTORY.createXMLStreamWriter(out); + public static XMLEventWriter createXMLEventWriter(final Result out) throws XMLStreamException { + return FACTORY.createXMLEventWriter(out); } }
