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 2015/02/23 00:38:35 UTC
svn commit: r1661582 [4/4] - in /sis/trunk: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-metadata/src/main/java/org/apache/sis/metadata/
core/sis-metadata/src/main/...
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -250,8 +250,9 @@ public class SimpleIdentifiedObject impl
buffer.append(codespace).append(DefaultNameSpace.DEFAULT_SEPARATOR);
}
buffer.append(code).append('"');
- if (authority != null) {
- buffer.append(", ID[\"").append(Citations.getIdentifier(authority)).append("\"]");
+ final String identifier = Citations.getIdentifier(authority, true);
+ if (identifier != null) {
+ buffer.append(", ID[\"").append(identifier).append("\"]");
}
return buffer.append(']').toString();
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -103,7 +103,7 @@ public class SimpleIdentifier implements
*/
@Override
public String getCodeSpace() {
- return Citations.getIdentifier(authority);
+ return Citations.getUnicodeIdentifier(authority);
}
/**
@@ -209,7 +209,7 @@ public class SimpleIdentifier implements
*/
public String toWKT() {
final StringBuilder buffer = new StringBuilder(40).append("ID[");
- append(buffer, Citations.getIdentifier(authority)); // Do not invoke getCodeSpace().
+ append(buffer, Citations.getIdentifier(authority, true)); // Do not invoke getCodeSpace().
append(buffer.append(", "), code);
return buffer.append(']').toString();
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -190,6 +190,8 @@ public final class DelayedExecutor exten
* Returns {@code true} if this thread seems to be stalled. This method checks the head
* of the queue. If the delay for that head has expired and the head is not removed in
* the next 5 seconds, then we will presume that the thread is stalled or dead.
+ *
+ * @return {@inheritDoc}
*/
@Override
protected boolean isStalled() {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/LocalizedStaticObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/LocalizedStaticObject.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/LocalizedStaticObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/LocalizedStaticObject.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -29,7 +29,7 @@ import java.lang.annotation.RetentionPol
*
* If JDK provided listeners allowing SIS to be notified about locale and timezone changes, we would
* reset the annotated object to {@code null}. However since those listeners do not exist as of JDK7,
- * we use this annotation in the main time for identifying the code which would need to be revisited
+ * we use this annotation in the meantime for identifying the code which would need to be revisited
* if we want to take in account default locale/timezone changes in a future SIS version.
*
* @author Martin Desruisseaux (Geomatys)
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -39,23 +39,13 @@ import org.opengis.referencing.Reference
* defined in the {@link org.apache.sis.metadata.iso.citation.Citations} class, but the actual
* implementation is defined here since it is needed by some utility methods.
*
- * {@section Argument checks}
- * Every methods in this class accept {@code null} argument. This is different from the methods
- * in the {@link org.apache.sis.metadata.iso.citation.Citations} facade, which perform checks
- * against null argument for trapping user errors.
- *
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class Citations extends Static {
/**
- * The {@value} code space.
- */
- public static final String EPSG = "EPSG";
-
- /**
* Do not allows instantiation of this class.
*/
private Citations() {
@@ -75,7 +65,7 @@ public final class Citations extends Sta
/**
* Returns a "unlocalized" string representation of the given international string,
- * or {@code null} if none. This method is used by {@link #getIdentifier(Citation)},
+ * or {@code null} if none. This method is used by {@link #getIdentifier(Citation, boolean)},
* which is why we don't want the localized string.
*/
private static String toString(final InternationalString title) {
@@ -83,16 +73,14 @@ public final class Citations extends Sta
}
/**
- * Returns {@code true} if at least one {@linkplain Citation#getTitle() title} or
- * {@linkplain Citation#getAlternateTitles() alternate title} in {@code c1} is leniently
- * equal to a title or alternate title in {@code c2}. The comparison is case-insensitive
- * and ignores every character which is not a {@linkplain Character#isLetterOrDigit(int)
- * letter or a digit}. The titles ordering is not significant.
+ * Returns {@code true} if the two citations have at least one title in common,
+ * ignoring case and non-alphanumeric characters.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#titleMatches(Citation, Citation)}
+ * for the public documentation of this method.
*
* @param c1 The first citation to compare, or {@code null}.
* @param c2 the second citation to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and at least one title or
- * alternate title matches.
+ * @return {@code true} if both arguments are non-null, and at least one title or alternate title matches.
*/
public static boolean titleMatches(final Citation c1, final Citation c2) {
if (c1 != null && c2 != null) {
@@ -126,14 +114,14 @@ public final class Citations extends Sta
}
/**
- * Returns {@code true} if the {@linkplain Citation#getTitle() title} or any
- * {@linkplain Citation#getAlternateTitles() alternate title} in the given citation
- * matches the given string. The comparison is case-insensitive and ignores every character
- * which is not a {@linkplain Character#isLetterOrDigit(int) letter or a digit}.
+ * Returns {@code true} if the given citation has at least one title equals to the given string,
+ * ignoring case and non-alphanumeric characters.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#titleMatches(Citation, String)}
+ * for the public documentation of this method.
*
* @param citation The citation to check for, or {@code null}.
* @param title The title or alternate title to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and the title or alternate
+ * @return {@code true} if both arguments are non-null, and the title or an alternate
* title matches the given string.
*/
public static boolean titleMatches(final Citation citation, final CharSequence title) {
@@ -165,22 +153,15 @@ public final class Citations extends Sta
}
/**
- * Returns {@code true} if at least one {@linkplain Citation#getIdentifiers() identifier}
- * {@linkplain Identifier#getCode() code} in {@code c1} is equal to an identifier code in
- * {@code c2}. {@linkplain Identifier#getCodeSpace() Code spaces} are compared only if
- * provided in the two identifiers being compared. Comparisons are case-insensitive and ignores
- * every character which is not a {@linkplain Character#isLetterOrDigit(int) letter or a digit}.
- * The identifier ordering is not significant.
- *
- * <p>If (and <em>only</em> if) the citations do not contains any identifier, then this method
- * fallback on titles comparison using the {@link #titleMatches(Citation,Citation) titleMatches}
- * method. This fallback exists for compatibility with client codes using the citation
- * {@linkplain Citation#getTitle() titles} without identifiers.</p>
+ * Returns {@code true} if the two citations have at least one identifier in common,
+ * ignoring case and non-alphanumeric characters. If and <em>only</em> if the citations
+ * do not contain any identifier, then this method fallback on titles comparison.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#identifierMatches(Citation, Citation)}
+ * for the public documentation of this method.
*
* @param c1 The first citation to compare, or {@code null}.
* @param c2 the second citation to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and at least one identifier,
- * title or alternate title matches.
+ * @return {@code true} if both arguments are non-null, and at least one identifier matches.
*/
public static boolean identifierMatches(Citation c1, Citation c2) {
if (c1 != null && c2 != null) {
@@ -212,24 +193,16 @@ public final class Citations extends Sta
}
/**
- * Returns {@code true} if at least one {@linkplain Citation#getIdentifiers() identifier}
- * in the given citation have a {@linkplain Identifier#getCode() code} matching the given
- * one. The comparison is case-insensitive and ignores every character which is not a
- * {@linkplain Character#isLetterOrDigit(int) letter or a digit}.
- *
- * <p>If a match is found, if the given {@code identifier} is non-null and if the code space
- * of both objects is non-null, then the code space is also compared.</p>
- *
- * <p>If (and <em>only</em> if) the citation does not contain any identifier, then this method
- * fallback on titles comparison using the {@link #titleMatches(Citation, CharSequence) titleMatches}
- * method. This fallback exists for compatibility with client codes using citation
- * {@linkplain Citation#getTitle() title} without identifiers.</p>
+ * Returns {@code true} if the given citation has at least one identifier equals to the given string,
+ * ignoring case and non-alphanumeric characters. If and <em>only</em> if the citations do not contain
+ * any identifier, then this method fallback on titles comparison.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#identifierMatches(Citation, String)}
+ * for the public documentation of this method.
*
* @param citation The citation to check for, or {@code null}.
* @param identifier The identifier to compare, or {@code null} to unknown.
* @param code The identifier code to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and the title or alternate title
- * matches the given string.
+ * @return {@code true} if both arguments are non-null, and an identifier matches the given string.
*/
public static boolean identifierMatches(final Citation citation, final Identifier identifier, final CharSequence code) {
if (citation != null && code != null) {
@@ -258,39 +231,23 @@ public final class Citations extends Sta
/**
* Infers an identifier from the given citation, or returns {@code null} if no identifier has been found.
- * This method is useful for extracting the namespace from an authority, for example {@code "EPSG"}.
- * The implementation performs the following choices:
+ * This method removes leading and trailing {@linkplain Character#isWhitespace(int) whitespaces}.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#getIdentifier(Citation)}
+ * for the public documentation of this method.
*
+ * <p><b>Which method to use:</b></p>
* <ul>
- * <li>If the given citation is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the citation contains at least one {@linkplain Citation#getIdentifiers() identifier}, then:
- * <ul>
- * <li>If at least one identifier is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
- * unicode identifier}, then the shortest of those identifiers is returned.</li>
- * <li>Otherwise the shortest identifier is returned, despite not being a Unicode identifier.</li>
- * </ul></li>
- * <li>Otherwise if the citation contains at least one {@linkplain Citation#getTitle() title} or
- * {@linkplain Citation#getAlternateTitles() alternate title}, then:
- * <ul>
- * <li>If at least one title is a {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
- * unicode identifier}, then the shortest of those titles is returned.</li>
- * <li>Otherwise the shortest title is returned, despite not being a Unicode identifier.</li>
- * </ul></li>
- * <li>Otherwise this method returns {@code null}.</li>
+ * <li>For information purpose (e.g. some {@code toString()} methods), use {@code getIdentifier(…, false)}.</li>
+ * <li>For WKT formatting, use {@code getIdentifier(…, true)} in order to preserve formatting characters.</li>
+ * <li>For assigning a value to a {@code codeSpace} field, use {@link #getUnicodeIdentifier(Citation)}.</li>
* </ul>
*
- * <div class="note"><b>Note:</b>
- * This method searches in alternate titles as a fallback because ISO specification said
- * that those titles are often used for abbreviations.</div>
- *
- * This method ignores leading and trailing whitespaces of every character sequences.
- * Null references, empty character sequences and sequences of whitespaces only are ignored.
- *
* @param citation The citation for which to get the identifier, or {@code null}.
+ * @param strict {@code true} for returning a non-null value only if the identifier is a valid Unicode identifier.
* @return A non-empty identifier for the given citation without leading or trailing whitespaces,
* or {@code null} if the given citation is null or does not declare any identifier or title.
*/
- public static String getIdentifier(final Citation citation) {
+ public static String getIdentifier(final Citation citation, final boolean strict) {
boolean isUnicode = false; // Whether 'identifier' is a Unicode identifier.
String identifier = null;
if (citation != null) {
@@ -341,6 +298,66 @@ public final class Citations extends Sta
}
}
}
+ return (isUnicode || !strict) ? identifier : null;
+ }
+
+ /**
+ * Infers a valid Unicode identifier from the given citation, or returns {@code null} if none.
+ * This method removes {@linkplain Character#isIdentifierIgnorable(int) ignorable characters}.
+ * See {@link org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)}
+ * for the public documentation of this method.
+ *
+ * {@section When to use}
+ * Use this method when assigning values to be returned by methods like {@link Identifier#getCodeSpace()},
+ * since those values are likely to be compared without special care about ignorable identifier characters.
+ * But if the intend is to format a more complex string like WKT or {@code toString()}, then we suggest to
+ * use {@code getIdentifier(citation, true)} instead, which will produce the same result but preserving the
+ * ignorable characters, which can be useful for formatting purpose.
+ *
+ * @param citation The citation for which to get the Unicode identifier, or {@code null}.
+ * @return A non-empty Unicode identifier for the given citation without leading or trailing whitespaces,
+ * or {@code null} if the given citation is null or does not have any Unicode identifier or title.
+ *
+ * @since 0.6
+ */
+ public static String getUnicodeIdentifier(final Citation citation) {
+ final String identifier = getIdentifier(citation, true);
+ if (identifier != null) {
+ /*
+ * First perform a quick check to see if there is any ignorable characters.
+ * We make this check because those characters are valid according Unicode
+ * but not according XML. However there is usually no such characters, so
+ * we will avoid the StringBuilder creation in the vast majority of times.
+ *
+ * Note that 'µ' and its friends are not ignorable, so we do not remove them.
+ * This method is "getUnicodeIdentifier", not "getXmlIdentifier".
+ */
+ final int length = identifier.length();
+ for (int i=0; i<length;) {
+ int c = identifier.codePointAt(i);
+ int n = Character.charCount(c);
+ if (Character.isIdentifierIgnorable(c)) {
+ /*
+ * Found an ignorable character. Create the buffer and copy non-ignorable characters.
+ * Following algorithm is inefficient, since we fill the buffer character-by-character
+ * (a more efficient approach would be to perform bulk appends). However we presume
+ * that this block will be rarely executed, so it is not worth to optimize it.
+ */
+ final StringBuilder buffer = new StringBuilder(length - n).append(identifier, 0, i);
+ while ((i += n) < length) {
+ c = identifier.codePointAt(i);
+ n = Character.charCount(c);
+ if (!Character.isIdentifierIgnorable(c)) {
+ buffer.appendCodePoint(c);
+ }
+ }
+ // No need to verify if the buffer is empty, because ignorable
+ // characters are not legal Unicode identifier start.
+ return buffer.toString();
+ }
+ i += n;
+ }
+ }
return identifier;
}
}
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -51,7 +51,7 @@ import org.apache.sis.internal.jdk8.Func
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class CollectionsExt extends Static {
@@ -62,6 +62,24 @@ public final class CollectionsExt extend
}
/**
+ * Returns the first element of the given iterable, or {@code null} if none.
+ * This method is null-safe. Note that the first element may be null.
+ *
+ * @param <T> The type of elements contained in the iterable.
+ * @param collection The iterable from which to get the first element, or {@code null}.
+ * @return The first element, or {@code null} if the given iterable is null or empty.
+ */
+ public static <T> T first(final Iterable<T> collection) {
+ if (collection != null) {
+ final Iterator<T> it = collection.iterator();
+ if (it != null && it.hasNext()) { // This check for null is paranoiac.
+ return it.next();
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns a {@linkplain Queue queue} which is always empty and accepts no element.
*
* @param <E> The type of elements in the empty collection.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -70,7 +70,7 @@ final class IdentifiedObjectFormat exten
final String code = identifier.getCode();
String cs = identifier.getCodeSpace();
if (cs == null || cs.isEmpty()) {
- cs = Citations.getIdentifier(identifier.getAuthority());
+ cs = Citations.getIdentifier(identifier.getAuthority(), true);
}
if (cs != null) {
toAppendTo.append(cs).append(DefaultNameSpace.DEFAULT_SEPARATOR);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -32,7 +32,7 @@ import org.apache.sis.util.Exceptions;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.DefinitionURI;
-import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.XPaths;
import static java.lang.Math.PI;
@@ -356,7 +356,7 @@ public final class Units extends Static
* we want to try to parse as a xpointer before to give up.
*/
if (isURI(uom)) {
- String code = DefinitionURI.codeOf("uom", Citations.EPSG, uom);
+ String code = DefinitionURI.codeOf("uom", Constants.EPSG, uom);
if (code != null && code != uom) try { // Really identity check, see above comment.
return valueOfEPSG(Integer.parseInt(code));
} catch (NumberFormatException e) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -18,6 +18,8 @@ package org.apache.sis.util;
import java.util.Arrays;
import java.nio.CharBuffer;
+import org.opengis.metadata.citation.Citation; // For javadoc
+import org.opengis.referencing.IdentifiedObject; // For javadoc
import static java.lang.Character.*;
@@ -1548,8 +1550,42 @@ cmp: while (ia < lga) {
* Unicode identifier start} and all remaining characters (if any) are
* {@linkplain Character#isUnicodeIdentifierPart(int) Unicode identifier parts}.
*
+ * {@section Relationship with legal XML identifiers}
+ * Most legal Unicode identifiers are also legal XML identifiers, but the converse is not true.
+ * The most noticeable differences are the ‘{@code :}’, ‘{@code -}’ and ‘{@code .}’ characters,
+ * which are legal in XML identifiers but not in Unicode.
+ *
+ * <table class="sis">
+ * <caption>Characters legal in one set but not in the other</caption>
+ * <tr><th colspan="2">Not legal in Unicode</th> <th class="sep" colspan="2">Not legal in XML</th></tr>
+ * <tr><td>{@code :}</td><td>(colon)</td> <td class="sep">{@code µ}</td><td>(micro sign)</td></tr>
+ * <tr><td>{@code -}</td><td>(hyphen or minus)</td> <td class="sep">{@code ª}</td><td>(feminine ordinal indicator)</td></tr>
+ * <tr><td>{@code .}</td><td>(dot)</td> <td class="sep">{@code º}</td><td>(masculine ordinal indicator)</td></tr>
+ * <tr><td>{@code ·}</td><td>(middle dot)</td> <td class="sep">{@code ⁔}</td><td>(inverted undertie)</td></tr>
+ * <tr>
+ * <td colspan="2">Many punctuation, symbols, <i>etc</i>.</td>
+ * <td colspan="2" class="sep">{@linkplain Character#isIdentifierIgnorable(int) Identifier ignorable} characters.</td>
+ * </tr>
+ * </table>
+ *
+ * Note that the ‘{@code _}’ (underscore) character is legal according both Unicode and XML, while spaces,
+ * ‘{@code !}’, ‘{@code #}’, ‘{@code *}’, ‘{@code /}’, ‘{@code ?}’ and most other punctuation characters are not.
+ *
+ * {@section Usage in Apache SIS}
+ * In its handling of {@linkplain org.apache.sis.metadata.iso.ImmutableIdentifier identifiers}, Apache SIS favors
+ * Unicode identifiers without {@linkplain Character#isIdentifierIgnorable(int) ignorable} characters since those
+ * identifiers are legal XML identifiers except for the above-cited rarely used characters. As a side effect,
+ * this policy excludes ‘{@code :}’, ‘{@code -}’ and ‘{@code .}’ which would normally be legal XML identifiers.
+ * But since those characters could easily be confused with
+ * {@linkplain org.apache.sis.util.iso.DefaultNameSpace#DEFAULT_SEPARATOR namespace separators},
+ * this exclusion is considered desirable.
+ *
* @param identifier The character sequence to test, or {@code null}.
* @return {@code true} if the given character sequence is a legal Unicode identifier.
+ *
+ * @see org.apache.sis.metadata.iso.ImmutableIdentifier
+ * @see org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)
+ * @see org.apache.sis.referencing.IdentifiedObjects#getUnicodeIdentifier(IdentifiedObject)
*/
public static boolean isUnicodeIdentifier(final CharSequence identifier) {
final int length = length(identifier);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -27,6 +27,7 @@ import org.opengis.util.TypeName;
import org.opengis.util.NameSpace;
import org.opengis.util.NameFactory;
import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Numbers;
@@ -53,17 +54,17 @@ final class TypeNames {
private static final Map<String,Class<?>> MAPPING = new LinkedHashMap<String,Class<?>>(16);
static {
final Map<String,Class<?>> m = MAPPING;
- m.put("URI", URI.class);
- m.put("DateTime", Date.class);
- m.put("PT_Locale", Locale.class);
- m.put("Boolean", Boolean.class); // Used as a sentinel value for stopping iteration.
+ m.put("URI", URI.class);
+ m.put("DateTime", Date.class);
+ m.put("PT_Locale", Locale.class);
+ m.put("Boolean", Boolean.class); // Used as a sentinel value for stopping iteration.
// Entries below this point are handled in a special way.
- m.put("FreeText", InternationalString.class);
- m.put("CharacterString", String.class);
- m.put("Real", Double.class);
- m.put("Decimal", Double.class);
- m.put("Integer", Integer.class);
+ m.put("FreeText", InternationalString.class);
+ m.put("CharacterString", String.class);
+ m.put("Real", Double.class);
+ m.put("Decimal", Double.class);
+ m.put("Integer", Integer.class);
};
/**
@@ -80,7 +81,7 @@ final class TypeNames {
* Creates a new factory of type names.
*/
TypeNames(final NameFactory factory) {
- ogcNS = factory.createNameSpace(factory.createLocalName(null, "OGC"), null);
+ ogcNS = factory.createNameSpace(factory.createLocalName(null, Constants.OGC), null);
classNS = factory.createNameSpace(factory.createLocalName(null, "class"), null);
}
@@ -157,7 +158,7 @@ final class TypeNames {
*/
static Class<?> toClass(final String namespace, final String name) throws ClassNotFoundException {
Class<?> c;
- if (namespace == null || namespace.equalsIgnoreCase("OGC")) {
+ if (namespace == null || namespace.equalsIgnoreCase(Constants.OGC)) {
c = MAPPING.get(name);
if (c == null) {
c = Types.forStandardName(name);
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -333,6 +333,11 @@ public final class Errors extends Indexe
public static final short IllegalMemberType_2 = 37;
/**
+ * Dimensions of “{0}” operation can not be ({1} → {2}).
+ */
+ public static final short IllegalOperationDimension_3 = 180;
+
+ /**
* This operation can not be applied to values of class ‘{0}’.
*/
public static final short IllegalOperationForValueClass_1 = 141;
@@ -585,6 +590,11 @@ public final class Errors extends Indexe
public static final short NoSuchAuthorityCode_3 = 137;
/**
+ * No operation method found for name of identifier “{0}”.
+ */
+ public static final short NoSuchOperationMethod_1 = 179;
+
+ /**
* No unit of measurement has been specified.
*/
public static final short NoUnit = 72;
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -76,6 +76,7 @@ IllegalClass_2 = Clas
IllegalFormatPatternForClass_2 = The \u201c{1}\u201d pattern can not be applied to formating of objects of type \u2018{0}\u2019.
IllegalLanguageCode_1 = The \u201c{0}\u201d language is not recognized.
IllegalMemberType_2 = Member \u201c{0}\u201d can not be associated to type \u201c{1}\u201d.
+IllegalOperationDimension_3 = Dimensions of \u201c{0}\u201d operation can not be ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = This operation can not be applied to values of class \u2018{0}\u2019.
IllegalOptionValue_2 = Option \u2018{0}\u2019 can not take the \u201c{1}\u201d value.
IllegalOrdinateRange_3 = The [{0} \u2026 {1}] range of ordinate values is not valid for the \u201c{2}\u201d axis.
@@ -150,6 +151,7 @@ NotASkewSymmetricMatrix = Matr
NotAUnicodeIdentifier_1 = Text \u201c{0}\u201d is not a Unicode identifier.
NotComparableClass_1 = Class \u2018{0}\u2019 is not a comparable.
NoSuchAuthorityCode_3 = No code \u201c{2}\u201d from authority \u201c{0}\u201d found for object of type \u2018{1}\u2019.
+NoSuchOperationMethod_1 = No operation method found for name of identifier \u201c{0}\u201d.
NoUnit = No unit of measurement has been specified.
NullArgument_1 = Argument \u2018{0}\u2019 shall not be null.
NullCollectionElement_1 = \u2018{0}\u2019 collection does not accept null elements.
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -66,6 +66,7 @@ IllegalClass_2 = La c
IllegalFormatPatternForClass_2 = Le mod\u00e8le \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{0}\u2019.
IllegalLanguageCode_1 = Le code de langue \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnu.
IllegalMemberType_2 = Le membre \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre associ\u00e9 au type \u00ab\u202f{1}\u202f\u00bb.
+IllegalOperationDimension_3 = Les dimensions de l\u2019op\u00e9ration \u00ab\u202f{0}\u202f\u00bb ne peuvent pas \u00eatre ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = Cette op\u00e9ration ne peut pas s\u2019appliquer aux valeurs de classe \u2018{0}\u2019.
IllegalOptionValue_2 = L\u2019option \u2018{0}\u2019 n\u2019accepte pas la valeur \u00ab\u202f{1}\u202f\u00bb.
IllegalOrdinateRange_3 = La plage de valeurs de coordonn\u00e9es [{0} \u2026 {1}] n\u2019est pas valide pour l\u2019axe \u00ab\u202f{2}\u202f\u00bb.
@@ -140,6 +141,7 @@ NotASkewSymmetricMatrix = La m
NotAUnicodeIdentifier_1 = Le texte \u00ab\u202f{0}\u202f\u00bb n\u2019est pas un identifiant Unicode.
NotComparableClass_1 = La classe \u2018{0}\u2019 n\u2019est pas comparable.
NoSuchAuthorityCode_3 = Aucun code \u00ab\u202f{2}\u202f\u00bb de l\u2019autorit\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019a \u00e9t\u00e9 trouv\u00e9 pour un objet de type \u2018{1}\u2019.
+NoSuchOperationMethod_1 = Aucune m\u00e9thode n\u2019a \u00e9t\u00e9 trouv\u00e9e pour le nom ou l\u2019identifiant \u00ab\u202f{0}\u202f\u00bb.
NoUnit = Aucune unit\u00e9 de mesure n\u2019a \u00e9t\u00e9 sp\u00e9cifi\u00e9e.
NullArgument_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre nul.
NullCollectionElement_1 = La collection \u2018{0}\u2019 n\u2019accepte pas les valeurs nulles.
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -92,6 +92,12 @@ public final class Messages extends Inde
public static final short LocalesDiscarded = 3;
/**
+ * The “{1}” parameter could have been omitted. But it has been given a value of {2} which does
+ * not match the definition of the “{0}” ellipsoid.
+ */
+ public static final short MismatchedEllipsoidAxisLength_3 = 9;
+
+ /**
* Property “{0}” is hidden by “{1}”.
*/
public static final short PropertyHiddenBy_2 = 4;
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -22,4 +22,5 @@ IgnoredPropertiesAfterFirst_1 = Ignore
IgnoredPropertyAssociatedTo_1 = Ignored property associated to \u2018{0}\u2019.
PropertyHiddenBy_2 = Property \u201c{0}\u201d is hidden by \u201c{1}\u201d.
LocalesDiscarded = Text were discarded for some locales.
+MismatchedEllipsoidAxisLength_3 = The \u201c{1}\u201d parameter could have been omitted. But it has been given a value of {2} which does not match the definition of the \u201c{0}\u201d ellipsoid.
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -22,4 +22,5 @@ IgnoredPropertiesAfterFirst_1 = Des pr
IgnoredPropertyAssociatedTo_1 = Une propri\u00e9t\u00e9 associ\u00e9e \u00e0 \u2018{0}\u2019 a \u00e9t\u00e9 ignor\u00e9e.
PropertyHiddenBy_2 = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb est masqu\u00e9e par \u00ab\u202f{1}\u202f\u00bb.
LocalesDiscarded = Des textes ont \u00e9t\u00e9 ignor\u00e9s pour certaines langues.
+MismatchedEllipsoidAxisLength_3 = Le param\u00e8tre \u00ab\u202f{1}\u202f\u00bb aurait pu \u00eatre omis. Mais il lui a \u00e9t\u00e9 donn\u00e9 la {2} qui ne correspond pas \u00e0 la d\u00e9finition de l'ellipso\u00efde \u00ab\u202f{0}\u202f\u00bb.
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/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -371,6 +371,11 @@ public final class Vocabulary extends In
public static final short StandardDeviation = 51;
/**
+ * Superseded by {0}.
+ */
+ public static final short SupersededBy_1 = 84;
+
+ /**
* Temporal
*/
public static final short Temporal = 66;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Sun Feb 22 23:38:34 2015
@@ -77,6 +77,7 @@ RootMeanSquare = Root Mean Squa
Scale = Scale
Source = Source
StandardDeviation = Standard deviation
+SupersededBy_1 = Superseded by {0}.
TemporaryFiles = Temporary files
Temporal = Temporal
Time = Time
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Sun Feb 22 23:38:34 2015
@@ -77,6 +77,7 @@ RootMeanSquare = Moyenne quadra
Scale = \u00c9chelle
Source = Source
StandardDeviation = \u00c9cart type
+SupersededBy_1 = Remplac\u00e9 par {0}.
TemporaryFiles = Fichiers temporaires
Temporal = Temporel
Time = Temps
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=1661582&r1=1661581&r2=1661582&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] Sun Feb 22 23:38:34 2015
@@ -259,7 +259,7 @@ abstract class Pooled {
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, 2) < 0) {
+ if (versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) {
return FilterVersion.GML31;
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -183,11 +183,10 @@ public final class XML extends Static {
* algorithm by subclassing {@link ReferenceResolver} and configure a unmarshaller as below:</p>
*
* {@preformat java
- * ReferenceResolver myResolver = ...;
- * Unmarshaller um = marshallerPool.acquireUnmarshaller();
- * um.setProperty(XML.RESOLVER, myResolver);
- * Object obj = um.unmarshal(xml);
- * marshallerPool.recycle(um);
+ * ReferenceResolver myResolver = ...;
+ * Map<String,Object> properties = new HashMap<>();
+ * properties.put(XML.RESOLVER, myResolver);
+ * Object obj = XML.unmarshal(source, properties);
* }
*
* @see Unmarshaller#setProperty(String, Object)
@@ -196,7 +195,7 @@ public final class XML extends Static {
public static final String RESOLVER = "org.apache.sis.xml.resolver";
/**
- * Control the behaviors of the (un)marshalling process when an element can not be processed,
+ * Controls the behaviors of the (un)marshalling process when an element can not be processed,
* or alter the element values. The value for this property shall be an instance of {@link ValueConverter}.
*
* <p>If an element in a XML document can not be parsed (for example if a {@linkplain java.net.URL}
@@ -231,10 +230,9 @@ public final class XML extends Static {
* // Not all errors are trapped - see the ValueConverter
* // javadoc for more details.
* WarningCollector myWarningList = new WarningCollector();
- * Unmarshaller um = marshallerPool.acquireUnmarshaller();
- * um.setProperty(XML.CONVERTER, myWarningList);
- * Object obj = um.unmarshal(xml);
- * marshallerPool.recycle(um);
+ * Map<String,Object> properties = new HashMap<>();
+ * properties.put(XML.CONVERTER, myWarningList);
+ * Object obj = XML.unmarshal(source, properties);
* if (!myWarningList.isEmpty()) {
* // Report here the warnings to the user.
* }
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleIdentifierTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleIdentifierTest.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleIdentifierTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleIdentifierTest.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.simple;
+import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -30,6 +31,7 @@ import static org.junit.Assert.*;
* @version 0.3
* @module
*/
+@DependsOn(org.apache.sis.internal.util.CitationsTest.class)
public final strictfp class SimpleIdentifierTest extends TestCase {
/**
* Tests {@link SimpleIdentifier#toString()}.
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -298,8 +298,7 @@ public final class TestRunner extends Bl
public void filter(final Filter filter) throws NoTestsRemainException {
int count = 0;
FrameworkMethod[] children = getFilteredChildren();
- for (int i=0; i<children.length; i++) {
- final FrameworkMethod method = children[i];
+ for (final FrameworkMethod method : children) {
if (filter.shouldRun(describeChild(method))) {
try {
filter.apply(method);
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -82,6 +82,7 @@ import org.junit.BeforeClass;
// GeoAPI most basic types.
org.apache.sis.internal.util.DefinitionURITest.class,
org.apache.sis.internal.util.XPathsTest.class,
+ org.apache.sis.internal.util.CitationsTest.class,
org.apache.sis.util.iso.TypesTest.class,
org.apache.sis.util.iso.SimpleInternationalStringTest.class,
org.apache.sis.util.iso.DefaultInternationalStringTest.class,
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -34,7 +34,7 @@ import static org.apache.sis.util.CharSe
* @author Martin Desruisseaux (Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
@DependsOn({
@@ -394,9 +394,28 @@ public final strictfp class CharSequence
*/
@Test
public void testIsUnicodeIdentifier() {
+ assertFalse( isUnicodeIdentifier(null));
assertTrue ("A123", isUnicodeIdentifier("A123"));
assertFalse("123A", isUnicodeIdentifier("123A"));
- assertFalse( isUnicodeIdentifier(null));
+ assertTrue ("A_1", isUnicodeIdentifier("A_1"));
+ assertFalse("A-1", isUnicodeIdentifier("A-1"));
+ assertFalse("A+1", isUnicodeIdentifier("A+1"));
+ assertFalse("A/1", isUnicodeIdentifier("A/1"));
+ assertFalse("A\\1", isUnicodeIdentifier("A\\1"));
+ assertFalse("A*1", isUnicodeIdentifier("A*1"));
+ assertFalse("A.1", isUnicodeIdentifier("A.1"));
+ assertFalse("A,1", isUnicodeIdentifier("A,1"));
+ assertFalse("A:1", isUnicodeIdentifier("A:1"));
+ assertFalse("A;1", isUnicodeIdentifier("A;1"));
+ assertFalse("A#1", isUnicodeIdentifier("A#1"));
+ assertFalse("A?1", isUnicodeIdentifier("A?1"));
+ assertFalse("A!1", isUnicodeIdentifier("A!1"));
+ assertFalse("A°1", isUnicodeIdentifier("A°1")); // Degree
+ assertTrue ("Aº1", isUnicodeIdentifier("Aº1")); // Masculine ordinal
+ assertFalse("A 1", isUnicodeIdentifier("A 1")); // Ordinary space
+ assertFalse("A 1", isUnicodeIdentifier("A" + Characters.NO_BREAK_SPACE + "1"));
+ assertFalse("A‐1", isUnicodeIdentifier("A" + Characters.HYPHEN + "1"));
+ assertTrue ("A1", isUnicodeIdentifier("A" + Characters.SOFT_HYPHEN + "1"));
}
/**
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/VersionTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/VersionTest.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/VersionTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/VersionTest.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -16,6 +16,7 @@
*/
package org.apache.sis.util;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -28,7 +29,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.6
* @module
*/
public final strictfp class VersionTest extends TestCase {
@@ -71,6 +72,21 @@ public final strictfp class VersionTest
}
/**
+ * Tests {@link Version#compareTo(Version, int)} with version numbers needed by our GML support.
+ */
+ @Test
+ public void testGML() {
+ assertTrue(LegacyNamespaces.VERSION_3_2.compareTo(LegacyNamespaces.VERSION_3_2_1, 2) == 0);
+ assertTrue(LegacyNamespaces.VERSION_3_2.compareTo(LegacyNamespaces.VERSION_3_2_1 ) < 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2_1 ) < 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2_1, 2) < 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2_1, 1) == 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2 ) < 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2, 2) < 0);
+ assertTrue(LegacyNamespaces.VERSION_3_0.compareTo(LegacyNamespaces.VERSION_3_2, 1) == 0);
+ }
+
+ /**
* Tests the {@link Version#valueOf(int[])} method.
*/
@Test
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -23,7 +23,7 @@ import org.junit.Test;
import static org.opengis.test.Validators.*;
import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.internal.util.Citations.EPSG;
+import static org.apache.sis.internal.util.Constants.EPSG;
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR_STRING;
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -29,6 +29,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;
+import static org.apache.sis.internal.util.Constants.OGC;
/**
@@ -74,14 +75,14 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testBasicTypes() throws ClassNotFoundException {
- verifyLookup("OGC", "URI", URI.class);
- verifyLookup("OGC", "PT_Locale", Locale.class);
- verifyLookup("OGC", "DateTime", Date.class);
- verifyLookup("OGC", "FreeText", InternationalString.class);
- verifyLookup("OGC", "CharacterString", String.class);
- verifyLookup("OGC", "Boolean", Boolean.class);
- verifyLookup("OGC", "Real", Double.class);
- verifyLookup("OGC", "Integer", Integer.class);
+ verifyLookup(OGC, "URI", URI.class);
+ verifyLookup(OGC, "PT_Locale", Locale.class);
+ verifyLookup(OGC, "DateTime", Date.class);
+ verifyLookup(OGC, "FreeText", InternationalString.class);
+ verifyLookup(OGC, "CharacterString", String.class);
+ verifyLookup(OGC, "Boolean", Boolean.class);
+ verifyLookup(OGC, "Real", Double.class);
+ verifyLookup(OGC, "Integer", Integer.class);
}
/**
@@ -89,10 +90,10 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testNumbers() {
- assertEquals("Short", "OGC:Integer", toTypeName(Short .class));
- assertEquals("Long", "OGC:Integer", toTypeName(Long .class));
- assertEquals("Float", "OGC:Real", toTypeName(Float .class));
- assertEquals("Double", "OGC:Real", toTypeName(Double.class));
+ assertEquals("Short", OGC+":Integer", toTypeName(Short .class));
+ assertEquals("Long", OGC+":Integer", toTypeName(Long .class));
+ assertEquals("Float", OGC+":Real", toTypeName(Float .class));
+ assertEquals("Double", OGC+":Real", toTypeName(Double.class));
}
/**
@@ -102,8 +103,8 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testMetadataClasses() throws ClassNotFoundException {
- verifyLookup("OGC", "MD_Metadata", Metadata.class);
- verifyLookup("OGC", "SC_CRS", CoordinateReferenceSystem.class);
+ verifyLookup(OGC, "MD_Metadata", Metadata.class);
+ verifyLookup(OGC, "SC_CRS", CoordinateReferenceSystem.class);
}
/**
@@ -124,9 +125,9 @@ public final strictfp class TypeNamesTes
@Test
public void testInvalidNames() throws ClassNotFoundException {
assertEquals("Dummy:Real", Void.TYPE, TypeNames.toClass("Dummy", "Real"));
- assertEquals("OGC:Real", Double.class, TypeNames.toClass("OGC", "Real"));
+ assertEquals(OGC+":Real", Double.class, TypeNames.toClass(OGC, "Real"));
assertEquals("Real", Double.class, TypeNames.toClass(null, "Real"));
assertEquals("Dummy", Void.TYPE, TypeNames.toClass(null, "Dummy")); // Considered not an error.
- assertNull ("OGC:Dummy", TypeNames.toClass("OGC", "Dummy")); // Considered an error.
+ assertNull (OGC+":Dummy", TypeNames.toClass(OGC, "Dummy")); // Considered an error.
}
}
Modified: sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] Sun Feb 22 23:38:34 2015
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.io.IOException;
import javax.measure.unit.Unit;
import javax.measure.unit.SI;
@@ -78,6 +77,7 @@ import ucar.nc2.constants.CF;
import static java.util.Collections.singleton;
import static org.apache.sis.storage.netcdf.AttributeNames.*;
+import static org.apache.sis.internal.util.CollectionsExt.first;
/**
@@ -261,14 +261,6 @@ final class MetadataReader {
}
/**
- * Returns the first element of the given collection.
- */
- private static <T> T first(final Collection<T> collection) {
- final Iterator<T> it = collection.iterator();
- return it.hasNext() ? it.next() : null;
- }
-
- /**
* Adds the given element in the given collection if the element is not already present in the collection.
* We define this method because the metadata API uses collections while the SIS implementation uses lists.
* The lists are usually very short (typically 0 or 1 element), so the call to {@link List#contains(Object)}