You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/02/26 11:28:20 UTC
svn commit: r1825355 [13/15] - in /sis/trunk: ./
application/sis-console/src/test/java/org/apache/sis/console/
core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/
core/sis-metadata/ core/sis-metadata/src/main/java/org/apache/sis/inte...
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] Mon Feb 26 11:28:17 2018
@@ -20,6 +20,7 @@ import java.util.Date;
import org.apache.sis.internal.geoapi.temporal.Instant;
import org.apache.sis.internal.geoapi.temporal.Period;
import org.apache.sis.internal.geoapi.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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties [ISO-8859-1] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties [ISO-8859-1] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java [UTF-8] Mon Feb 26 11:28:17 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);
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] Mon Feb 26 11:28:17 2018
@@ -49,7 +49,8 @@ import org.apache.sis.internal.jaxb.Type
* "endorsed JAR" names if needed.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @author Cullen Rombach (Image Matters)
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -58,7 +59,7 @@ abstract class Pooled {
* The keys of entries that can be stored in the {@link #schemas} map.
* Those keys are documented in {@link XML#SCHEMAS}.
*/
- private static final String[] SCHEMA_KEYS = {"gmd"};
+ private static final String[] SCHEMA_KEYS = {"cat", "gmd"};
/**
* {@code true} if the JAXB implementation is the one bundled in JDK 6, or {@code false}
@@ -105,35 +106,27 @@ abstract class Pooled {
private TimeZone timezone;
/**
- * The base URL of ISO 19139 (or other standards) schemas. It shall be an unmodifiable
+ * The base URL of ISO 19115-3 (or other standards) schemas. It shall be an unmodifiable
* instance because {@link #getProperty(String)} returns a direct reference to the user.
* The valid values are documented in the {@link XML#SCHEMAS} property.
*/
private Map<String,String> schemas;
/**
- * Whether {@link FilteredNamespaces} shall be used of not. Values can be:
- *
- * <ul>
- * <li>0 for the default behavior, which applies namespace replacements only if the {@link XML#GML_VERSION}
- * property is set to an older value than the one supported natively by SIS.</li>
- * <li>1 for forcing namespace replacements at unmarshalling time. This is useful for reading a XML document
- * of unknown GML version.</li>
- * <li>2 for disabling namespace replacements. XML (un)marshalling will use the namespaces URI supported
- * natively by SIS as declared in JAXB annotations. This is sometime useful for debugging purpose.</li>
- * </ul>
+ * The GML version to be marshalled or unmarshalled, or {@code null} if unspecified.
+ * If null, then the latest version is assumed.
*
- * @see LegacyNamespaces#APPLY_NAMESPACE_REPLACEMENTS
+ * @see Context#getVersion(String)
*/
- private byte xmlnsReplaceCode;
+ private Version versionGML;
/**
- * The GML version to be marshalled or unmarshalled, or {@code null} if unspecified.
+ * The metadata version to be marshalled or unmarshalled, or {@code null} if unspecified.
* If null, then the latest version is assumed.
*
* @see Context#getVersion(String)
*/
- private Version versionGML;
+ private Version versionMetadata;
/**
* The reference resolver to use during unmarshalling.
@@ -222,8 +215,8 @@ abstract class Pooled {
locale = template.locale;
timezone = template.timezone;
schemas = template.schemas;
- xmlnsReplaceCode = template.xmlnsReplaceCode;
versionGML = template.versionGML;
+ versionMetadata = template.versionMetadata;
resolver = template.resolver;
converter = template.converter;
rootAdapters = template.rootAdapters;
@@ -248,35 +241,35 @@ abstract class Pooled {
protected abstract void reset(final Object key, final Object value) throws JAXBException;
/**
- * Returns the {@code FilterVersion} enumeration value to use for the current GML version, or
- * {@code null} if the SIS native version is suitable. If this method returns a non-null value,
- * then the output generated by JAXB will need to go through a {@link FilteredStreamWriter}
- * in order to replace the namespace of the GML version implemented by SIS by the namespace of
- * the GML version asked by the user.
- *
- * @see FilteredNamespaces
- */
- final FilterVersion getFilterVersion() {
- switch (xmlnsReplaceCode) {
- case 0: {
- // Apply namespace replacements only for older versions than the one supported natively by SIS.
- if (versionGML != null) {
- if (versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) {
- return FilterVersion.GML31;
- }
- }
- break;
- }
- case 1: {
- // Force namespace replacements at unmarshalling time (illegal for marshalling).
- if ((bitMasks & Context.MARSHALLING) == 0) {
- return FilterVersion.ALL;
- }
- break;
- }
- // case 2: disable namespace replacements.
+ * Returns the {@code TransformVersion} enumeration value to use for the current GML or metadata version,
+ * or {@code null} if the SIS native versions are suitable. If this method returns a non-null value, then
+ * the output generated by JAXB will need to go through a {@link TransformingWriter} in order to replace
+ * the namespace of versions implemented by SIS by the namespace of versions requested by the user.
+ *
+ * @see Transformer
+ */
+ final TransformVersion getTransformVersion() {
+ /*
+ * If no version is specified, then the default behavior will be:
+ * - enable namespace replacement on unmarshalling (in order to accept all versions)
+ * - disable namespace replacement on marshalling (in order to use latest version).
+ */
+ final boolean byDefault = (bitMasks & Context.MARSHALLING) == 0;
+ /*
+ * Bitwise combination of legacy schemas to support:
+ * 1: namespace replacement needed for GML
+ * 2: namespace replacement needed for metadata.
+ */
+ int combine = (specificBitMasks() & Context.LEGACY_METADATA) != 0 ? 2 : 0;
+ if (versionGML == null ? byDefault : versionGML .compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) combine = 1;
+ if (versionMetadata == null ? byDefault : versionMetadata.compareTo(LegacyNamespaces.VERSION_2014) < 0) combine |= 2;
+ switch (combine) {
+ case 0: return null;
+ case 1: return TransformVersion.GML31;
+ case 2: return TransformVersion.ISO19139;
+ case 3: return TransformVersion.ALL;
+ default: throw new AssertionError(combine); // Should never happen.
}
- return null;
}
/**
@@ -343,6 +336,10 @@ abstract class Pooled {
versionGML = (value instanceof CharSequence) ? new Version(value.toString()) : (Version) value;
return;
}
+ case XML.METADATA_VERSION: {
+ versionMetadata = (value instanceof CharSequence) ? new Version(value.toString()) : (Version) value;
+ return;
+ }
case XML.RESOLVER: {
resolver = (ReferenceResolver) value;
return;
@@ -375,13 +372,6 @@ abstract class Pooled {
warningListener = (WarningListener<?>) value;
return;
}
- case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
- xmlnsReplaceCode = 0;
- if (value != null) {
- xmlnsReplaceCode = ((Boolean) value) ? (byte) 1 : (byte) 2;
- }
- return;
- }
case TypeRegistration.ROOT_ADAPTERS: {
rootAdapters = (TypeRegistration[]) value;
// No clone for now because ROOT_ADAPTERS is not yet a public API.
@@ -416,6 +406,7 @@ abstract class Pooled {
case XML.TIMEZONE: return timezone;
case XML.SCHEMAS: return schemas;
case XML.GML_VERSION: return versionGML;
+ case XML.METADATA_VERSION: return versionMetadata;
case XML.RESOLVER: return resolver;
case XML.CONVERTER: return converter;
case XML.WARNING_LISTENER: return warningListener;
@@ -428,13 +419,6 @@ abstract class Pooled {
if ((bitMasks & Context.SUBSTITUTE_MIMETYPE) != 0) substitutes[n++] = "mimetype";
return (n != 0) ? ArraysExt.resize(substitutes, n) : null;
}
- case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
- switch (xmlnsReplaceCode) {
- case 1: return Boolean.TRUE;
- case 2: return Boolean.FALSE;
- default: return null;
- }
- }
case TypeRegistration.ROOT_ADAPTERS: return (rootAdapters != null) ? rootAdapters.clone() : null;
default: {
if (internal) {
@@ -531,6 +515,20 @@ abstract class Pooled {
public abstract ValidationEventHandler getEventHandler() throws JAXBException;
/**
+ * Returns bit masks specific to the object being marshalled. This mask will be combined with the
+ * bit masks managed by the {@link Pooled} base class. This is used mostly for mandating legacy
+ * metadata format (ISO 19139:2007) for some object to marshal.
+ *
+ * <p>This is a hopefully temporary hack for marshalling metadata in GML.
+ * May be deleted if we implement SIS-401.</p>
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-401">SIS-401</a>
+ */
+ int specificBitMasks() {
+ return 0;
+ }
+
+ /**
* Must be invoked by subclasses before a {@code try} block performing a (un)marshalling
* operation. Must be followed by a call to {@code finish()} in a {@code finally} block.
*
@@ -546,6 +544,7 @@ abstract class Pooled {
* @see Context#finish()
*/
final Context begin() {
- return new Context(bitMasks, locale, timezone, schemas, versionGML, resolver, converter, warningListener);
+ return new Context(bitMasks | specificBitMasks(), locale, timezone,
+ schemas, versionGML, versionMetadata, resolver, converter, warningListener);
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java?rev=1825355&r1=1825354&r2=1825355&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java [UTF-8] Mon Feb 26 11:28:17 2018
@@ -37,6 +37,7 @@ import org.xml.sax.ContentHandler;
import org.w3c.dom.Node;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.TypeRegistration;
+import org.apache.sis.internal.jaxb.UseLegacyMetadata;
/**
@@ -48,12 +49,12 @@ import org.apache.sis.internal.jaxb.Type
* when the marshaller is recycled.</li>
* <li>Constructs a SIS {@link Context} object on marshalling, in order to give
* additional information to the SIS object being marshalled.</li>
- * <li>Wraps the output stream in a {@link FilteredStreamWriter} if the desired GML version
+ * <li>Wraps the output stream in a {@link TransformingWriter} if the desired GML version
* in not the SIS native GML version.</li>
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -64,6 +65,13 @@ final class PooledMarshaller extends Poo
private final Marshaller marshaller;
/**
+ * Bit masks specific to the object being marshalled. This mask will be combined with the
+ * bit masks managed by the {@link Pooled} base class. This is used mostly for mandating
+ * legacy metadata format (ISO 19139:2007) for some object to marshal.
+ */
+ private int specificBitMasks;
+
+ /**
* Creates a pooled marshaller wrapping the given one.
* Callers shall invoke {@link #reset(Pooled)} after construction for completing the initialization.
*
@@ -115,11 +123,23 @@ final class PooledMarshaller extends Poo
}
/**
+ * Returns a non-zero bitmask if the object given in last call to {@link #toImplementation(Object)} should use
+ * legacy metadata. This is a hack for marshalling metadata in GML. May be deleted if we implement SIS-401.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-401">SIS-401</a>
+ */
+ @Override
+ final int specificBitMasks() {
+ return specificBitMasks;
+ }
+
+ /**
* Converts the given arbitrary object to an implementation having JAXB annotations.
* If the given object is not recognized or is already an instance of the expected class,
* then it is returned unchanged.
*/
private Object toImplementation(final Object value) throws JAXBException {
+ specificBitMasks = value.getClass().isAnnotationPresent(UseLegacyMetadata.class) ? Context.LEGACY_METADATA : 0;
final TypeRegistration[] converters = getRootAdapters();
if (converters != null) {
for (final TypeRegistration t : converters) {
@@ -132,21 +152,20 @@ final class PooledMarshaller extends Poo
/**
* Marshals to the given output with on-the-fly substitution of namespaces.
- * This method is invoked only when the user asked to marshal to a different GML version
- * than the one supported natively by SIS, i.e. when {@link #getFilterVersion()} returns
- * a non-null value.
+ * This method is invoked when the user asked to marshal to a different GML or metadata version than the
+ * one supported natively by SIS, i.e. when {@link #getTransformVersion()} returns a non-null value.
*
- * @param object the object to marshall.
+ * @param object the object to marshal.
* @param output the writer created by SIS (<b>not</b> the writer given by the user).
* @param version identifies the namespace substitutions to perform.
*/
- private void marshal(final Object object, XMLStreamWriter output, final FilterVersion version)
+ private void marshal(Object object, XMLEventWriter output, final TransformVersion version)
throws XMLStreamException, JAXBException
{
- output = new FilteredStreamWriter(output, version);
+ output = new TransformingWriter(output, version);
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -157,17 +176,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final Result output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final Result output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -178,17 +198,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final OutputStream output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final OutputStream output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output, getEncoding()), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output, getEncoding()), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -199,11 +220,12 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final File output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final File output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
try (OutputStream s = new BufferedOutputStream(new FileOutputStream(output))) {
- marshal(object, OutputFactory.createXMLStreamWriter(s, getEncoding()), version);
+ marshal(object, OutputFactory.createXMLEventWriter(s, getEncoding()), version);
}
} catch (IOException | XMLStreamException e) {
throw new JAXBException(e);
@@ -211,7 +233,7 @@ final class PooledMarshaller extends Poo
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -222,17 +244,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final Writer output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final Writer output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -243,17 +266,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final ContentHandler output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final ContentHandler output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -264,17 +288,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, final Node output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final Node output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -285,34 +310,18 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public void marshal(final Object object, XMLStreamWriter output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
- if (version != null) {
- output = new FilteredStreamWriter(output, version);
- }
- final Context context = begin();
- try {
- marshaller.marshal(toImplementation(object), output);
- } finally {
- context.finish();
- }
- }
-
- /**
- * Delegates the marshalling to the wrapped marshaller.
- */
- @Override
- public void marshal(final Object object, final XMLEventWriter output) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, final XMLStreamWriter output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
- marshal(object, OutputFactory.createXMLStreamWriter(output), version);
+ marshal(object, OutputFactory.createXMLEventWriter(output), version);
} catch (XMLStreamException e) {
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
final Context context = begin();
try {
- marshaller.marshal(toImplementation(object), output);
+ marshaller.marshal(object, output);
} finally {
context.finish();
}
@@ -323,15 +332,34 @@ final class PooledMarshaller extends Poo
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
- public Node getNode(final Object object) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ public void marshal(Object object, XMLEventWriter output) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
+ if (version != null) {
+ output = new TransformingWriter(output, version);
+ }
+ final Context context = begin();
+ try {
+ marshaller.marshal(object, output);
+ } finally {
+ context.finish();
+ }
+ }
+
+ /**
+ * Delegates the marshalling to the wrapped marshaller.
+ */
+ @Override
+ public Node getNode(Object object) throws JAXBException {
+ object = toImplementation(object); // Must be call before getTransformVersion()
+ final TransformVersion version = getTransformVersion();
if (version != null) {
// This exception is thrown by javax.xml.bind.helpers.AbstractMarshallerImpl anyway.
throw new UnsupportedOperationException();
} else {
final Context context = begin();
try {
- return marshaller.getNode(toImplementation(object));
+ return marshaller.getNode(object);
} finally {
context.finish();
}