sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1481776 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ sis-utility/src/main/java/org/apache/sis/internal/util/
Date Mon, 13 May 2013 10:21:50 GMT
Author: desruisseaux
Date: Mon May 13 10:21:49 2013
New Revision: 1481776

URL: http://svn.apache.org/r1481776
Log:
Added DefaultTemporalExtent.setBounds(Date, Date) convenience method.

Added:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefaultFactories.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -23,6 +23,7 @@ import org.apache.sis.metadata.iso.exten
 import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.internal.util.SystemListener;
+import org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent;
 import org.apache.sis.util.resources.Errors;
 
 
@@ -84,7 +85,7 @@ public abstract class ReferencingService
     }
 
     /**
-     * Initializes a geographic bounding box from the specified envelope. If the envelope
contains
+     * Sets a geographic bounding box from the specified envelope. If the envelope contains
      * a CRS, then the bounding box will be projected to a geographic CRS. Otherwise, the
envelope
      * is assumed already in appropriate CRS.
      *
@@ -96,7 +97,7 @@ public abstract class ReferencingService
             throws TransformException;
 
     /**
-     * Initializes a vertical extent with the value inferred from the given envelope.
+     * Sets a vertical extent with the value inferred from the given envelope.
      * Only the vertical ordinates are extracted; all other ordinates are ignored.
      *
      * @param  envelope The source envelope.
@@ -107,8 +108,8 @@ public abstract class ReferencingService
             throws TransformException;
 
     /**
-     * Initializes a temporal extent with the value inferred from the given envelope.
-     * Only the vertical ordinates are extracted; all other ordinates are ignored.
+     * Sets a temporal extent with the value inferred from the given envelope.
+     * Only the temporal ordinates are extracted; all other ordinates are ignored.
      *
      * @param  envelope The source envelope.
      * @param  target The target temporal extent.
@@ -118,6 +119,17 @@ public abstract class ReferencingService
             throws TransformException;
 
     /**
+     * Sets a temporal extent with the value inferred from the given envelope,
+     * and optionally sets a geographic bounding box if a spatial component if found.
+     *
+     * @param  envelope The source envelope.
+     * @param  target The target spatio-temporal extent.
+     * @throws TransformException If no temporal component can be extracted from the given
envelope.
+     */
+    public abstract void setBounds(Envelope envelope, DefaultSpatialTemporalExtent target)
+            throws TransformException;
+
+    /**
      * Initializes a horizontal, vertical and temporal extent with the values inferred from
      * the given envelope.
      *

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -369,7 +369,7 @@ public class DefaultGeographicBoundingBo
      *
      * @param  envelope The envelope to use for setting this geographic bounding box.
      * @throws UnsupportedOperationException if the referencing module is not on the classpath.
-     * @throws TransformException if the envelope can't be transformed.
+     * @throws TransformException if the envelope can not be transformed to a geographic
extent.
      *
      * @see DefaultExtent#addElements(Envelope)
      * @see DefaultVerticalExtent#setBounds(Envelope)

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -20,8 +20,12 @@ import java.util.Collection;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.geometry.Envelope;
 import org.opengis.metadata.extent.GeographicExtent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.metadata.extent.SpatialTemporalExtent;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.metadata.ReferencingServices;
 
 
 /**
@@ -112,4 +116,30 @@ public class DefaultSpatialTemporalExten
     public void setSpatialExtent(final Collection<? extends GeographicExtent> newValues)
{
         spatialExtent = writeCollection(newValues, spatialExtent, GeographicExtent.class);
     }
+
+    /**
+     * Sets this spatio-temporal extent to values inferred from the specified envelope.
+     * The envelope shall have at least a temporal component. If a spatial component is
+     * also found, then:
+     *
+     * <ul>
+     *   <li>If the collection of {@link #getSpatialExtent() spatial extents} contains
a
+     *       {@link GeographicBoundingBox}, then that bounding box will be updated or replaced
+     *       by a bounding box containing the spatial component of the given envelope.</li>
+     *   <li>Otherwise a new {@link DefaultGeographicBoundingBox} with the spatial
component
+     *       of the given envelope is added to the list of spatial extents.</li>
+     * </ul>
+     *
+     * <b>Note:</b> This method is available only if the {@code sis-referencing}
module is
+     * available on the classpath.
+     *
+     * @param  envelope The envelope to use for setting this spatio-temporal extent.
+     * @throws UnsupportedOperationException if the referencing module is not on the classpath.
+     * @throws TransformException if the envelope can not be transformed to a temporal extent.
+     */
+    @Override
+    public void setBounds(final Envelope envelope) throws TransformException {
+        checkWritePermission();
+        ReferencingServices.getInstance().setBounds(envelope, this);
+    }
 }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -29,6 +29,7 @@ import org.opengis.metadata.extent.Tempo
 import org.opengis.metadata.extent.SpatialTemporalExtent;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.util.TemporalUtilities;
 import org.apache.sis.internal.metadata.ReferencingServices;
 
 
@@ -180,15 +181,42 @@ public class DefaultTemporalExtent exten
     }
 
     /**
+     * Sets the temporal extent to the specified values. This convenience method creates
a temporal
+     * primitive for the given dates, then invokes {@link #setExtent(TemporalPrimitive)}.
+     *
+     * <p><b>Note:</b> This method is available only if the {@code sis-temporal}
module is available on the classpath,
+     * or any other module providing an implementation of the {@link org.opengis.temporal.TemporalFactory}
interface.</p>
+     *
+     * @param  startTime The start date and time for the content of the dataset, or {@code
null} if none.
+     * @param  endTime   The end date and time for the content of the dataset, or {@code
null} if none.
+     * @throws UnsupportedOperationException If no implementation of {@code TemporalFactory}
has been found
+     *         on the classpath.
+     */
+    public void setBounds(final Date startTime, final Date endTime) throws UnsupportedOperationException
{
+        TemporalPrimitive value = null;
+        if (startTime != null || endTime != null) {
+            if (endTime == null || endTime.equals(startTime)) {
+                value = TemporalUtilities.createInstant(startTime);
+            } else if (startTime == null) {
+                value = TemporalUtilities.createInstant(endTime);
+            } else {
+                value = TemporalUtilities.createPeriod(startTime, endTime);
+            }
+        }
+        setExtent(value);
+    }
+
+    /**
      * Sets this temporal extent to values inferred from the specified envelope. The envelope
can
      * be multi-dimensional, in which case the {@linkplain Envelope#getCoordinateReferenceSystem()
      * envelope CRS} must have a temporal component.
      *
-     * <p><b>Note:</b> This method is available only if the referencing
module is on the classpath.</p>
+     * <p><b>Note:</b> This method is available only if the {@code sis-referencing}
module is
+     * available on the classpath.</p>
      *
      * @param  envelope The envelope to use for setting this temporal extent.
      * @throws UnsupportedOperationException if the referencing module is not on the classpath.
-     * @throws TransformException if the envelope can't be transformed to a temporal extent.
+     * @throws TransformException if the envelope can not be transformed to a temporal extent.
      *
      * @see DefaultExtent#addElements(Envelope)
      * @see DefaultGeographicBoundingBox#setBounds(Envelope)

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -203,7 +203,7 @@ public class DefaultVerticalExtent exten
      *
      * @param  envelope The envelope to use for setting this vertical extent.
      * @throws UnsupportedOperationException if the referencing module is not on the classpath.
-     * @throws TransformException if the envelope can't be transformed to a vertical extent.
+     * @throws TransformException if the envelope can not be transformed to a vertical extent.
      *
      * @see DefaultExtent#addElements(Envelope)
      * @see DefaultGeographicBoundingBox#setBounds(Envelope)

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -51,41 +51,61 @@
  *
  * <p>In addition to the standard properties, SIS provides the following methods:</p>
  * <ul>
- *   <li>{@link org.apache.sis.metadata.iso.extent.Extents#getGeographicBoundingBox
- *       Extents.getGeographicBoundingBox(Extent)}
+ *   <li>{@link org.apache.sis.metadata.iso.extent.Extents}
+ *     <ul>
+ *       <li>{@link org.apache.sis.metadata.iso.extent.Extents#getGeographicBoundingBox
+ *       getGeographicBoundingBox(Extent)}
  *       for extracting a global geographic bounding box.</li>
- *
- *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#setBounds(double,
double, double, double)
- *       DefaultGeographicBoundingBox.setBounds(double, double, double, double)}
+ *     </ul>
+ *   </li>
+ *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox}
+ *     <ul>
+ *       <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#setBounds(double,
double, double, double)
+ *       setBounds(double, double, double, double)}
  *       for setting the extent from (λ,φ) values.</li>
  *
  *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#setBounds(org.opengis.geometry.Envelope)
- *       DefaultGeographicBoundingBox.setBounds(Envelope)}
+ *       setBounds(Envelope)}
  *       for setting the extent from the given envelope.</li>
  *
  *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#setBounds(org.opengis.metadata.extent.GeographicBoundingBox)
- *       DefaultGeographicBoundingBox.setBounds(GeographicBoundingBox)}
+ *       setBounds(GeographicBoundingBox)}
  *       for setting the extent from an other bounding box.</li>
  *
  *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#add
- *       DefaultGeographicBoundingBox.add(GeographicBoundingBox)}
+ *       add(GeographicBoundingBox)}
  *       for expanding this extent to include an other bounding box.</li>
  *
  *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#intersect
- *       DefaultGeographicBoundingBox.intersect(GeographicBoundingBox)}
+ *       intersect(GeographicBoundingBox)}
  *       for the intersection between the two bounding boxes.</li>
- *
- *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultVerticalExtent#setBounds
- *       DefaultVerticalExtent.setBounds(Envelope)}
+ *     </ul>
+ *   </li>
+ *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultVerticalExtent}
+ *     <ul>
+ *       <li>{@link org.apache.sis.metadata.iso.extent.DefaultVerticalExtent#setBounds
+ *       setBounds(Envelope)}
  *       for setting the vertical element from the given envelope.</li>
+ *     </ul>
+ *   </li>
+ *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultTemporalExtent}
+ *     <ul>
+ *       <li>{@link org.apache.sis.metadata.iso.extent.DefaultTemporalExtent#setBounds(java.util.Date,
java.util.Date)
+ *       setBounds(Date, Date)}
+ *       for setting the temporal element from the start time and end time.</li>
  *
- *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultTemporalExtent#setBounds
- *       DefaultTemporalExtent.setBounds(Envelope)}
+ *       <li>{@link org.apache.sis.metadata.iso.extent.DefaultTemporalExtent#setBounds(org.opengis.geometry.Envelope)
+ *       setBounds(Envelope)}
  *       for setting the temporal element from the given envelope.</li>
- *
- *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultExtent#addElements
- *       DefaultExtent.addElements(Extent)}
+ *     </ul>
+ *   </li>
+ *   <li>{@link org.apache.sis.metadata.iso.extent.DefaultExtent}
+ *     <ul>
+ *       <li>{@link org.apache.sis.metadata.iso.extent.DefaultExtent#addElements
+ *       addElements(Extent)}
  *       for adding extent elements inferred from the given envelope.</li>
+ *     </ul>
+ *   </li>
  * </ul>
  *
  * {@section Null values, nil objects and collections}

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefaultFactories.java?rev=1481776&r1=1481775&r2=1481776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefaultFactories.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefaultFactories.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -16,8 +16,10 @@
  */
 package org.apache.sis.internal.util;
 
+import java.util.Map;
+import java.util.IdentityHashMap;
+import java.util.ServiceLoader;
 import org.opengis.util.NameFactory;
-import org.apache.sis.util.Static;
 import org.apache.sis.util.iso.DefaultNameFactory;
 
 
@@ -30,15 +32,60 @@ import org.apache.sis.util.iso.DefaultNa
  * @version 0.3
  * @module
  */
-public final class DefaultFactories extends Static {
+public final class DefaultFactories extends SystemListener {
     /**
      * The factory to use for creating names.
      */
     public static final NameFactory NAMES = new DefaultNameFactory();
 
     /**
-     * Do not allow instantiation of this class.
+     * Cache of factories which are found by {@code META-INF/services}.
+     */
+    private static final Map<Class<?>, Object> FACTORIES = new IdentityHashMap<>(4);
+    static {
+        FACTORIES.put(NameFactory.class, NAMES);
+        SystemListener.add(new DefaultFactories());
+    }
+
+    /**
+     * For the singleton system listener only.
      */
     private DefaultFactories() {
     }
+
+    /**
+     * Discards cached factories when the classpath has changed.
+     */
+    @Override
+    protected void classpathChanged() {
+        synchronized (DefaultFactories.class) {
+            FACTORIES.clear();
+            FACTORIES.put(NameFactory.class, NAMES);
+        }
+    }
+
+    /**
+     * Return the default factory implementing the given interface.
+     * This method will give preference to Apache SIS factories if any.
+     *
+     * @param  <T>  The interface type.
+     * @param  type The interface type.
+     * @return A factory implementing the given interface, or {@code null} if none.
+     */
+    public static synchronized <T> T forClass(final Class<T> type) {
+        T factory = type.cast(FACTORIES.get(type));
+        if (factory == null && !FACTORIES.containsKey(type)) {
+            for (final T candidate : ServiceLoader.load(type)) {
+                if (candidate.getClass().getName().startsWith("org.apache.sis.")) {
+                    factory = candidate;
+                    break;
+                }
+                if (factory == null) {
+                    factory = candidate;
+                }
+            }
+            FACTORIES.put(type, factory);
+        }
+        return factory;
+    }
 }

Added: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java?rev=1481776&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
(added)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
[UTF-8] Mon May 13 10:21:49 2013
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.util;
+
+import java.util.Date;
+import org.opengis.temporal.Instant;
+import org.opengis.temporal.Period;
+import org.opengis.temporal.TemporalFactory;
+import org.apache.sis.util.Static;
+import org.apache.sis.util.resources.Errors;
+
+
+/**
+ * Utilities related to ISO 19108 objects. This class may disappear after we reviewed
+ * the GeoAPI-pending temporal interfaces.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.3 (derived from geotk-3.20)
+ * @version 0.3
+ * @module
+ */
+public final class TemporalUtilities extends Static {
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private TemporalUtilities() {
+    }
+
+    /**
+     * Returns a temporal factory if available.
+     *
+     * @throws UnsupportedOperationException If the temporal factory is not available on
the classpath.
+     */
+    private static TemporalFactory getTemporalFactory() throws UnsupportedOperationException
{
+        final TemporalFactory factory = DefaultFactories.forClass(TemporalFactory.class);
+        if (factory != null) {
+            return factory;
+        }
+        throw new UnsupportedOperationException(Errors.format(Errors.Keys.MissingRequiredModule_1,
"sis-temporal"));
+    }
+
+    /**
+     * Creates an instant for the given date using the given factory.
+     */
+    private static Instant createInstant(final TemporalFactory factory, final Date date)
{
+        return factory.createInstant(factory.createPosition(date));
+    }
+
+    /**
+     * Creates an instant for the given date.
+     *
+     * @param  time The date for which to create instant.
+     * @return The instant.
+     * @throws UnsupportedOperationException If the temporal factory is not available on
the classpath.
+     */
+    public static Instant createInstant(final Date time) throws UnsupportedOperationException
{
+        return createInstant(getTemporalFactory(), time);
+    }
+
+    /**
+     * Creates a period for the given begin and end dates. The given arguments can be null
if the
+     * {@link TemporalFactory#createPosition(Date)} method accepts null dates, which stand
for
+     * undetermined position.
+     *
+     * @param  begin The begin date, inclusive.
+     * @param  end The end date, inclusive.
+     * @return The period.
+     * @throws UnsupportedOperationException If the temporal factory is not available on
the classpath.
+     */
+    public static Period createPeriod(final Date begin, final Date end) throws UnsupportedOperationException
{
+        final TemporalFactory factory = getTemporalFactory();
+        return factory.createPeriod(createInstant(factory, begin), createInstant(factory,
end));
+    }
+}

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8



Mime
View raw message