sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1467088 - in /sis/branches/JDK7: sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ sis-metadata/src/main...
Date Thu, 11 Apr 2013 21:11:12 GMT
Author: desruisseaux
Date: Thu Apr 11 21:11:12 2013
New Revision: 1467088

URL: http://svn.apache.org/r1467088
Log:
Tuned the handling of identifiers collection in metadata objects.

Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] Thu Apr 11 21:11:12 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();

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
[UTF-8] Thu Apr 11 21:11:12 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>&lt:gmd:identifier&gt;</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/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] Thu Apr 11 21:11:12 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;
 
@@ -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>&lt:gmd:identifier&gt;</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/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] Thu Apr 11 21:11:12 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/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/MarshalContext.java
[UTF-8] Thu Apr 11 21:11:12 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/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
[UTF-8] Thu Apr 11 21:11:12 2013
@@ -25,7 +25,9 @@ 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;
@@ -173,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();
@@ -197,24 +236,33 @@ 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);
         }
     }
 

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java [UTF-8]
Thu Apr 11 21:11:12 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/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1467088&r1=1467087&r2=1467088&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] Thu
Apr 11 21:11:12 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;
     }
 
     /**



Mime
View raw message