Author: desruisseaux
Date: Thu Oct 8 20:16:20 2015
New Revision: 1707616
URL: http://svn.apache.org/viewvc?rev=1707616&view=rev
Log:
Emit a warning of no object is found for a xlink:href.
Add some documentation.
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
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=1707616&r1=1707615&r2=1707616&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] Thu Oct 8 20:16:20 2015
@@ -746,6 +746,11 @@ public final class Errors extends Indexe
public static final short NonUniformScale = 88;
/**
+ * No element for the “{0}” identifier, or the identifier is a forward reference.
+ */
+ public static final short NotABackwardReference_1 = 199;
+
+ /**
* Argument ‘{0}’ shall not be NaN (Not-a-Number).
*/
public static final short NotANumber_1 = 89;
@@ -916,6 +921,11 @@ public final class Errors extends Indexe
public static final short UnexpectedParameter_1 = 152;
/**
+ * Expected “{0}” to reference an instance of ‘{1}’, but found an instance of ‘{2}’.
+ */
+ public static final short UnexpectedTypeForReference_3 = 200;
+
+ /**
* Unexpected value “{1}” in “{0}” element.
*/
public static final short UnexpectedValueInElement_2 = 191;
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=1707616&r1=1707615&r2=1707616&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] Thu Oct 8 20:16:20 2015
@@ -155,6 +155,7 @@ NonPerpendicularDirections_2 = Axis
NonScaleUnit_1 = \u201c{0}\u201d is not a scale unit.
NonTemporalUnit_1 = \u201c{0}\u201d is not a time unit.
NonUniformScale = Scale is not uniform.
+NotABackwardReference_1 = No element for the \u201c{0}\u201d identifier, or the identifier is a forward reference.
NotAnAffineTransform = Transform is not affine.
NotANumber_1 = Argument \u2018{0}\u2019 shall not be NaN (Not-a-Number).
NotAPrimitiveWrapper_1 = Class \u2018{0}\u2019 is not a primitive type wrapper.
@@ -194,6 +195,7 @@ UnexpectedEndOfFile_1 = Unex
UnexpectedEndOfString_1 = More characters were expected at the end of \u201c{0}\u201d.
UnexpectedFileFormat_2 = File \u201c{1}\u201d seems to be encoded in an other format than {0}.
UnexpectedParameter_1 = Parameter \u201c{0}\u201d was not expected.
+UnexpectedTypeForReference_3 = Expected \u201c{0}\u201d to reference an instance of \u2018{1}\u2019, but found an instance of \u2018{2}\u2019.
UnexpectedValueInElement_2 = Unexpected value \u201c{1}\u201d in \u201c{0}\u201d element.
UnitlessParameter_1 = Parameter \u201c{0}\u201d has no unit.
UnknownAuthority_1 = Authority \u201c{0}\u201d is unknown.
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=1707616&r1=1707615&r2=1707616&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] Thu Oct 8 20:16:20 2015
@@ -152,6 +152,7 @@ NonPerpendicularDirections_2 = Les
NonScaleUnit_1 = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas une unit\u00e9 d\u2019\u00e9chelles.
NonTemporalUnit_1 = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas une unit\u00e9 de temps.
NonUniformScale = L\u2019\u00e9chelle n\u2019est pas uniforme.
+NotABackwardReference_1 = Il n\u2019y a pas d\u2019\u00e9l\u00e9ment pour l\u2019identifiant \u201c{0}\u201d, ou l\u2019identifiant est une r\u00e9f\u00e9rence vers l\u2019avant.
NotAnAffineTransform = La transformation n\u2019est pas affine.
NotANumber_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre NaN (Not-a-Number).
NotAPrimitiveWrapper_1 = La classe \u2018{0}\u2019 n\u2019est pas un adaptateur d\u2019un type primitif.
@@ -190,6 +191,7 @@ UnexpectedEndOfFile_1 = Fin
UnexpectedEndOfString_1 = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0 la fin du texte \u00ab\u202f{0}\u202f\u00bb.
UnexpectedFileFormat_2 = Le fichier \u00ab\u202f{1}\u202f\u00bb semble \u00eatre encod\u00e9 dans un autre format que {0}.
UnexpectedParameter_1 = Le param\u00e8tre \u00ab\u202f{0}\u202f\u00bb est inattendu.
+UnexpectedTypeForReference_3 = L\u2019identifiant \u201c{0}\u201d r\u00e9f\u00e9rence une instance de \u2018{2}\u2019 alors qu\u2019on attendait une instance de \u2018{1}\u2019.
UnexpectedValueInElement_2 = La valeur \u00ab\u202f{1}\u202f\u00bb dans l\u2019\u00e9l\u00e9ment \u00ab\u202f{0}\u202f\u00bb est inattendue.
UnitlessParameter_1 = Le param\u00e8tre \u00ab\u202f{0}\u202f\u00bb n\u2019a pas d\u2019unit\u00e9.
UnknownAuthority_1 = L\u2019autorit\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnue.
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java?rev=1707616&r1=1707615&r2=1707616&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java [UTF-8] Thu Oct 8 20:16:20 2015
@@ -63,7 +63,10 @@ public interface IdentifierSpace
The XML attribute name of the reference to such identified object is {@code "xlink:href"}.
+ *Elements with {@code gml:id} or {@code gco:id} attribute can be referenced from other XML elements + * using the {@code xlink:href} attribute. This is done automatically by Apache SIS implementations at + * marshalling and unmarshalling time. If many of {@code gml:id}, {@code gco:uuid} and {@code xlink:href} + * attributes are used, then {@code gml:id} has precedence.
* * @see javax.xml.bind.annotation.XmlID */ @@ -78,7 +81,9 @@ public interface IdentifierSpaceThe XML attribute name of the reference to such identified object is {@code "gco:uuidref"}. + *
Elements with {@code gco:uuid} attribute can be referenced from other XML elements using the + * {@code gco:uuidref} attribute. However this is not done automatically by Apache SIS. Users need + * to manage their set of UUIDs in their own {@link ReferenceResolver} subclass.
* * @see UUID */ Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java?rev=1707616&r1=1707615&r2=1707616&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java [UTF-8] Thu Oct 8 20:16:20 2015 @@ -129,9 +129,22 @@ public class ReferenceResolver { ensureNonNull("xlink", link); final URI href = link.getHRef(); if (href != null && href.toString().startsWith("#")) { - final Object object = Context.getObjectForID(Context.current(), href.getFragment()); + final String id = href.getFragment(); + final Context c = (context instanceof Context) ? (Context) context : Context.current(); + final Object object = Context.getObjectForID(c, id); if (type.isInstance(object)) { return type.cast(object); + } else { + final short key; + final Object args; + if (object == null) { + key = Errors.Keys.NotABackwardReference_1; + args = id; + } else { + key = Errors.Keys.UnexpectedTypeForReference_3; + args = new Object[] {id, type, object.getClass()}; + } + Context.warningOccured(c, ReferenceResolver.class, "resolve", Errors.class, key, args); } } return null;