Author: desruisseaux
Date: Mon Aug 3 08:23:51 2015
New Revision: 1693858
URL: http://svn.apache.org/r1693858
Log:
Less missleading error message if the user gives the internal Anchor class in
argument to the constructor,
and if that object is incomplete.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1693858&r1=1693857&r2=1693858&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] Mon Aug 3 08:23:51 2015
@@ -28,6 +28,7 @@ import org.opengis.util.ScopedName;
import org.opengis.util.GenericName;
import org.opengis.util.NameFactory;
import org.opengis.util.InternationalString;
+import org.apache.sis.util.resources.Errors;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.Identifier;
import org.opengis.parameter.InvalidParameterValueException;
@@ -212,11 +213,20 @@ public class NamedIdentifier extends Imm
*/
private static String toString(final CharSequence code) {
ArgumentChecks.ensureNonNull("code", code);
+ final String c;
if (code instanceof InternationalString) {
- return ((InternationalString) code).toString(Locale.ROOT);
+ c = ((InternationalString) code).toString(Locale.ROOT);
} else {
- return code.toString();
+ c = code.toString();
}
+ if (c != null) {
+ return c;
+ }
+ /*
+ * May happen if the user gave us an instance of
'org.apache.sis.internal.jaxb.gmx.Anchor' class
+ * (maybe he got the instance indirectly) and the construction of that
instance is not completed.
+ */
+ throw new
IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
"code", code.getClass()));
}
/**