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.citation;
021:
022: // J2SE direct dependencies
023: import java.net.URI;
024: import java.net.URISyntaxException;
025: import java.util.Collection;
026: import java.util.Date;
027: import java.util.Iterator;
028: import java.util.Locale;
029:
030: // OpenGIS dependencies
031: import org.opengis.metadata.citation.Citation;
032: import org.opengis.metadata.citation.CitationDate;
033: import org.opengis.metadata.citation.DateType;
034: import org.opengis.metadata.citation.OnLineFunction;
035: import org.opengis.metadata.citation.PresentationForm;
036: import org.opengis.metadata.citation.ResponsibleParty;
037: import org.opengis.metadata.citation.Role;
038: import org.opengis.metadata.citation.Series;
039: import org.opengis.util.InternationalString;
040: import org.opengis.referencing.crs.CRSAuthorityFactory; // For javadoc
041: import org.opengis.referencing.crs.CoordinateReferenceSystem; // For javadoc
042:
043: // Geotools dependencies
044: import org.geotools.metadata.iso.MetadataEntity;
045: import org.geotools.util.SimpleInternationalString;
046:
047: /**
048: * Standardized resource reference.
049: *
050: * @since 2.1
051: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/citation/CitationImpl.java $
052: * @version $Id: CitationImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
053: * @author Martin Desruisseaux
054: * @author Jody Garnett
055: */
056: public class CitationImpl extends MetadataEntity implements Citation {
057: /**
058: * Serial number for interoperability with different versions.
059: */
060: private static final long serialVersionUID = -4415559967618358778L;
061:
062: /**
063: * Name by which the cited resource is known.
064: */
065: private InternationalString title;
066:
067: /**
068: * Short name or other language name by which the cited information is known.
069: * Example: "DCW" as an alternative title for "Digital Chart of the World.
070: */
071: private Collection alternateTitles;
072:
073: /**
074: * Reference date for the cited resource.
075: */
076: private Collection dates;
077:
078: /**
079: * Version of the cited resource.
080: */
081: private InternationalString edition;
082:
083: /**
084: * Date of the edition in millisecondes ellapsed sine January 1st, 1970,
085: * or {@link Long#MIN_VALUE} if none.
086: */
087: private long editionDate = Long.MIN_VALUE;
088:
089: /**
090: * Unique identifier for the resource. Example: Universal Product Code (UPC),
091: * National Stock Number (NSN).
092: */
093: private Collection identifiers;
094:
095: /**
096: * Reference form of the unique identifier (ID). Example: Universal Product Code (UPC),
097: * National Stock Number (NSN).
098: *
099: * @deprecated
100: */
101: private Collection identifierTypes;
102:
103: /**
104: * Name and position information for an individual or organization that is responsible
105: * for the resource. Returns an empty string if there is none.
106: */
107: private Collection citedResponsibleParties;
108:
109: /**
110: * Mode in which the resource is represented, or an empty string if none.
111: */
112: private Collection presentationForm;
113:
114: /**
115: * Information about the series, or aggregate dataset, of which the dataset is a part.
116: * May be {@code null} if none.
117: */
118: private Series series;
119:
120: /**
121: * Other information required to complete the citation that is not recorded elsewhere.
122: * May be {@code null} if none.
123: */
124: private InternationalString otherCitationDetails;
125:
126: /**
127: * Common title with holdings note. Note: title identifies elements of a series
128: * collectively, combined with information about what volumes are available at the
129: * source cited. May be {@code null} if there is no title.
130: */
131: private InternationalString collectiveTitle;
132:
133: /**
134: * International Standard Book Number, or {@code null} if none.
135: */
136: private String ISBN;
137:
138: /**
139: * International Standard Serial Number, or {@code null} if none.
140: */
141: private String ISSN;
142:
143: /**
144: * Constructs an initially empty citation.
145: */
146: public CitationImpl() {
147: }
148:
149: /**
150: * Constructs a new citation initialized to the values specified by the given object.
151: * This constructor performs a shallow copy (i.e. each source attributes are reused
152: * without copying them).
153: */
154: public CitationImpl(final Citation source) {
155: super (source);
156: }
157:
158: /**
159: * Constructs a citation with the specified title.
160: *
161: * @param title The title, as a {@link String} or an {@link InternationalString} object.
162: */
163: public CitationImpl(final CharSequence title) {
164: final InternationalString t;
165: if (title instanceof InternationalString) {
166: t = (InternationalString) title;
167: } else {
168: t = new SimpleInternationalString(title.toString());
169: }
170: setTitle(t);
171: }
172:
173: /**
174: * Constructs a citation with the specified responsible party. This convenience constructor
175: * initialize the citation title to the first non-null of the following properties:
176: * {@linkplain ResponsibleParty#getOrganisationName organisation name},
177: * {@linkplain ResponsibleParty#getPositionName position name} or
178: * {@linkplain ResponsibleParty#getIndividualName individual name}.
179: *
180: * @since 2.2
181: */
182: public CitationImpl(final ResponsibleParty party) {
183: InternationalString title = party.getOrganisationName();
184: if (title == null) {
185: title = party.getPositionName();
186: if (title == null) {
187: String name = party.getIndividualName();
188: if (name != null) {
189: title = new SimpleInternationalString(name);
190: }
191: }
192: }
193: setTitle(title);
194: getCitedResponsibleParties().add(party);
195: }
196:
197: /**
198: * Adds the specified identifier as a CRS authority factory. This is used as a convenience
199: * method for the creation of constants, and for making sure that all of them use the same
200: * identifier type.
201: */
202: final void addAuthority(final String identifier,
203: final boolean asTitle) {
204: if (asTitle) {
205: getAlternateTitles().add(
206: new SimpleInternationalString(identifier));
207: }
208: getIdentifierTypes().add("Authority name");
209: getIdentifiers().add(identifier);
210: }
211:
212: /**
213: * Returns the name by which the cited resource is known.
214: */
215: public InternationalString getTitle() {
216: return title;
217: }
218:
219: /**
220: * Set the name by which the cited resource is known.
221: */
222: public synchronized void setTitle(final InternationalString newValue) {
223: checkWritePermission();
224: title = newValue;
225: }
226:
227: /**
228: * Returns the short name or other language name by which the cited information is known.
229: * Example: "DCW" as an alternative title for "Digital Chart of the World".
230: */
231: public synchronized Collection getAlternateTitles() {
232: return alternateTitles = nonNullCollection(alternateTitles,
233: InternationalString.class);
234: }
235:
236: /**
237: * Set the short name or other language name by which the cited information is known.
238: */
239: public synchronized void setAlternateTitles(
240: final Collection newValues) {
241: alternateTitles = copyCollection(newValues, alternateTitles,
242: InternationalString.class);
243: }
244:
245: /**
246: * Returns the reference date for the cited resource.
247: */
248: public synchronized Collection getDates() {
249: return dates = nonNullCollection(dates, CitationDate.class);
250: }
251:
252: /**
253: * Set the reference date for the cited resource.
254: */
255: public synchronized void setDates(final Collection newValues) {
256: dates = copyCollection(newValues, dates, CitationDate.class);
257: }
258:
259: /**
260: * Returns the version of the cited resource.
261: */
262: public InternationalString getEdition() {
263: return edition;
264: }
265:
266: /**
267: * Set the version of the cited resource.
268: */
269: public synchronized void setEdition(
270: final InternationalString newValue) {
271: checkWritePermission();
272: edition = newValue;
273: }
274:
275: /**
276: * Returns the date of the edition, or {@code null} if none.
277: */
278: public synchronized Date getEditionDate() {
279: return (editionDate != Long.MIN_VALUE) ? new Date(editionDate)
280: : null;
281: }
282:
283: /**
284: * Set the date of the edition, or {@code null} if none.
285: *
286: * @todo Use an unmodifiable {@link Date} here.
287: */
288: public synchronized void setEditionDate(final Date newValue) {
289: checkWritePermission();
290: editionDate = (newValue != null) ? newValue.getTime()
291: : Long.MIN_VALUE;
292: }
293:
294: /**
295: * Returns the unique identifier for the resource. Example: Universal Product Code (UPC),
296: * National Stock Number (NSN).
297: */
298: public synchronized Collection getIdentifiers() {
299: return identifiers = nonNullCollection(identifiers,
300: String.class);
301: }
302:
303: /**
304: * Set the unique identifier for the resource. Example: Universal Product Code (UPC),
305: * National Stock Number (NSN).
306: */
307: public synchronized void setIdentifiers(final Collection newValues) {
308: identifiers = copyCollection(newValues, identifiers,
309: String.class);
310: }
311:
312: /**
313: * Returns the reference form of the unique identifier (ID).
314: * Example: Universal Product Code (UPC), National Stock Number (NSN).
315: *
316: * @deprecated IdentifierType removed from ISO 19115
317: */
318: public synchronized Collection getIdentifierTypes() {
319: return identifierTypes = nonNullCollection(identifierTypes,
320: String.class);
321: }
322:
323: /**
324: * Set the reference form of the unique identifier (ID).
325: * Example: Universal Product Code (UPC), National Stock Number (NSN).
326: *
327: * @deprecated IdentifierType removed from ISO 19115
328: */
329: public synchronized void setIdentifierTypes(
330: final Collection newValues) {
331: identifierTypes = copyCollection(newValues, identifierTypes,
332: String.class);
333: }
334:
335: /**
336: * Returns the name and position information for an individual or organization that is
337: * responsible for the resource. Returns an empty string if there is none.
338: */
339: public synchronized Collection getCitedResponsibleParties() {
340: return citedResponsibleParties = nonNullCollection(
341: citedResponsibleParties, ResponsibleParty.class);
342: }
343:
344: /**
345: * Set the name and position information for an individual or organization that is responsible
346: * for the resource. Returns an empty string if there is none.
347: */
348: public synchronized void setCitedResponsibleParties(
349: final Collection newValues) {
350: citedResponsibleParties = copyCollection(newValues,
351: citedResponsibleParties, ResponsibleParty.class);
352: }
353:
354: /**
355: * Returns the mode in which the resource is represented, or an empty string if none.
356: */
357: public synchronized Collection getPresentationForm() {
358: return presentationForm = nonNullCollection(presentationForm,
359: PresentationForm.class);
360: }
361:
362: /**
363: * Set the mode in which the resource is represented, or an empty string if none.
364: */
365: public synchronized void setPresentationForm(
366: final Collection newValues) {
367: presentationForm = copyCollection(newValues, presentationForm,
368: PresentationForm.class);
369: }
370:
371: /**
372: * Returns the information about the series, or aggregate dataset, of which the dataset is
373: * a part. Returns {@code null} if none.
374: */
375: public Series getSeries() {
376: return series;
377: }
378:
379: /**
380: * Set the information about the series, or aggregate dataset, of which the dataset is
381: * a part. Set to {@code null} if none.
382: */
383: public synchronized void setSeries(final Series newValue) {
384: checkWritePermission();
385: series = newValue;
386: }
387:
388: /**
389: * Returns other information required to complete the citation that is not recorded elsewhere.
390: * Returns {@code null} if none.
391: */
392: public InternationalString getOtherCitationDetails() {
393: return otherCitationDetails;
394: }
395:
396: /**
397: * Set other information required to complete the citation that is not recorded elsewhere.
398: * Set to {@code null} if none.
399: */
400: public synchronized void setOtherCitationDetails(
401: final InternationalString newValue) {
402: checkWritePermission();
403: otherCitationDetails = newValue;
404: }
405:
406: /**
407: * Returns the common title with holdings note. Note: title identifies elements of a series
408: * collectively, combined with information about what volumes are available at the
409: * source cited. Returns {@code null} if there is no title.
410: */
411: public InternationalString getCollectiveTitle() {
412: return collectiveTitle;
413: }
414:
415: /**
416: * Set the common title with holdings note. Note: title identifies elements of a series
417: * collectively, combined with information about what volumes are available at the
418: * source cited. Set to {@code null} if there is no title.
419: */
420: public synchronized void setCollectiveTitle(
421: final InternationalString newValue) {
422: checkWritePermission();
423: collectiveTitle = newValue;
424: }
425:
426: /**
427: * Returns the International Standard Book Number, or {@code null} if none.
428: */
429: public String getISBN() {
430: return ISBN;
431: }
432:
433: /**
434: * Set the International Standard Book Number, or {@code null} if none.
435: */
436: public synchronized void setISBN(final String newValue) {
437: checkWritePermission();
438: ISBN = newValue;
439: }
440:
441: /**
442: * Returns the International Standard Serial Number, or {@code null} if none.
443: */
444: public String getISSN() {
445: return ISSN;
446: }
447:
448: /**
449: * Set the International Standard Serial Number, or {@code null} if none.
450: */
451: public synchronized void setISSN(final String newValue) {
452: checkWritePermission();
453: ISSN = newValue;
454: }
455: }
|