sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1625096 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-referencing/src/main/java/org/apache/sis/parameter/
Date Mon, 15 Sep 2014 17:16:06 GMT
Author: desruisseaux
Date: Mon Sep 15 17:16:05 2014
New Revision: 1625096

URL: http://svn.apache.org/r1625096
Log:
Connect ServiceParameter (an internal class) to DefaultParameterDescriptor (the public class).
The later is defined from ISO 19111, while the former is used only internally for ISO 19115
support.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java?rev=1625096&r1=1625095&r2=1625096&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
[UTF-8] Mon Sep 15 17:16:05 2014
@@ -32,6 +32,7 @@ import org.opengis.parameter.ParameterDe
 import org.opengis.referencing.ReferenceIdentifier;
 import org.apache.sis.internal.simple.SimpleIdentifiedObject;
 import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName;
+import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.iso.Names;
@@ -125,6 +126,12 @@ public final class ServiceParameter exte
     public boolean repeatability;
 
     /**
+     * A copy of {@code this} as a fully-implemented parameter descriptor.
+     * This is created when first needed for implementation of {@link #createValue()}.
+     */
+    private transient ParameterDescriptor descriptor;
+
+    /**
      * Creates an initially empty parameter.
      * This constructor is needed by JAXB.
      *
@@ -160,7 +167,7 @@ public final class ServiceParameter exte
     }
 
     /**
-     * Gets the parameter name as a {@code MemberName}. This method first check if the primary
name is an instance of
+     * Gets the parameter name as a {@code MemberName}. This method first checks if the primary
name is an instance of
      * {@code MemberName}. If not, this method searches for the first alias which is an instance
of {@code MemberName}.
      * If none is found, then this method tries to build a member name from the primary name
and value class.
      *
@@ -302,9 +309,23 @@ public final class ServiceParameter exte
     @Override public Object        getDefaultValue() {return null;}
     @Override public Unit<?>       getUnit()         {return null;}
 
+    /**
+     * Creates a new instance of {@code ParameterValue}.
+     * This method delegates the work to {@link org.apache.sis.parameter.DefaultParameterDescriptor}
+     * since this {@code ServiceParameter} class is not a full-featured parameter descriptor
implementation.
+     *
+     * @return A new instance of {@code ParameterValue}.
+     */
     @Override
     public ParameterValue<?> createValue() {
-        throw new UnsupportedOperationException("Not supported yet."); // TODO
+        ParameterDescriptor<?> desc;
+        synchronized (this) {
+            desc = descriptor;
+            if (desc == null) {
+                descriptor = desc = ReferencingServices.getInstance().toImplementation(this);
+            }
+        }
+        return desc.createValue();
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1625096&r1=1625095&r2=1625096&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Mon Sep 15 17:16:05 2014
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.metadata;
 
 import org.opengis.geometry.Envelope;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
@@ -38,8 +39,8 @@ import org.apache.sis.util.resources.Err
  * implementation using Java reflection.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.4 (derived from geotk-3.18)
- * @version 0.3
+ * @since   0.3 (derived from geotk-3.18)
+ * @version 0.5
  * @module
  */
 public abstract class ReferencingServices extends SystemListener {
@@ -118,6 +119,16 @@ public abstract class ReferencingService
     public abstract Matrix getMatrix(MathTransform tr);
 
     /**
+     * Returns a fully implemented parameter descriptor.
+     *
+     * @param  parameter A partially implemented parameter descriptor, or {@code null}.
+     * @return A fully implemented parameter descriptor, or {@code null} if the given argument
was null.
+     *
+     * @since 0.5
+     */
+    public abstract ParameterDescriptor<?> toImplementation(ParameterDescriptor<?>
parameter);
+
+    /**
      * Converts the given object in a {@link org.apache.sis.io.wkt.FormattableObject} instance.
      *
      * @param  object The object to wrap.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1625096&r1=1625095&r2=1625096&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] Mon Sep 15 17:16:05 2014
@@ -17,8 +17,10 @@
 package org.apache.sis.parameter;
 
 import javax.measure.unit.Unit;
-import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.util.MemberName;
 import org.opengis.parameter.ParameterValue;
+import org.opengis.parameter.ParameterDescriptor;
+import org.apache.sis.internal.jaxb.metadata.replace.ServiceParameter;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.measure.MeasurementRange;
@@ -31,7 +33,7 @@ import org.apache.sis.util.Static;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Parameters extends Static {
@@ -136,4 +138,27 @@ public final class Parameters extends St
         }
         return null;
     }
+
+    /**
+     * Gets the parameter name as an instance of {@code MemberName}.
+     * This method first checks if the {@linkplain DefaultParameterDescriptor#getName()}
primary name is an instance of
+     * {@code MemberName}. If not, this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias()
+     * alias} which is an instance of {@code MemberName}. If none is found, then this method
tries to build a member name
+     * from the primary name and {@linkplain DefaultParameterDescriptor#getValueClass() value
class} using the mapping
+     * defined in {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.
+     *
+     * <p>This method can be used as a bridge between the parameter object
+     * defined by ISO 19111 (namely {@code CC_OperationParameter}) and the one
+     * defined by ISO 19115 (namely {@code SV_Parameter}).</p>
+     *
+     * @param  parameter The parameter from which to get the name (may be {@code null}).
+     * @return The member name, or {@code null} if none.
+     *
+     * @see org.apache.sis.util.iso.Names#createMemberName(CharSequence, String, CharSequence,
Class)
+     *
+     * @since 0.5
+     */
+    public static MemberName getMemberName(final ParameterDescriptor<?> parameter)
{
+        return ServiceParameter.getMemberName(parameter);
+    }
 }



Mime
View raw message