sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1467465 - in /sis/branches/JDK7: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-referencing/src/main/java/org/apache/sis/geometry/ sis-utility/src/main/java/org...
Date Fri, 12 Apr 2013 21:04:34 GMT
Author: desruisseaux
Date: Fri Apr 12 21:04:34 2013
New Revision: 1467465

URL: http://svn.apache.org/r1467465
Log:
Renamed (again!) UnmodifiableIdentifier as ImmutableIdentifier, which reflect better
the intend and is consistent with ImmutableEnvelope. Added javadoc explaining the
limits of the immutability contract.

Added:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
      - copied, changed from r1467349, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java
Removed:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java
Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Deprecable.java

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java?rev=1467465&r1=1467464&r2=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java
[UTF-8] Fri Apr 12 21:04:34 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.metadata.iso.UnmodifiableIdentifier;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.internal.jaxb.gco.PropertyType;
 
 
@@ -107,11 +107,11 @@ public final class MD_Identifier extends
      * @return The metadata to be marshalled.
      */
     @XmlElement(name = "RS_Identifier")
-    public UnmodifiableIdentifier getReferenceIdentifier() {
+    public ImmutableIdentifier getReferenceIdentifier() {
         if (!skip()) {
             final Identifier metadata = this.metadata;
             if (metadata instanceof ReferenceIdentifier) {
-                return UnmodifiableIdentifier.castOrCopy((ReferenceIdentifier) metadata);
+                return ImmutableIdentifier.castOrCopy((ReferenceIdentifier) metadata);
             }
         }
         return null;
@@ -122,7 +122,7 @@ public final class MD_Identifier extends
      *
      * @param metadata The unmarshalled metadata.
      */
-    public void setReferenceIdentifier(final UnmodifiableIdentifier metadata) {
+    public void setReferenceIdentifier(final ImmutableIdentifier metadata) {
         this.metadata = metadata;
     }
 }

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java?rev=1467465&r1=1467464&r2=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java
[UTF-8] Fri Apr 12 21:04:34 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.metadata.iso.UnmodifiableIdentifier;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
 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 UnmodifiableIdentifier getElement() {
+    public ImmutableIdentifier getElement() {
         if (skip()) return null;
         final ReferenceIdentifier metadata = this.metadata;
-        if (metadata instanceof UnmodifiableIdentifier) {
-            return (UnmodifiableIdentifier) metadata;
+        if (metadata instanceof ImmutableIdentifier) {
+            return (ImmutableIdentifier) metadata;
         } else {
-            return new UnmodifiableIdentifier(metadata);
+            return new ImmutableIdentifier(metadata);
         }
     }
 
@@ -96,7 +96,7 @@ public final class RS_Identifier extends
      *
      * @param metadata The unmarshalled metadata.
      */
-    public void setElement(final UnmodifiableIdentifier metadata) {
+    public void setElement(final ImmutableIdentifier metadata) {
         this.metadata = metadata;
     }
 }

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java?rev=1467465&r1=1467464&r2=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] Fri Apr 12 21:04:34 2013
@@ -32,6 +32,8 @@ import org.opengis.metadata.citation.Cit
  * @since   0.3 (derived from geotk-2.1)
  * @version 0.3
  * @module
+ *
+ * @see ImmutableIdentifier
  */
 @XmlType(name = "MD_Identifier_Type", propOrder = {
     "code",

Copied: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
(from r1467349, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?p2=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java&r1=1467349&r2=1467465&rev=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/UnmodifiableIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Fri Apr 12 21:04:34 2013
@@ -51,18 +51,25 @@ import java.util.Objects;
 
 
 /**
- * Unmodifiable value uniquely identifying an object within a namespace, together with a
version.
+ * Immutable value uniquely identifying an object within a namespace, together with a version.
  * This kind of identifier is primarily used for identification of
  * {@link org.opengis.referencing.crs.CoordinateReferenceSystem} objects.
  *
+ * {@note While <code>ImmutableIdentifier</code> objects are immutable, they
may contain references to
+ *        <code>Citation</code> and <code>InternationalString</code>
objects which are not guaranteed
+ *        to be immutable. For better safety, factory codes are encouraged to pass only immutable
+ *        citations and immutable international strings to the constructors.}
+ *
  * @author Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.03)
  * @version 0.3
  * @module
+ *
+ * @see DefaultIdentifier
  */
 @Immutable
 @XmlRootElement(name = "RS_Identifier")
-public class UnmodifiableIdentifier implements ReferenceIdentifier, Deprecable, Serializable
{
+public class ImmutableIdentifier implements ReferenceIdentifier, Deprecable, Serializable
{
     /**
      * For cross-version compatibility.
      */
@@ -119,7 +126,7 @@ public class UnmodifiableIdentifier impl
     /**
      * Empty constructor for JAXB.
      */
-    private UnmodifiableIdentifier() {
+    private ImmutableIdentifier() {
         code      = null;
         codeSpace = null;
         authority = null;
@@ -134,14 +141,14 @@ public class UnmodifiableIdentifier impl
      *
      * @param identifier The identifier to copy.
      */
-    public UnmodifiableIdentifier(final ReferenceIdentifier identifier) {
+    public ImmutableIdentifier(final ReferenceIdentifier identifier) {
         ensureNonNull("identifier", identifier);
         code      = identifier.getCode();
         codeSpace = identifier.getCodeSpace();
         authority = identifier.getAuthority();
         version   = identifier.getVersion();
-        if (identifier instanceof UnmodifiableIdentifier) {
-            remarks = ((UnmodifiableIdentifier) identifier).getRemarks();
+        if (identifier instanceof ImmutableIdentifier) {
+            remarks = ((ImmutableIdentifier) identifier).getRemarks();
         } else {
             remarks = null;
         }
@@ -160,7 +167,7 @@ public class UnmodifiableIdentifier impl
      *          Identifier code or name, optionally from a controlled list or pattern defined
by
      *          a code space. The code can not be null.
      */
-    public UnmodifiableIdentifier(final Citation authority, final String codeSpace, final
String code) {
+    public ImmutableIdentifier(final Citation authority, final String codeSpace, final String
code) {
         this(authority, codeSpace, code, null, null);
     }
 
@@ -183,7 +190,7 @@ public class UnmodifiableIdentifier impl
      * @param remarks
      *          Comments on or information about this identifier, or {@code null} if none.
      */
-    public UnmodifiableIdentifier(final Citation authority, final String codeSpace,
+    public ImmutableIdentifier(final Citation authority, final String codeSpace,
             final String code, final String version, final InternationalString remarks)
     {
         ensureNonNull("code", code);
@@ -242,7 +249,7 @@ public class UnmodifiableIdentifier impl
      * @throws InvalidParameterValueException if a property has an invalid value.
      * @throws IllegalArgumentException if a property is invalid for some other reason.
      */
-    public UnmodifiableIdentifier(final Map<String,?> properties) throws IllegalArgumentException
{
+    public ImmutableIdentifier(final Map<String,?> properties) throws IllegalArgumentException
{
         ensureNonNull("properties", properties);
         Object code      = null;
         Object codeSpace = null;
@@ -318,7 +325,7 @@ public class UnmodifiableIdentifier impl
             if (remarks == null) {
                 remarks = localized;
             } else {
-                Logging.log(UnmodifiableIdentifier.class, "<init>",
+                Logging.log(ImmutableIdentifier.class, "<init>",
                     Messages.getResources(null).getLogRecord(Level.WARNING, Messages.Keys.LocalesDiscarded));
             }
         }
@@ -400,9 +407,9 @@ public class UnmodifiableIdentifier impl
      * <ul>
      *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
      *   <li>Otherwise if the given object is already an instance of
-     *       {@code UnmodifiableIdentifier}, then it is returned unchanged.</li>
-     *   <li>Otherwise a new {@code UnmodifiableIdentifier} instance is created using
the
-     *       {@linkplain #UnmodifiableIdentifier(ReferenceIdentifier) copy constructor}
+     *       {@code ImmutableIdentifier}, then it is returned unchanged.</li>
+     *   <li>Otherwise a new {@code ImmutableIdentifier} instance is created using
the
+     *       {@linkplain #ImmutableIdentifier(ReferenceIdentifier) copy constructor}
      *       and returned. Note that this is a <cite>shallow</cite> copy operation,
since the other
      *       metadata contained in the given object are not recursively copied.</li>
      * </ul>
@@ -411,11 +418,11 @@ public class UnmodifiableIdentifier impl
      * @return A SIS implementation containing the values of the given object (may be the
      *         given object itself), or {@code null} if the argument was null.
      */
-    public static UnmodifiableIdentifier castOrCopy(final ReferenceIdentifier object) {
-        if (object == null || object instanceof UnmodifiableIdentifier) {
-            return (UnmodifiableIdentifier) object;
+    public static ImmutableIdentifier castOrCopy(final ReferenceIdentifier object) {
+        if (object == null || object instanceof ImmutableIdentifier) {
+            return (ImmutableIdentifier) object;
         }
-        return new UnmodifiableIdentifier(object);
+        return new ImmutableIdentifier(object);
     }
 
     /**
@@ -472,8 +479,9 @@ public class UnmodifiableIdentifier impl
     /**
      * Comments on or information about this identifier, or {@code null} if none.
      *
-     * @return Optional comments about this identifier.
+     * @return Optional comments about this identifier, or {@code null} if none.
      */
+    @Override
     public InternationalString getRemarks() {
         return remarks;
     }
@@ -520,7 +528,7 @@ public class UnmodifiableIdentifier impl
             return true;
         }
         if (object != null && object.getClass() == getClass()) {
-            final UnmodifiableIdentifier that = (UnmodifiableIdentifier) object;
+            final ImmutableIdentifier that = (ImmutableIdentifier) object;
             return Objects.equals(code,      that.code)      &&
                    Objects.equals(codeSpace, that.codeSpace) &&
                    Objects.equals(authority, that.authority) &&

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java?rev=1467465&r1=1467464&r2=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
[UTF-8] Fri Apr 12 21:04:34 2013
@@ -38,6 +38,11 @@ import static org.apache.sis.util.Argume
  * This class is final in order to ensure that the immutability contract can not be broken
  * (assuming not using <cite>Java Native Interface</cite> or reflections).
  *
+ * {@note While <code>ImmutableEnvelope</code> objects are immutable, they contain
references to
+ *        <code>CoordinateReferenceSystem</code> objects which are not guaranteed
to be immutable.
+ *        For better safety, factory codes are encouraged to pass only immutable instances
of
+ *        coordinate reference systems to the constructors.}
+ *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-3.00)

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Deprecable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Deprecable.java?rev=1467465&r1=1467464&r2=1467465&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Deprecable.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Deprecable.java [UTF-8]
Fri Apr 12 21:04:34 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.util;
 
+import org.opengis.util.InternationalString;
+
 
 /**
  * Interface of classes for which deprecated instances may exist. Deprecated instances exist
in some
@@ -41,4 +43,14 @@ public interface Deprecable {
      * @return {@code true} if this instance is deprecated.
      */
     boolean isDeprecated();
+
+    /**
+     * If this instance is deprecated, the reason or the alternative to use.
+     * Otherwise, an optional free text.
+     *
+     * @return Comments about this instance, or {@code null} if none. Shall be the
+     *         reason for deprecation or the alternative to use if this instance
+     *         {@linkplain #isDeprecated() is deprecated}.
+     */
+    InternationalString getRemarks();
 }



Mime
View raw message