001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * This package contains documentation from OpenGIS specifications.
017: * OpenGIS consortium's work is fully acknowledged here.
018: */
019: package org.geotools.metadata.iso.citation;
020:
021: import java.util.Collection;
022: import org.opengis.metadata.citation.Telephone;
023: import org.geotools.metadata.iso.MetadataEntity;
024:
025: /**
026: * Telephone numbers for contacting the responsible individual or organization.
027: *
028: * @author Jody Garnett
029: * @author Martin Desruisseaux
030: *
031: * @since 2.1
032: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/citation/TelephoneImpl.java $
033: */
034: public class TelephoneImpl extends MetadataEntity implements Telephone {
035: /**
036: * Serial number for interoperability with different versions.
037: */
038: private static final long serialVersionUID = 4920157673337669241L;
039:
040: /**
041: * Telephone numbers by which individuals can speak to the responsible organization or
042: * individual.
043: */
044: private Collection voices;
045:
046: /**
047: * Telephone numbers of a facsimile machine for the responsible organization or individual.
048: */
049: private Collection facsimiles;
050:
051: /**
052: * Constructs a default telephone.
053: */
054: public TelephoneImpl() {
055: }
056:
057: /**
058: * Constructs a metadata entity initialized with the values from the specified metadata.
059: *
060: * @since 2.4
061: */
062: public TelephoneImpl(final Telephone source) {
063: super (source);
064: }
065:
066: /**
067: * Returns the telephone number by which individuals can speak to the responsible
068: * organization or individual.
069: *
070: * @deprecated Replaced by {@link #getVoices}.
071: */
072: public synchronized String getVoice() {
073: return voices == null || voices.isEmpty() ? null
074: : (String) voices.iterator().next();
075: }
076:
077: /**
078: * Returns the telephone numbers by which individuals can speak to the responsible
079: * organization or individual.
080: *
081: * @since 2.4
082: */
083: public synchronized Collection getVoices() {
084: return voices = nonNullCollection(voices, String.class);
085: }
086:
087: /**
088: * Set the telephone number by which individuals can speak to the responsible
089: * organization or individual.
090: *
091: * @deprecated Replaced by {@link #setVoices}.
092: */
093: public void setVoice(final String newValue) {
094: setVoices(java.util.Collections.singleton(newValue));
095: }
096:
097: /**
098: * Set the telephone numbers by which individuals can speak to the responsible
099: * organization or individual.
100: *
101: * @since 2.4
102: */
103: public synchronized void setVoices(final Collection newValues) {
104: voices = copyCollection(newValues, voices, String.class);
105: }
106:
107: /**
108: * Returns the telephone number of a facsimile machine for the responsible organization
109: * or individual.
110: *
111: * @deprecated Replaced by {@link #getFacsimiles}.
112: */
113: public synchronized String getFacsimile() {
114: return facsimiles == null || facsimiles.isEmpty() ? null
115: : (String) facsimiles.iterator().next();
116: }
117:
118: /**
119: * Returns the telephone numbers of a facsimile machine for the responsible organization
120: * or individual.
121: *
122: * @since 2.4
123: */
124: public synchronized Collection getFacsimiles() {
125: return facsimiles = nonNullCollection(facsimiles, String.class);
126: }
127:
128: /**
129: * Set the telephone number of a facsimile machine for the responsible organization
130: * or individual.
131: *
132: * @deprecated Replaced by {@link #setFacsimiles}.
133: */
134: public void setFacsimile(final String newValue) {
135: setFacsimiles(java.util.Collections.singleton(newValue));
136: }
137:
138: /**
139: * Set the telephone number of a facsimile machine for the responsible organization
140: * or individual.
141: *
142: * @since 2.4
143: */
144: public synchronized void setFacsimiles(final Collection newValues) {
145: facsimiles = copyCollection(newValues, facsimiles, String.class);
146: }
147: }
|