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 2013/04/11 23:17:35 UTC
svn commit: r1467089 - in /sis/branches/JDK6: ./
sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/
sis-metadata/src/main/java/org/apache/sis/metadata/
sis-metadata/src/main/java/org/apache/sis/metadata/iso/
sis-metadata/src/main/java/or...
Author: desruisseaux
Date: Thu Apr 11 21:17:33 2013
New Revision: 1467089
URL: http://svn.apache.org/r1467089
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java
- copied, changed from r1467088, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
- copied unchanged from r1467088, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
Removed:
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/referencing/
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1466651-1467088
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -23,7 +23,7 @@ import org.opengis.metadata.Identifier;
import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.metadata.iso.DefaultIdentifier;
-import org.apache.sis.referencing.DefaultReferenceIdentifier;
+import org.apache.sis.metadata.iso.UnmodifiableIdentifier;
import org.apache.sis.internal.jaxb.gco.PropertyType;
@@ -107,15 +107,14 @@ public final class MD_Identifier extends
* @return The metadata to be marshalled.
*/
@XmlElement(name = "RS_Identifier")
- public DefaultReferenceIdentifier getReferenceIdentifier() {
- if (skip()) return null;
- final Identifier metadata = this.metadata;
- if (!(metadata instanceof ReferenceIdentifier)) {
- return null;
+ public UnmodifiableIdentifier getReferenceIdentifier() {
+ if (!skip()) {
+ final Identifier metadata = this.metadata;
+ if (metadata instanceof ReferenceIdentifier) {
+ return UnmodifiableIdentifier.castOrCopy((ReferenceIdentifier) metadata);
+ }
}
- return (metadata instanceof DefaultReferenceIdentifier) ?
- (DefaultReferenceIdentifier) metadata :
- new DefaultReferenceIdentifier((ReferenceIdentifier) metadata);
+ return null;
}
/**
@@ -123,7 +122,7 @@ public final class MD_Identifier extends
*
* @param metadata The unmarshalled metadata.
*/
- public void setReferenceIdentifier(final DefaultReferenceIdentifier metadata) {
+ public void setReferenceIdentifier(final UnmodifiableIdentifier metadata) {
this.metadata = metadata;
}
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -18,7 +18,7 @@ package org.apache.sis.internal.jaxb.met
import javax.xml.bind.annotation.XmlElementRef;
import org.opengis.referencing.ReferenceIdentifier;
-import org.apache.sis.referencing.DefaultReferenceIdentifier;
+import org.apache.sis.metadata.iso.UnmodifiableIdentifier;
import org.apache.sis.internal.jaxb.gco.PropertyType;
@@ -81,13 +81,13 @@ public final class RS_Identifier extends
* @return The metadata to be marshalled.
*/
@XmlElementRef
- public DefaultReferenceIdentifier getElement() {
+ public UnmodifiableIdentifier getElement() {
if (skip()) return null;
final ReferenceIdentifier metadata = this.metadata;
- if (metadata instanceof DefaultReferenceIdentifier) {
- return (DefaultReferenceIdentifier) metadata;
+ if (metadata instanceof UnmodifiableIdentifier) {
+ return (UnmodifiableIdentifier) metadata;
} else {
- return new DefaultReferenceIdentifier(metadata);
+ return new UnmodifiableIdentifier(metadata);
}
}
@@ -96,7 +96,7 @@ public final class RS_Identifier extends
*
* @param metadata The unmarshalled metadata.
*/
- public void setElement(final DefaultReferenceIdentifier metadata) {
+ public void setElement(final UnmodifiableIdentifier metadata) {
this.metadata = metadata;
}
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -31,7 +31,7 @@ import org.apache.sis.internal.util.Chec
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
-import static org.apache.sis.internal.jaxb.MarshalContext.isMarshaling;
+import static org.apache.sis.internal.jaxb.MarshalContext.isMarshalling;
/**
@@ -499,9 +499,9 @@ public abstract class ModifiableMetadata
protected final <E> List<E> nonNullList(final List<E> c, final Class<E> elementType) {
assert Thread.holdsLock(this);
if (c != null) {
- return c.isEmpty() && isMarshaling() ? null : c;
+ return c.isEmpty() && isMarshalling() ? null : c;
}
- if (isMarshaling()) {
+ if (isMarshalling()) {
return null;
}
if (isModifiable()) {
@@ -522,9 +522,9 @@ public abstract class ModifiableMetadata
protected final <E> Set<E> nonNullSet(final Set<E> c, final Class<E> elementType) {
assert Thread.holdsLock(this);
if (c != null) {
- return c.isEmpty() && isMarshaling() ? null : c;
+ return c.isEmpty() && isMarshalling() ? null : c;
}
- if (isMarshaling()) {
+ if (isMarshalling()) {
return null;
}
if (isModifiable()) {
@@ -554,9 +554,9 @@ public abstract class ModifiableMetadata
assert Thread.holdsLock(this);
if (c != null) {
assert collectionType(elementType).isInstance(c);
- return c.isEmpty() && isMarshaling() ? null : c;
+ return c.isEmpty() && isMarshalling() ? null : c;
}
- if (isMarshaling()) {
+ if (isMarshalling()) {
return null;
}
final boolean isModifiable = isModifiable();
Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java (from r1467088, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java&r1=1467088&r2=1467089&rev=1467089&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -47,7 +47,7 @@ import static org.apache.sis.util.Argume
import static org.opengis.referencing.IdentifiedObject.REMARKS_KEY;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -262,27 +262,27 @@ public class UnmodifiableIdentifier impl
for (final Map.Entry<String,?> entry : properties.entrySet()) {
String key = entry.getKey().trim().toLowerCase();
Object value = entry.getValue();
- switch (key) {
- case CODE_KEY: {
+ /*switch (key)*/ { // This is a "string in switch" on the JDK7 branch.
+ if (key.equals(CODE_KEY)) {
code = value;
continue;
}
- case CODESPACE_KEY: {
+ else if (key.equals(CODESPACE_KEY)) {
codeSpace = value;
continue;
}
- case VERSION_KEY: {
+ else if (key.equals(VERSION_KEY)) {
version = value;
continue;
}
- case AUTHORITY_KEY: {
+ else if (key.equals(AUTHORITY_KEY)) {
if (value instanceof String) {
value = Citations.fromName((String) value);
}
authority = value;
continue;
}
- case REMARKS_KEY: {
+ else if (key.equals(REMARKS_KEY)) {
if (value instanceof String) {
value = new SimpleInternationalString((String) value);
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -32,8 +32,6 @@ import org.apache.sis.xml.IdentifierSpac
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
-import static org.apache.sis.internal.jaxb.MarshalContext.filterIdentifiers;
-
/**
* Describes the characteristics, spatial and temporal extent of the intended object to be observed.
@@ -152,29 +150,36 @@ public class DefaultObjective extends IS
/**
* Returns the code used to identify the objective.
*
- * {@section Implementation limitation}
- * In the current SIS implementation, the returned list is always unmodifiable. The only way
- * to change the collection of identifiers is to invoke {@link #setIdentifiers(Collection)}.
- * This limitation may be removed in a future SIS version.
+ * {@section Unified identifiers view}
+ * In this SIS implementation, the collection returned by this method includes the XML identifiers
+ * ({@linkplain IdentifierSpace#ID ID}, {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>),
+ * thus providing a unified view of every kind of identifiers associated to this objective.
+ *
+ * {@note The <code><:gmd:identifier></code> element marshalled to XML will exclude
+ * all the above cited identifiers, for ISO 19139 compliance. Those identifiers
+ * will appear in other XML elements or attributes.}
*/
@Override
@XmlElement(name = "identifier", required = true)
public synchronized Collection<Identifier> getIdentifiers() {
identifiers = nonNullCollection(identifiers, Identifier.class);
- return filterIdentifiers(identifiers);
+ return NonMarshalledAuthority.excludeOnMarshalling(identifiers);
}
/**
* Sets the code used to identify the objective.
- * If the given collection contains XML identifiers like {@linkplain IdentifierSpace#ID ID}
- * or {@linkplain IdentifierSpace#UUID UUID}, then those identifiers are ignored.
+ *
+ * <p>This method overwrites all previous identifiers with the given new values,
+ * <strong>except</strong> the XML identifiers ({@linkplain IdentifierSpace#ID ID},
+ * {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>), if any. We do not overwrite
+ * the XML identifiers because they are usually associated to object identity.</p>
*
* @param newValues The new identifiers values.
*/
public synchronized void setIdentifiers(final Collection<? extends Identifier> newValues) {
- final Collection<Identifier> oldIds = NonMarshalledAuthority.getIdentifiers(identifiers);
+ final Collection<Identifier> oldIds = NonMarshalledAuthority.filteredCopy(identifiers);
identifiers = writeCollection(newValues, identifiers, Identifier.class);
- NonMarshalledAuthority.setIdentifiers(identifiers, oldIds);
+ NonMarshalledAuthority.replace(identifiers, oldIds);
}
/**
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -30,12 +30,11 @@ import org.opengis.metadata.citation.Ser
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
import org.apache.sis.util.iso.SimpleInternationalString;
-import org.apache.sis.util.collection.CollectionsExt;
import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.xml.IdentifierSpace;
-import static org.apache.sis.internal.jaxb.MarshalContext.filterIdentifiers;
+import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
import static org.apache.sis.internal.metadata.MetadataUtilities.toDate;
import static org.apache.sis.internal.metadata.MetadataUtilities.toMilliseconds;
@@ -81,8 +80,8 @@ public class DefaultCitation extends ISO
* The authority for International Standard Book Number.
*
* <p><b>Implementation note:</b> This field is read by reflection in
- * {@link org.apache.sis.internal.jaxb.NonMarshalledAuthority}. IF this
- * field is renamed or moved, then {@code NonMarshalledAuthority} needs
+ * {@link org.apache.sis.internal.jaxb.NonMarshalledAuthority#getCitation(String)}.
+ * If this field is renamed or moved, then {@code NonMarshalledAuthority} needs
* to be updated.</p>
*/
static final IdentifierSpace<String> ISBN = new NonMarshalledAuthority<String>("ISBN", NonMarshalledAuthority.ISBN);
@@ -91,8 +90,8 @@ public class DefaultCitation extends ISO
* The authority for International Standard Serial Number.
*
* <p><b>Implementation note:</b> This field is read by reflection in
- * {@link org.apache.sis.internal.jaxb.NonMarshalledAuthority}. IF this
- * field is renamed or moved, then {@code NonMarshalledAuthority} needs
+ * {@link org.apache.sis.internal.jaxb.NonMarshalledAuthority#getCitation(String)}.
+ * If this field is renamed or moved, then {@code NonMarshalledAuthority} needs
* to be updated.</p>
*/
static final IdentifierSpace<String> ISSN = new NonMarshalledAuthority<String>("ISSN", NonMarshalledAuthority.ISSN);
@@ -350,37 +349,46 @@ public class DefaultCitation extends ISO
* Example: Universal Product Code (UPC), National Stock Number (NSN).
*
* {@section Unified identifiers view}
- * In this SIS implementation, the collection returned by this method includes the
- * {@linkplain #getISBN() ISBN} and {@linkplain #getISSN() ISSN} codes
- * (except at XML marshalling time for ISO 19139 compliance).
+ * In this SIS implementation, the collection returned by this method includes the XML identifiers
+ * ({@linkplain IdentifierSpace#ID ID}, {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>),
+ * as well as the {@linkplain #getISBN() ISBN} and {@linkplain #getISSN() ISSN} codes, thus
+ * providing a unified view of every kind of identifiers associated to this citation.
+ *
+ * {@note The <code><:gmd:identifier></code> element marshalled to XML will exclude
+ * all the above cited identifiers, for ISO 19139 compliance. Those identifiers
+ * will appear in other XML elements or attributes.}
+ *
+ * @see #getISBN()
+ * @see #getISSN()
+ * @see #getIdentifierMap()
*/
@Override
@XmlElement(name = "identifier")
public synchronized Collection<Identifier> getIdentifiers() {
identifiers = nonNullCollection(identifiers, Identifier.class);
- return filterIdentifiers(identifiers);
+ return NonMarshalledAuthority.excludeOnMarshalling(identifiers);
}
/**
* Sets the unique identifier for the resource.
* Example: Universal Product Code (UPC), National Stock Number (NSN).
*
- * <p>The following exceptions apply:</p>
- * <ul>
- * <li>This method does not set the {@linkplain #getISBN() ISBN} and {@linkplain #getISSN() ISSN}
- * codes, even if they are included in the given collection. The ISBN/ISSN codes shall be set
- * by the {@link #setISBN(String)} or {@link #setISSN(String)} methods, for compliance with
- * the ISO 19115 model.</li>
- * <li>The {@linkplain IdentifierSpace XML identifiers} ({@linkplain IdentifierSpace#ID ID},
- * {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>) are ignored because.</li>
- * </ul>
+ * <p>This method overwrites all previous identifiers with the given new values,
+ * <strong>except</strong> the XML identifiers ({@linkplain IdentifierSpace#ID ID},
+ * {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>), ISBN and ISSN codes, if any.
+ * We do not overwrite the XML identifiers because they are usually associated to object
+ * identity, and we do not overwrite ISBN/ISSN codes because they have dedicated setters
+ * for compliance with the ISO 19115 model.</p>
*
* @param newValues The new identifiers, or {@code null} if none.
+ *
+ * @see #setISBN(String)
+ * @see #setISSN(String)
*/
public synchronized void setIdentifiers(final Collection<? extends Identifier> newValues) {
- final Collection<Identifier> oldIds = NonMarshalledAuthority.getIdentifiers(identifiers);
+ final Collection<Identifier> oldIds = NonMarshalledAuthority.filteredCopy(identifiers);
identifiers = writeCollection(newValues, identifiers, Identifier.class);
- NonMarshalledAuthority.setIdentifiers(identifiers, oldIds);
+ NonMarshalledAuthority.replace(identifiers, oldIds);
}
/**
@@ -489,12 +497,13 @@ public class DefaultCitation extends ISO
* return getIdentifierMap().getSpecialized(Citations.ISBN);
* }
*
+ * @see #getIdentifiers()
* @see Citations#ISBN
*/
@Override
@XmlElement(name = "ISBN")
public synchronized String getISBN() {
- return CollectionsExt.isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISBN);
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISBN);
}
/**
@@ -506,10 +515,13 @@ public class DefaultCitation extends ISO
* }
*
* @param newValue The new ISBN, or {@code null} if none.
+ *
+ * @see #setIdentifiers(Collection)
+ * @see Citations#ISBN
*/
public synchronized void setISBN(final String newValue) {
checkWritePermission();
- if (newValue != null || !CollectionsExt.isNullOrEmpty(identifiers)) {
+ if (newValue != null || !isNullOrEmpty(identifiers)) {
getIdentifierMap().putSpecialized(ISBN, newValue);
}
}
@@ -522,12 +534,13 @@ public class DefaultCitation extends ISO
* return getIdentifierMap().getSpecialized(Citations.ISSN);
* }
*
+ * @see #getIdentifiers()
* @see Citations#ISSN
*/
@Override
@XmlElement(name = "ISSN")
public synchronized String getISSN() {
- return CollectionsExt.isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISSN);
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISSN);
}
/**
@@ -539,10 +552,13 @@ public class DefaultCitation extends ISO
* }
*
* @param newValue The new ISSN.
+ *
+ * @see #setIdentifiers(Collection)
+ * @see Citations#ISSN
*/
public synchronized void setISSN(final String newValue) {
checkWritePermission();
- if (newValue != null || !CollectionsExt.isNullOrEmpty(identifiers)) {
+ if (newValue != null || !isNullOrEmpty(identifiers)) {
getIdentifierMap().putSpecialized(ISSN, newValue);
}
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -27,7 +27,7 @@ import org.apache.sis.metadata.iso.ISOMe
import org.apache.sis.internal.metadata.ExcludedSet;
import org.apache.sis.util.collection.CheckedContainer;
-import static org.apache.sis.internal.jaxb.MarshalContext.isMarshaling;
+import static org.apache.sis.internal.jaxb.MarshalContext.isMarshalling;
import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
@@ -197,7 +197,7 @@ public class DefaultScopeDescription ext
if (property == code) {
return cast(value, type);
} else if (!(value instanceof Set) || !((Set<?>) value).isEmpty()) {
- return isMarshaling() ? null : new ExcludedSet<E>(NAMES[code-1], NAMES[property-1]);
+ return isMarshalling() ? null : new ExcludedSet<E>(NAMES[code-1], NAMES[property-1]);
}
}
// Unconditionally create a new set, because the
Modified: sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -196,7 +196,7 @@ public class Envelope2D extends Rectangl
box.getSouthBoundLatitude(),
box.getEastBoundLongitude(),
box.getNorthBoundLatitude());
- try {
+ if (false) try { // TODO: excluded for now because CRS.forCode is not yet implemented.
crs = CRS.forCode("CRS:84");
} catch (FactoryException e) {
// Should never happen since we asked for a CRS which should always be present.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -16,15 +16,12 @@
*/
package org.apache.sis.internal.jaxb;
-import java.util.Collection;
import java.util.Map;
import java.util.Locale;
import java.util.TimeZone;
-import org.opengis.metadata.Identifier;
import org.apache.sis.util.Version;
import org.apache.sis.xml.ValueConverter;
import org.apache.sis.xml.ReferenceResolver;
-import org.apache.sis.util.collection.UnmodifiableArrayList;
/**
@@ -44,7 +41,7 @@ public final class MarshalContext extend
* The bit flag telling if a marshalling process is under progress.
* This flag is unset for unmarshalling processes.
*/
- public static final int MARSHALING = 1;
+ public static final int MARSHALLING = 1;
/**
* The bit flag for enabling substitution of language codes by character strings.
@@ -131,7 +128,7 @@ public final class MarshalContext extend
* @param schemas The schemas root URL, or {@code null} if none.
* @param locale The locale, or {@code null} if unspecified.
* @param timezone The timezone, or {@code null} if unspecified.
- * @param bitMasks A combination of {@link #MARSHALING}, {@link #SUBSTITUTE_LANGUAGE},
+ * @param bitMasks A combination of {@link #MARSHALLING}, {@link #SUBSTITUTE_LANGUAGE},
* {@link #SUBSTITUTE_COUNTRY} or other bit masks.
*/
public MarshalContext(final ValueConverter converter, final ReferenceResolver resolver,
@@ -223,23 +220,23 @@ public final class MarshalContext extend
* This convenience method is implemented by:
*
* {@preformat java
- * return isFlagSet(current(), MARSHALING);
+ * return isFlagSet(current(), MARSHALLING);
* }
*
* Callers should use the {@link #isFlagSet(MarshalContext, int)} method instead if the
* {@code MarshalContext} instance is known, for avoiding a call to {@link #current()}.
- *
+ *
* @return {@code true} if XML marshalling is under progress.
*/
- public static boolean isMarshaling() {
- return isFlagSet(current(), MARSHALING);
+ public static boolean isMarshalling() {
+ return isFlagSet(current(), MARSHALLING);
}
/**
* Returns {@code true} if the given flag is set.
*
* @param context The current context, or {@code null} if none.
- * @param flag One of {@link #MARSHALING}, {@link #SUBSTITUTE_LANGUAGE},
+ * @param flag One of {@link #MARSHALLING}, {@link #SUBSTITUTE_LANGUAGE},
* {@link #SUBSTITUTE_COUNTRY} or other bit masks.
* @return {@code true} if the given flag is set.
*/
@@ -334,30 +331,6 @@ public final class MarshalContext extend
}
/**
- * If marshalling, filters the given collection of identifiers in order to omit any identifiers
- * for which the authority is one of the {@link org.apache.sis.xml.IdentifierSpace} constants.
- *
- * @param identifiers The identifiers to filter, or {@code null}.
- * @return The identifiers to marshal, or {@code null} if none.
- */
- public static Collection<Identifier> filterIdentifiers(Collection<Identifier> identifiers) {
- if (identifiers != null && isFlagSet(current(), MARSHALING)) {
- int count = identifiers.size();
- if (count != 0) {
- final Identifier[] copy = identifiers.toArray(new Identifier[count]);
- for (int i=count; --i>=0;) {
- final Identifier id = copy[i];
- if (id == null || (id.getAuthority() instanceof NonMarshalledAuthority)) {
- System.arraycopy(copy, i+1, copy, i, --count - i);
- }
- }
- identifiers = (count != 0) ? UnmodifiableArrayList.wrap(copy, 0, count) : null;
- }
- }
- return identifiers;
- }
-
- /**
* Sets the locale to the given value. The old locales are remembered and will
* be restored by the next call to {@link #pull()}. This method can be invoked
* when marshalling object that need to marshall their children in a different
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -19,12 +19,17 @@ package org.apache.sis.internal.jaxb;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
import java.io.Serializable;
import java.io.ObjectStreamException;
import java.lang.reflect.Field;
import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.Citation;
import org.apache.sis.internal.simple.SimpleCitation;
+import org.apache.sis.util.collection.UnmodifiableArrayList;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.xml.IdentifierSpace;
@@ -71,6 +76,12 @@ public final class NonMarshalledAuthorit
private static final long serialVersionUID = 6299502270649111201L;
/**
+ * Sets to {@code true} if {@link #getCitation(String)} has already logged a warning.
+ * This is used in order to avoid flooding the logs with the same message.
+ */
+ private static volatile boolean warningLogged;
+
+ /**
* Ordinal values for switch statements. The constant defined here shall
* mirror the constants defined in the {@link IdentifierSpace} interface
* and {@link org.apache.sis.metadata.iso.citation.DefaultCitation} class.
@@ -164,13 +175,50 @@ public final class NonMarshalledAuthorit
}
/**
+ * If marshalling, filters the given collection of identifiers in order to omit any identifiers
+ * for which the authority is an instance of {@code NonMarshalledAuthority}. This should exclude
+ * all {@link org.apache.sis.xml.IdentifierSpace} constants.
+ *
+ * @param identifiers The identifiers to filter, or {@code null}.
+ * @return The identifiers to marshal, or {@code null} if none.
+ */
+ public static Collection<Identifier> excludeOnMarshalling(Collection<Identifier> identifiers) {
+ if (identifiers != null && MarshalContext.isMarshalling()) {
+ int count = identifiers.size();
+ if (count != 0) {
+ final Identifier[] copy = identifiers.toArray(new Identifier[count]);
+ for (int i=count; --i>=0;) {
+ final Identifier id = copy[i];
+ if (id == null || (id.getAuthority() instanceof NonMarshalledAuthority)) {
+ System.arraycopy(copy, i+1, copy, i, --count - i);
+ }
+ }
+ identifiers = (count != 0) ? UnmodifiableArrayList.wrap(copy, 0, count) : null;
+ }
+ }
+ return identifiers;
+ }
+
+ /**
* Returns a collection containing only the identifiers having a {@code NonMarshalledAuthority}.
+ * This method is invoked for saving the identifiers that are conceptually stored in distinct fields
+ * (XML identifier, UUID, ISBN, ISSN) before to overwrite the collection of all identifiers in
+ * a metadata object.
+ *
+ * <p>This method is invoked from {@code setIdentifiers(Collection<Identifier>)} implementation
+ * in {@link org.apache.sis.metadata.iso.ISOMetadata} subclasses as below:</p>
+ *
+ * {@preformat java
+ * final Collection<Identifier> oldIds = NonMarshalledAuthority.filteredCopy(identifiers);
+ * identifiers = writeCollection(newValues, identifiers, Identifier.class);
+ * NonMarshalledAuthority.replace(identifiers, oldIds);
+ * }
*
* @param <T> The type of object used as identifier values.
- * @param identifiers The identifiers to getIdentifiers, or {@code null} if none.
- * @return The filtered identifiers, or {@code null} if none.
+ * @param identifiers The metadata internal identifiers collection, or {@code null} if none.
+ * @return The new list containing the filtered identifiers, or {@code null} if none.
*/
- public static <T extends Identifier> Collection<T> getIdentifiers(final Collection<? extends T> identifiers) {
+ public static <T extends Identifier> Collection<T> filteredCopy(final Collection<T> identifiers) {
Collection<T> filtered = null;
if (identifiers != null) {
int remaining = identifiers.size();
@@ -188,29 +236,40 @@ public final class NonMarshalledAuthorit
}
/**
- * Removes from the given collection every identifiers having a {@code NonMarshalledAuthority},
- * then adds the previously filtered identifiers (if any).
+ * Replaces all identifiers in the {@code identifiers} collection having the same
+ * {@linkplain Identifier#getAuthority() authority} than the ones in {@code oldIds}.
+ * More specifically:
+ *
+ * <ul>
+ * <li>First, remove all {@code identifiers} elements having the same authority
+ * than one of the elements in {@code oldIds}.</li>
+ * <li>Next, add all {@code oldIds} elements to {@code identifiers}.</li>
+ * </ul>
*
* @param <T> The type of object used as identifier values.
- * @param identifiers The collection from which to remove identifiers, or {@code null}.
- * @param filtered The previous filtered identifiers returned by {@link #getIdentifiers}.
- */
- public static <T extends Identifier> void setIdentifiers(final Collection<T> identifiers, final Collection<T> filtered) {
- if (identifiers != null) {
- for (final Iterator<T> it=identifiers.iterator(); it.hasNext();) {
- final T id = it.next();
- if (id == null || id.getAuthority() instanceof NonMarshalledAuthority<?>) {
- it.remove();
+ * @param identifiers The metadata internal identifiers collection, or {@code null} if none.
+ * @param oldIds The previous filtered identifiers returned by {@link #filteredCopy(Collection)},
+ * or {@code null} if none.
+ */
+ public static <T extends Identifier> void replace(final Collection<T> identifiers, final Collection<T> oldIds) {
+ if (oldIds != null && identifiers != null) {
+ for (final T old : oldIds) {
+ final Citation authority = old.getAuthority();
+ for (final Iterator<T> it=identifiers.iterator(); it.hasNext();) {
+ final T id = it.next();
+ if (id == null || id.getAuthority() == authority) {
+ it.remove();
+ }
}
}
- if (filtered != null) {
- identifiers.addAll(filtered);
- }
+ identifiers.addAll(oldIds);
}
}
/**
- * Returns one of the constants in the {@link DefaultCitation} class.
+ * Returns one of the constants in the {@link DefaultCitation} class, or {@code null} if none.
+ * We need to use Java reflection because the {@code sis-metadata} module may not be in the
+ * classpath.
*/
private static IdentifierSpace<?> getCitation(final String name) throws ObjectStreamException {
try {
@@ -218,13 +277,19 @@ public final class NonMarshalledAuthorit
field.setAccessible(true);
return (IdentifierSpace<?>) field.get(null);
} catch (Exception e) {
- Logging.unexpectedException(NonMarshalledAuthority.class, "readResolve", e);
+ if (!warningLogged) {
+ warningLogged = true;
+ final LogRecord record = Errors.getResources(null).getLogRecord(Level.WARNING,
+ Errors.Keys.MissingRequiredModule_1, "sis-metadata");
+ record.setThrown(e);
+ Logging.log(NonMarshalledAuthority.class, "readResolve", record);
+ }
}
return null;
}
/**
- * Invoked at deserialization time in order to setIdentifiers the deserialized instance
+ * Invoked at deserialization time in order to replace the deserialized instance
* by the appropriate instance defined in the {@link IdentifierSpace} interface.
*/
private Object readResolve() throws ObjectStreamException {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -202,9 +202,16 @@ public final class Locales extends Stati
* country code (again either as 2 or 3 letters), optionally followed by {@code '_'} and
* the variant.
*
+ * <p>This method can be used when the caller wants the same {@code Locale} constants no
+ * matter if the language and country codes use 2 or 3 letters. Apache SIS usually don't
+ * distinguish those two cases since ISO 19139 documents have to use the 3 letters codes
+ * anyway.</p>
+ *
* @param code The language code, which may be followed by country code.
* @return The language for the given code.
* @throws IllegalArgumentException If the given code doesn't seem to be a valid locale.
+ *
+ * @see Locale#forLanguageTag(String)
*/
public static Locale parse(final String code) throws IllegalArgumentException {
final String language, country, variant;
@@ -263,6 +270,43 @@ public final class Locales extends Stati
}
/**
+ * Parses the locale encoded in the suffix of a property key. This convenience method
+ * is used when a property in a {@link java.util.Map} may have many localized variants.
+ * For example the {@code "remarks"} property may be defined by values associated to the
+ * {@code "remarks_en"} and {@code "remarks_fr"} keys, for English and French locales
+ * respectively.
+ *
+ * <p>This method infers the {@code Locale} from the property {@code key}
+ * with the following steps:</p>
+ *
+ * <ul>
+ * <li>If the given {@code key} is exactly equals to {@code prefix},
+ * then this method returns {@link Locale#ROOT}.</li>
+ * <li>Otherwise if the given {@code key} does not start with the specified {@code prefix}
+ * followed by the {@code '_'} character, then this method returns {@code null}.</li>
+ * <li>Otherwise, the characters after the {@code '_'} are parsed as an ISO language
+ * and country code by the {@link #parse(String)} method.</li>
+ * </ul>
+ *
+ * @param prefix The prefix to skip at the beginning of the {@code key}.
+ * @param key The property key from which to extract the locale.
+ * @return {@code true} if the key has been recognized, or {@code false} otherwise.
+ * @throws IllegalArgumentException if the locale after the prefix is an illegal code.
+ */
+ public static Locale parseSuffix(final String prefix, final String key) throws IllegalArgumentException {
+ if (key.startsWith(prefix)) {
+ final int offset = prefix.length();
+ if (key.length() == offset) {
+ return Locale.ROOT;
+ }
+ if (key.charAt(offset) == '_') {
+ return parse(key.substring(offset + 1));
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns {@code true} if the following code is 3 letters, or {@code false} if 2 letters.
*/
private static boolean isThreeLetters(final String code) {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -157,48 +157,6 @@ public class DefaultInternationalString
}
/**
- * Adds a string for the given property key. This is a convenience method for constructing an
- * {@code DefaultInternationalString} during iteration through the entries in a {@link Map}.
- * It infers the {@code Locale} from the property {@code key}, using the following steps:
- *
- * <ul>
- * <li>If the {@code key} does not start with the specified {@code prefix}, then
- * this method does nothing and returns {@code false}.</li>
- * <li>Otherwise, the characters after the {@code prefix} are parsed as an ISO language
- * and country code, and the {@link #add(Locale, String)} method is invoked.</li>
- * </ul>
- *
- * For example if the prefix is {@code "remarks"}, then the {@code "remarks_fr"} property key
- * stands for remarks in {@linkplain Locale#FRENCH French} while the {@code "remarks_fr_CA"}
- * property key stands for remarks in {@linkplain Locale#CANADA_FRENCH French Canadian}.
- *
- * @param prefix The prefix to skip at the beginning of the {@code key}.
- * @param key The property key which will determined the locale.
- * @param value The localized string for the specified {@code key}.
- * @return {@code true} if the key has been recognized, or {@code false} otherwise.
- * @throws IllegalArgumentException if the locale after the prefix is an illegal code,
- * or a different string value was already set for the given locale.
- */
- public boolean add(final String prefix, final String key, final String value)
- throws IllegalArgumentException
- {
- if (key.startsWith(prefix)) {
- Locale locale = null;
- final int offset = prefix.length();
- if (key.length() != offset) {
- if (key.charAt(offset) == '_') {
- locale = Locales.parse(key.substring(offset + 1));
- } else {
- return false;
- }
- }
- add(locale, value);
- return true;
- }
- return false;
- }
-
- /**
* Returns the set of locales defined in this international string.
*
* @return The set of locales.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -99,7 +99,8 @@ public interface IdentifiedObject {
Collection<? extends Identifier> getIdentifiers();
/**
- * A map view of {@linkplain #getIdentifiers() identifiers}.
+ * A map view of the {@linkplain #getIdentifiers() identifiers} collection
+ * as (<var>authority</var>, <var>code</var>) entries.
* Each {@linkplain java.util.Map.Entry map entry} is associated
* to an element from the above identifier collection in which the
* {@linkplain java.util.Map.Entry#getKey() key} is the
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -152,10 +152,10 @@ abstract class Pooled {
/**
* Returns the initial value of {@link MarshalContext#bitMasks}. Shall be 0 if this object is
- * an unmarshaller, or {@link MarshalContext#MARSHALING} if it is an {@link Unmarshaller}.
+ * an unmarshaller, or {@link MarshalContext#MARSHALLING} if it is an {@link Unmarshaller}.
*/
private int initialBitMasks() {
- return (this instanceof Marshaller) ? MarshalContext.MARSHALING : 0;
+ return (this instanceof Marshaller) ? MarshalContext.MARSHALLING : 0;
}
/**
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java?rev=1467089&r1=1467088&r2=1467089&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] Thu Apr 11 21:17:33 2013
@@ -19,6 +19,7 @@ package org.apache.sis.util;
import java.util.Locale;
import org.apache.sis.test.TestCase;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -58,10 +59,19 @@ public final strictfp class LocalesTest
}
/**
+ * Tests the {@link Locales#unique(Locale)} method.
+ */
+ @Test
+ public void testUnique() {
+ assertSame(Locale.ENGLISH, Locales.unique(new Locale("en")));
+ assertSame(Locale.FRENCH, Locales.unique(new Locale("fr")));
+ }
+
+ /**
* Tests the {@link Locales#parse(String)} method.
- * Depends on {@link #testUnique()}.
*/
@Test
+ @DependsOnMethod("testUnique")
public void testParse() {
assertSame(Locale.FRENCH, Locales.parse("fr"));
assertSame(Locale.FRENCH, Locales.parse("fra"));
@@ -79,11 +89,16 @@ public final strictfp class LocalesTest
}
/**
- * Tests the {@link Locales#unique(Locale)} method.
+ * Tests the {@link Locales#parseSuffix(String, String)} method.
*/
@Test
- public void testUnique() {
- assertSame(Locale.ENGLISH, Locales.unique(new Locale("en")));
- assertSame(Locale.FRENCH, Locales.unique(new Locale("fr")));
+ @DependsOnMethod("testParse")
+ public void testParseSuffix() {
+ assertSame(null, Locales.parseSuffix("remarks", "remark"));
+ assertSame(Locale.ROOT, Locales.parseSuffix("remarks", "remarks"));
+ assertSame(Locale.ENGLISH, Locales.parseSuffix("remarks", "remarks_en"));
+ assertSame(Locale.FRENCH, Locales.parseSuffix("remarks", "remarks_fr"));
+ assertSame(Locale.FRENCH, Locales.parseSuffix("remarks", "remarks_fra"));
+ assertSame(null, Locales.parseSuffix("remarks", "remarks2_en"));
}
}