sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Provide information about the parent of a variable. This information is useful for customized implementations of Convention.
Date Tue, 12 Mar 2019 11:10:24 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new fdedea8  Provide information about the parent of a variable. This information is
useful for customized implementations of Convention.
fdedea8 is described below

commit fdedea814dc62c4ffce88d9d491f6470c66b72eb
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Mar 12 12:09:51 2019 +0100

    Provide information about the parent of a variable. This information is useful for customized
implementations of Convention.
---
 .../java/org/apache/sis/internal/netcdf/NamedElement.java     | 10 ++++++++++
 .../main/java/org/apache/sis/internal/netcdf/ucar/Utils.java  |  3 ++-
 .../org/apache/sis/internal/netcdf/ucar/VariableWrapper.java  | 11 +++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
index bffb3d8..dce6207 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
@@ -51,6 +51,16 @@ public abstract class NamedElement {
     public abstract String getName();
 
     /**
+     * If this element is member of a group, returns the name of that group.
+     * Otherwise returns {@code null}. The default implementation always returns {@code null}.
+     *
+     * @return name of the group which contains this element, or {@code null}.
+     */
+    public String getGroupName() {
+        return null;
+    }
+
+    /**
      * Creates a name for a {@code NamedElement} made of other components.
      * Current implementation returns a separated list of component names.
      *
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/Utils.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/Utils.java
index 629b5f3..2d07542 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/Utils.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/Utils.java
@@ -18,7 +18,8 @@ package org.apache.sis.internal.netcdf.ucar;
 
 
 /**
- * Utility methods and workaround for UCAR library methods having a different behavior than
what we would expect.
+ * Utility methods completing UCAR library for Apache SIS needs.
+ * Some methods are workarounds for UCAR library methods having a different behavior than
what we would expect.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
index 1c0b007..cb3b3f5 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
@@ -24,6 +24,7 @@ import javax.measure.Unit;
 import ucar.ma2.Array;
 import ucar.ma2.Section;
 import ucar.ma2.InvalidRangeException;
+import ucar.nc2.Group;
 import ucar.nc2.Attribute;
 import ucar.nc2.VariableIF;
 import ucar.nc2.dataset.Enhancements;
@@ -126,6 +127,16 @@ final class VariableWrapper extends Variable {
     }
 
     /**
+     * If this element is member of a group, returns the name of that group.
+     * Otherwise returns {@code null}.
+     */
+    @Override
+    public String getGroupName() {
+        final Group parent = variable.getParentGroup();
+        return (parent != null) ? parent.getShortName() : null;
+    }
+
+    /**
      * Returns the name of this variable.
      */
     @Override


Mime
View raw message