sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1496394 - in /sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml: GMLAdapter.java TM_Primitive.java TimeInstant.java TimePeriod.java TimePeriodBound.java package-info.java
Date Tue, 25 Jun 2013 09:46:44 GMT
Author: desruisseaux
Date: Tue Jun 25 09:46:43 2013
New Revision: 1496394

URL: http://svn.apache.org/r1496394
Log:
Ported the TM_Primitive adapter (temporal schema).

Added:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
  (with props)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
  (with props)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
  (with props)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/GMLAdapter.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/package-info.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/GMLAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/GMLAdapter.java?rev=1496394&r1=1496393&r2=1496394&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/GMLAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/GMLAdapter.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -19,7 +19,6 @@ package org.apache.sis.internal.jaxb.gml
 import javax.xml.bind.annotation.XmlID;
 import javax.xml.bind.annotation.XmlAttribute;
 import org.apache.sis.util.Version;
-import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.IdentifierMap;
 import org.apache.sis.xml.IdentifierSpace;
 import org.apache.sis.xml.IdentifiedObject;
@@ -66,7 +65,7 @@ public abstract class GMLAdapter {
      * @see org.apache.sis.internal.jaxb.gco.ObjectReference#getUUIDREF()
      */
     @XmlID
-    @XmlAttribute(required = true, namespace = Namespaces.GML)
+    @XmlAttribute(required = true)
     private String id;
 
     /**

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1496394&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -0,0 +1,182 @@
+/*
+ * 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.jaxb.gml;
+
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import javax.xml.bind.annotation.XmlElement;
+import org.opengis.temporal.Period;
+import org.opengis.temporal.Instant;
+import org.opengis.temporal.TemporalPrimitive;
+import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.XmlUtilities;
+import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.internal.util.TemporalUtilities;
+import org.apache.sis.util.resources.Errors;
+
+
+/**
+ * JAXB adapter for {@link TemporalPrimitive}, in order to integrate the value in an element
complying
+ * with OGC/ISO standard. Note that the CRS is formatted using the GML schema, not the ISO
19139 one.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.00)
+ * @version 0.3
+ * @module
+ */
+public final class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive>
{
+    /**
+     * Empty constructor for JAXB.
+     */
+    public TM_Primitive() {
+    }
+
+    /**
+     * Wraps a Temporal Primitive value at marshalling-time.
+     *
+     * @param metadata The metadata value to marshal.
+     */
+    private TM_Primitive(final TemporalPrimitive metadata) {
+        super(metadata);
+    }
+
+    /**
+     * Returns the Vertical CRS value wrapped by a temporal primitive element.
+     *
+     * @param  value The value to marshal.
+     * @return The adapter which wraps the metadata value.
+     */
+    @Override
+    protected TM_Primitive wrap(final TemporalPrimitive value) {
+        return new TM_Primitive(value);
+    }
+
+    /**
+     * Returns the GeoAPI interface which is bound by this adapter.
+     */
+    @Override
+    protected Class<TemporalPrimitive> getBoundType() {
+        return TemporalPrimitive.class;
+    }
+
+    /**
+     * Returns the {@code TimePeriod} generated from the metadata value.
+     * This method is systematically called at marshalling-time by JAXB.
+     *
+     * @return The time period, or {@code null}.
+     */
+    @XmlElement(name = "TimePeriod")
+    public TimePeriod getTimePeriod() {
+        if (!skip()) {
+            final TemporalPrimitive metadata = this.metadata;
+            if (metadata instanceof Period) {
+                return new TimePeriod((Period) metadata);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns the {@link TimeInstant} generated from the metadata value.
+     * This method is systematically called at marshalling-time by JAXB.
+     *
+     * @return The time instant, or {@code null}.
+     */
+    @XmlElement(name = "TimeInstant")
+    public TimeInstant getTimeInstant() {
+        if (!skip()) {
+            final TemporalPrimitive metadata = this.metadata;
+            if (metadata instanceof Instant) {
+                return new TimeInstant((Instant) metadata);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Sets the value from the {@link TimePeriod}.
+     * This method is called at unmarshalling-time by JAXB.
+     *
+     * @param period The adapter to set.
+     */
+    public void setTimePeriod(final TimePeriod period) {
+        metadata = null; // Cleaned first in case of failure.
+        if (period != null) {
+            final Date begin = toDate(period.begin);
+            final Date end   = toDate(period.end);
+            if (begin != null || end != null) {
+                if (begin != null && end != null && end.before(begin)) {
+                    /*
+                     * Be tolerant - we can treat such case as an empty range, which is a
similar
+                     * approach to what JDK does for Rectangle width and height. We will
log with
+                     * TemporalPrimitive as the source class, since it is the closest we
can get
+                     * to a public API.
+                     */
+                    final Context context = Context.current();
+                    final LogRecord record = Errors.getResources(context != null ? context.getLocale()
: null)
+                            .getLogRecord(Level.WARNING, Errors.Keys.IllegalRange_2, begin,
end);
+                    record.setSourceClassName(TemporalPrimitive.class.getName());
+                    record.setSourceMethodName("setTimePeriod");
+                    Context.warningOccured(context, this, record);
+                } else try {
+                    metadata = TemporalUtilities.createPeriod(begin, end);
+                    period.copyIdTo(metadata);
+                } catch (UnsupportedOperationException e) {
+                    warningOccured("setTimePeriod", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Sets the value from the {@link TimeInstant}.
+     * This method is called at unmarshalling-time by JAXB.
+     *
+     * @param instant The adapter to set.
+     */
+    public void setTimeInstant(final TimeInstant instant) {
+        metadata = null; // Cleaned first in case of failure.
+        if (instant != null) {
+            final Date position = XmlUtilities.toDate(instant.timePosition);
+            if (position != null) try {
+                metadata = TemporalUtilities.createInstant(position);
+                instant.copyIdTo(metadata);
+            } catch (UnsupportedOperationException e) {
+                warningOccured("setTimeInstant", e);
+            }
+        }
+    }
+
+    /**
+     * Returns the date of the given bounds, or {@code null} if none.
+     */
+    private static Date toDate(final TimePeriodBound bound) {
+        return (bound != null) ? XmlUtilities.toDate(bound.calendar()) : null;
+    }
+
+    /**
+     * Reports a warning for the given exception.
+     *
+     * @param method The name of the method to declare in the log record.
+     * @param e the exception.
+     */
+    private void warningOccured(final String method, final Exception e) {
+        Context.warningOccured(Context.current(), this, TM_Primitive.class, method, e, true);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java?rev=1496394&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -0,0 +1,105 @@
+/*
+ * 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.jaxb.gml;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.datatype.DatatypeConfigurationException;
+import org.opengis.temporal.Instant;
+import org.opengis.temporal.Position;
+import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.XmlUtilities;
+
+
+/**
+ * Encapsulates a {@code gml:TimeInstant}. This element may be used alone, or included in
a
+ * {@link TimePeriodBound.GML2} object. The later is itself included in {@link TimePeriod}.
+ * Note that GML3 does not anymore include {@code TimeInstant} inside {@code TimePeriod}.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.3 (derived from geotk-3.20)
+ * @version 0.3
+ * @module
+ */
+@XmlRootElement(name="TimeInstant")
+@XmlType(name = "TimeInstantType")
+public final class TimeInstant extends GMLAdapter {
+    /**
+     * The date, optionally with its time component. The time component is omitted
+     * if the hours, minutes, seconds and milliseconds fields are all set to 0.
+     *
+     * <p><strong>WARNING: The timezone information may be lost!</strong>
This is because this field
+     * is derived from a {@link java.util.Date}, in which case we don't know if the time
is really 0
+     * or just unspecified. This class assumes that a time of zero means "unspecified". This
will be
+     * revised after we implemented ISO 19108.</p>
+     */
+    @XmlElement
+    public XMLGregorianCalendar timePosition;
+
+    /**
+     * Empty constructor used by JAXB.
+     */
+    public TimeInstant() {
+    }
+
+    /**
+     * Creates a new time instant initialized to the given value.
+     *
+     * @param instant The initial instant value.
+     */
+    public TimeInstant(final Instant instant) {
+        timePosition = toXML(instant);
+    }
+
+    /**
+     * Creates a XML Gregorian Calendar from the given instants, if non-null.
+     * Otherwise returns {@code null}.
+     *
+     * <p><strong>WARNING: The timezone information may be lost!</strong>
This is because this field
+     * is derived from a {@link java.util.Date}, in which case we don't know if the time
is really 0
+     * or just unspecified. This class assumes that a time of zero means "unspecified". This
will be
+     * revised after we implemented ISO 19108.</p>
+     */
+    static XMLGregorianCalendar toXML(final Instant instant) {
+        if (instant != null) {
+            final Position position = instant.getPosition();
+            if (position != null) {
+                final Context context = Context.current();
+                try {
+                    final XMLGregorianCalendar date = XmlUtilities.toXML(context, position.getDate());
+                    if (date != null) {
+                        XmlUtilities.trimTime(date, false);
+                        return date;
+                    }
+                } catch (DatatypeConfigurationException e) {
+                    Context.warningOccured(context, position, TimeInstant.class, "toXML",
e, true);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns a string representation for debugging and formatting error message.
+     */
+    @Override
+    public String toString() {
+        return "TimeInstant[" + timePosition + ']';
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java?rev=1496394&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -0,0 +1,96 @@
+/*
+ * 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.jaxb.gml;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.temporal.Period;
+import org.apache.sis.internal.jaxb.Context;
+
+
+/**
+ * The adapter for {@code "TimePeriod"}. This is an attribute of {@link TM_Primitive}.
+ *
+ * @todo A time period can also be expressed as a begin position and a period or duration.
+ *       This is not yet supported in the current implementation.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.00)
+ * @version 0.3
+ * @module
+ */
+@XmlRootElement(name="TimePeriod")
+@XmlType(name = "TimePeriodType", propOrder = {
+    "begin",
+    "end"
+})
+public final class TimePeriod extends GMLAdapter {
+    /**
+     * The start time, which may be marshalled in a GML3 way or GML2 way.
+     * The GML2 way is more verbose.
+     */
+    @XmlElements({
+        @XmlElement(type=TimePeriodBound.GML3.class, name="beginPosition"),
+        @XmlElement(type=TimePeriodBound.GML2.class, name="begin")
+    })
+    TimePeriodBound begin;
+
+    /**
+     * The end time, which may be marshalled in a GML3 way or GML2 way.
+     * The GML2 way is more verbose.
+     */
+    @XmlElements({
+        @XmlElement(type=TimePeriodBound.GML3.class, name="endPosition"),
+        @XmlElement(type=TimePeriodBound.GML2.class, name="end")
+    })
+    TimePeriodBound end;
+
+    /**
+     * Empty constructor used by JAXB.
+     */
+    public TimePeriod() {
+    }
+
+    /**
+     * Creates a new Time Period bounded by the begin and end time specified in the given
object.
+     *
+     * @param period The period to use for initializing this object.
+     */
+    public TimePeriod(final Period period) {
+        super(period);
+        if (period != null) {
+            if (Context.isGMLVersion(Context.current(), GML_3_0)) {
+                begin = new TimePeriodBound.GML3(period.getBeginning(), "before");
+                end   = new TimePeriodBound.GML3(period.getEnding(), "after");
+            } else {
+                begin = new TimePeriodBound.GML2(period.getBeginning());
+                end   = new TimePeriodBound.GML2(period.getEnding());
+            }
+        }
+    }
+
+    /**
+     * Returns a string representation for debugging and formatting error message.
+     */
+    @Override
+    public String toString() {
+        return "TimePeriod[" + begin + " … " + end + ']';
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java?rev=1496394&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -0,0 +1,172 @@
+/*
+ * 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.jaxb.gml;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.datatype.XMLGregorianCalendar;
+import org.opengis.temporal.Instant;
+
+
+/**
+ * The {@linkplain TimePeriod#begin begin} or {@linkplain TimePeriod#end end} position in
+ * a {@link TimePeriod}. This information is encoded in different way depending if we are
+ * reading or formatting a GML2 or GML2 file.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.20)
+ * @version 0.3
+ * @module
+ */
+@XmlTransient
+abstract class TimePeriodBound {
+    /**
+     * Empty constructor for subclasses only.
+     */
+    TimePeriodBound() {
+    }
+
+    /**
+     * Returns the XML calendar, or {@code null} if none. This information is encoded
+     * in different fields depending if we are reading/writing a GML2 or a GML3 file.
+     */
+    abstract XMLGregorianCalendar calendar();
+
+    /**
+     * Returns a string representation of this bound for debugging purpose.
+     */
+    @Override
+    public String toString() {
+        return String.valueOf(calendar());
+    }
+
+    /**
+     * The begin or end position in a {@link TimePeriod}, expressed in the GML 3 way.
+     * Example:
+     *
+     * {@preformat xml
+     *   <gml:TimePeriod>
+     *     <gml:beginPosition>1992-01-01T01:00:00.000+01:00</gml:beginPosition>
+     *     <gml:endPosition>2007-12-31T01:00:00.000+01:00</gml:endPosition>
+     *   </gml:TimePeriod>
+     * }
+     */
+    public static final class GML3 extends TimePeriodBound {
+        /**
+         * A textual indication of the time, usually {@code "before"}, {@code "after"} or
{@code "now"}.
+         * This attribute and the {@linkplain #value} are mutually exclusive.
+         */
+        @XmlAttribute
+        public String indeterminatePosition;
+
+        /**
+         * The actual time position, or {@code null} for {@linkplain #indeterminatePosition
indeterminate position}.
+         *
+         * <p><strong>WARNING: The timezone information may be lost!</strong>
This is because this field
+         * is derived from a {@link java.util.Date}, in which case we don't know if the time
is really 0
+         * or just unspecified. This class assumes that a time of zero means "unspecified".
This will be
+         * revised after we implemented ISO 19108.</p>
+         */
+        @XmlValue
+        public XMLGregorianCalendar value;
+
+        /**
+         * Empty constructor used by JAXB.
+         */
+        public GML3() {
+        }
+
+        /**
+         * Creates a bound initialized to the given instant.
+         *
+         * @param instant The instant of the new bound, or {@code null}.
+         * @param indeterminate The value to give to {@link #indeterminatePosition} if the
date is null.
+         */
+        GML3(final Instant instant, final String indeterminate) {
+            value = TimeInstant.toXML(instant);
+            if (value == null) {
+                indeterminatePosition = indeterminate;
+            }
+        }
+
+        /**
+         * Returns the XML calendar, or {@code null} if none or undetermined.
+         */
+        @Override
+        XMLGregorianCalendar calendar() {
+            return value;
+        }
+    }
+
+    /**
+     * The begin or end position in a {@link TimePeriod}, expressed in the GML 2 way.
+     * This object encapsulates a {@link TimeInstant} inside a {@code begin} or {@code end}
+     * element inside a GML 2 {@link TimePeriod} in GML 2. This is not used for GML 3.
+     * Example:
+     *
+     * {@preformat xml
+     *   <gml:TimePeriod>
+     *     <gml:begin>
+     *       <gml:TimeInstant gml:id="begin">
+     *         <gml:timePosition>1992-01-01T01:00:00.000+01:00</gml:timePosition>
+     *       </gml:TimeInstant>
+     *     </gml:begin>
+     *     <gml:end>
+     *       <gml:TimeInstant gml:id="end">
+     *         <gml:timePosition>2007-12-31T01:00:00.000+01:00</gml:timePosition>
+     *       </gml:TimeInstant>
+     *     </gml:end>
+     *   </gml:TimePeriod>
+     * }
+     */
+    @XmlType(name = "TimeInstantPropertyType")
+    public static final class GML2 extends TimePeriodBound {
+        /**
+         * The time.
+         */
+        @XmlElement(name = "TimeInstant")
+        public TimeInstant timeInstant;
+
+        /**
+         * Empty constructor used by JAXB.
+         */
+        public GML2() {
+        }
+
+        /**
+         * Creates a bound initialized to the given instant.
+         *
+         * @param instant The instant of the new bound, or {@code null}.
+         */
+        GML2(final Instant instant) {
+            timeInstant = new TimeInstant(instant);
+        }
+
+        /**
+         * Returns the XML calendar, or {@code null} if none.
+         */
+        @Override
+        XMLGregorianCalendar calendar() {
+            final TimeInstant timeInstant = this.timeInstant;
+            return (timeInstant != null) ? timeInstant.timePosition : null;
+        }
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/package-info.java?rev=1496394&r1=1496393&r2=1496394&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/package-info.java
[UTF-8] Tue Jun 25 09:46:43 2013
@@ -17,17 +17,27 @@
 
 /**
  * Miscellaneous objects and adapters defined in the {@code "gml"} namespace.
+ * This package contains adapters mapping GeoAPI interfaces to their SIS implementation.
+ * We must use adapters since JAXB can not handle interfaces. Consequently the purpose of
+ * these adapters is to replace arbitrary instances of interfaces by SIS implementations.
+ *
+ * <p>Every time JAXB try to marshal or unmarshal an instance of an interface,
+ * the adapter will be invoked for eventually substituting that instance.</p>
  *
  * @author  Guilhem Legal (Geomatys)
+ * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.3 (derived from geotk-3.18)
+ * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
  * @module
  *
  * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
  */
 @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GML, xmlns =
{
-    @XmlNs(prefix = "gml", namespaceURI = Namespaces.GML)
+    @XmlNs(prefix = "gml", namespaceURI = Namespaces.GML),
+    @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
+    @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO),
+    @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI)
 })
 @XmlAccessorType(XmlAccessType.NONE)
 package org.apache.sis.internal.jaxb.gml;



Mime
View raw message