001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2005, 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.citation;
021:
022: // J2SE direct dependencies
023: import java.util.Date;
024:
025: // OpenGIS dependencies
026: import org.opengis.metadata.citation.CitationDate;
027: import org.opengis.metadata.citation.DateType;
028:
029: // Geotools dependencies
030: import org.geotools.metadata.iso.MetadataEntity;
031:
032: /**
033: * Reference date and event used to describe it.
034: *
035: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/citation/CitationDateImpl.java $
036: * @version $Id: CitationDateImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
037: * @author Martin Desruisseaux
038: *
039: * @since 2.1
040: */
041: public class CitationDateImpl extends MetadataEntity implements
042: CitationDate {
043: /**
044: * Serial number for interoperability with different versions.
045: */
046: private static final long serialVersionUID = -2884791484254008454L;
047:
048: /**
049: * Reference date for the cited resource in millisecondes ellapsed sine January 1st, 1970,
050: * or {@link Long#MIN_VALUE} if none.
051: */
052: private long date = Long.MIN_VALUE;
053:
054: /**
055: * Event used for reference date.
056: */
057: private DateType dateType;
058:
059: /**
060: * Constructs an initially empty citation date.
061: */
062: public CitationDateImpl() {
063: }
064:
065: /**
066: * Constructs a metadata entity initialized with the values from the specified metadata.
067: *
068: * @since 2.4
069: */
070: public CitationDateImpl(final CitationDate source) {
071: super (source);
072: }
073:
074: /**
075: * Constructs a citation date initialized to the given date.
076: */
077: public CitationDateImpl(final Date date, final DateType dateType) {
078: setDate(date);
079: setDateType(dateType);
080: }
081:
082: /**
083: * Returns the reference date for the cited resource.
084: */
085: public synchronized Date getDate() {
086: return (date != Long.MIN_VALUE) ? new Date(date) : null;
087: }
088:
089: /**
090: * Set the reference date for the cited resource.
091: */
092: public synchronized void setDate(final Date newValue) {
093: checkWritePermission();
094: date = (newValue != null) ? newValue.getTime() : Long.MIN_VALUE;
095: }
096:
097: /**
098: * Returns the event used for reference date.
099: */
100: public DateType getDateType() {
101: return dateType;
102: }
103:
104: /**
105: * Set the event used for reference date.
106: */
107: public synchronized void setDateType(final DateType newValue) {
108: checkWritePermission();
109: dateType = newValue;
110: }
111: }
|