001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2004, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * This package contains documentation from OpenGIS specifications.
018: * OpenGIS consortium's work is fully acknowledged here.
019: */
020: package org.geotools.metadata.iso.extent;
021:
022: // J2SE direct dependencies
023: import java.util.Date;
024:
025: // OpenGIS dependencies
026: import org.opengis.metadata.extent.TemporalExtent;
027: import org.opengis.temporal.TemporalPrimitive;
028:
029: // Geotools dependencies
030: import org.geotools.metadata.iso.MetadataEntity;
031:
032: /**
033: * Boundary enclosing the dataset, expressed as the closed set of
034: * (<var>x</var>,<var>y</var>) coordinates of the polygon. The last
035: * point replicates first point.
036: *
037: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/extent/TemporalExtentImpl.java $
038: * @version $Id: TemporalExtentImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
039: * @author Martin Desruisseaux
040: * @author Touraïvane
041: *
042: * @since 2.1
043: */
044: public class TemporalExtentImpl extends MetadataEntity implements
045: TemporalExtent {
046: /**
047: * Serial number for interoperability with different versions.
048: */
049: private static final long serialVersionUID = 3668140516657118045L;
050:
051: /**
052: * The start date and time for the content of the dataset,
053: * in milliseconds ellapsed since January 1st, 1970. A value
054: * of {@link Long#MIN_VALUE} means that this attribute is not set.
055: */
056: private long startTime = Long.MIN_VALUE;
057:
058: /**
059: * The end date and time for the content of the dataset,
060: * in milliseconds ellapsed since January 1st, 1970. A value
061: * of {@link Long#MIN_VALUE} means that this attribute is not set.
062: */
063: private long endTime = Long.MIN_VALUE;
064:
065: /**
066: * The date and time for the content of the dataset.
067: */
068: private TemporalPrimitive extent;
069:
070: /**
071: * Constructs an initially empty temporal extent.
072: */
073: public TemporalExtentImpl() {
074: }
075:
076: /**
077: * Constructs a metadata entity initialized with the values from the specified metadata.
078: *
079: * @since 2.4
080: */
081: public TemporalExtentImpl(final TemporalExtent source) {
082: super (source);
083: }
084:
085: /**
086: * Creates a temporal extent initialized to the specified values.
087: */
088: public TemporalExtentImpl(final Date startTime, final Date endTime) {
089: setStartTime(startTime);
090: setEndTime(endTime);
091: }
092:
093: /**
094: * The start date and time for the content of the dataset.
095: */
096: public synchronized Date getStartTime() {
097: return (startTime != Long.MIN_VALUE) ? new Date(startTime)
098: : null;
099: }
100:
101: /**
102: * Set the start date and time for the content of the dataset.
103: */
104: public synchronized void setStartTime(final Date newValue) {
105: checkWritePermission();
106: startTime = (newValue != null) ? newValue.getTime()
107: : Long.MIN_VALUE;
108: }
109:
110: /**
111: * Returns the end date and time for the content of the dataset.
112: */
113: public synchronized Date getEndTime() {
114: return (endTime != Long.MIN_VALUE) ? new Date(endTime) : null;
115: }
116:
117: /**
118: * Set the end date and time for the content of the dataset.
119: */
120: public synchronized void setEndTime(final Date newValue) {
121: checkWritePermission();
122: endTime = (newValue != null) ? newValue.getTime()
123: : Long.MIN_VALUE;
124: }
125:
126: /**
127: * Returns the date and time for the content of the dataset.
128: *
129: * @since 2.4
130: */
131: public TemporalPrimitive getExtent() {
132: return extent;
133: }
134:
135: /**
136: * Set the date and time for the content of the dataset.
137: *
138: * @since 2.4
139: */
140: public synchronized void setExtent(final TemporalPrimitive newValue) {
141: checkWritePermission();
142: extent = newValue;
143: }
144: }
|