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;
021:
022: // J2SE direct dependencies
023: import java.util.Collection;
024: import java.util.Collections;
025: import java.util.Date;
026: import java.util.Locale;
027: import java.nio.charset.Charset;
028:
029: // OpenGIS dependencies
030: import org.opengis.metadata.MetaData;
031: import org.opengis.metadata.ApplicationSchemaInformation;
032: import org.opengis.metadata.MetadataExtensionInformation;
033: import org.opengis.metadata.PortrayalCatalogueReference;
034: import org.opengis.metadata.citation.ResponsibleParty;
035: import org.opengis.metadata.constraint.Constraints;
036: import org.opengis.metadata.distribution.Distribution;
037: import org.opengis.metadata.identification.CharacterSet;
038: import org.opengis.metadata.identification.Identification;
039: import org.opengis.metadata.maintenance.MaintenanceInformation;
040: import org.opengis.metadata.maintenance.ScopeCode;
041: import org.opengis.metadata.quality.DataQuality;
042: import org.opengis.metadata.spatial.SpatialRepresentation;
043: import org.opengis.referencing.ReferenceSystem;
044:
045: /**
046: * Root entity which defines metadata about a resource or resources.
047: *
048: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/MetaDataImpl.java $
049: * @version $Id: MetaDataImpl.java 25193 2007-04-18 13:37:38Z desruisseaux $
050: * @author Martin Desruisseaux
051: * @author Touraïvane
052: *
053: * @since 2.1
054: */
055: public class MetaDataImpl extends MetadataEntity implements MetaData {
056: /**
057: * Serial number for interoperability with different versions.
058: */
059: private static final long serialVersionUID = -5600409558876701144L;
060:
061: /**
062: * Unique identifier for this metadata file, or {@code null} if none.
063: */
064: private String fileIdentifier;
065:
066: /**
067: * Language used for documenting metadata.
068: */
069: private Locale language;
070:
071: /**
072: * Information about an alternatively used localized character
073: * strings for linguistic extensions.
074: */
075: private Collection locales;
076:
077: /**
078: * Full name of the character coding standard used for the metadata set.
079: */
080: private CharacterSet characterSet;
081:
082: /**
083: * File identifier of the metadata to which this metadata is a subset (child).
084: */
085: private String parentIdentifier;
086:
087: /**
088: * Scope to which the metadata applies.
089: */
090: private Collection hierarchyLevels;
091:
092: /**
093: * Name of the hierarchy levels for which the metadata is provided.
094: */
095: private Collection hierarchyLevelNames;
096:
097: /**
098: * Parties responsible for the metadata information.
099: */
100: private Collection contacts;
101:
102: /**
103: * Uniformed Resource Identifier (URI) of the dataset to which the metadata applies.
104: */
105: private String dataSetUri;
106:
107: /**
108: * Date that the metadata was created, in milliseconds ellapsed since January 1st, 1970.
109: * If not defined, then then value is {@link Long#MIN_VALUE}.
110: */
111: private long dateStamp = Long.MIN_VALUE;
112:
113: /**
114: * Name of the metadata standard (including profile name) used.
115: */
116: private String metadataStandardName;
117:
118: /**
119: * Version (profile) of the metadata standard used.
120: */
121: private String metadataStandardVersion;
122:
123: /**
124: * Digital representation of spatial information in the dataset.
125: */
126: private Collection spatialRepresentationInfo;
127:
128: /**
129: * Description of the spatial and temporal reference systems used in the dataset.
130: */
131: private Collection referenceSystemInfo;
132:
133: /**
134: * Information describing metadata extensions.
135: */
136: private Collection metadataExtensionInfo;
137:
138: /**
139: * Basic information about the resource(s) to which the metadata applies.
140: */
141: private Collection identificationInfo;
142:
143: /**
144: * Provides information about the feature catalogue and describes the coverage and
145: * image data characteristics.
146: */
147: private Collection contentInfo;
148:
149: /**
150: * Provides information about the distributor of and options for obtaining the resource(s).
151: */
152: private Distribution distributionInfo;
153:
154: /**
155: * Provides overall assessment of quality of a resource(s).
156: */
157: private Collection dataQualityInfo;
158:
159: /**
160: * Provides information about the catalogue of rules defined for the portrayal of a resource(s).
161: */
162: private Collection portrayalCatalogueInfo;
163:
164: /**
165: * Provides restrictions on the access and use of data.
166: */
167: private Collection metadataConstraints;
168:
169: /**
170: * Provides information about the conceptual schema of a dataset.
171: */
172: private Collection applicationSchemaInfo;
173:
174: /**
175: * Provides information about the frequency of metadata updates, and the scope of those updates.
176: */
177: private MaintenanceInformation metadataMaintenance;
178:
179: /**
180: * Creates an initially empty metadata.
181: */
182: public MetaDataImpl() {
183: }
184:
185: /**
186: * Constructs a metadata entity initialized with the values from the specified metadata.
187: *
188: * @since 2.4
189: */
190: public MetaDataImpl(final MetaData source) {
191: super (source);
192: }
193:
194: /**
195: * Creates a meta data initialised to the specified values.
196: *
197: * @param contact Party responsible for the metadata information.
198: * @param dateStamp Date that the metadata was created.
199: * @param identificationInfo Basic information about the resource
200: * to which the metadata applies.
201: */
202: public MetaDataImpl(final ResponsibleParty contact,
203: final Date dateStamp,
204: final Identification identificationInfo) {
205: setContacts(Collections.singleton(contact));
206: setDateStamp(dateStamp);
207: setIdentificationInfo(Collections.singleton(identificationInfo));
208: }
209:
210: /**
211: * Returns the unique identifier for this metadata file, or {@code null} if none.
212: */
213: public String getFileIdentifier() {
214: return fileIdentifier;
215: }
216:
217: /**
218: * Set the unique identifier for this metadata file, or {@code null} if none.
219: */
220: public synchronized void setFileIdentifier(final String newValue) {
221: checkWritePermission();
222: fileIdentifier = newValue;
223: }
224:
225: /**
226: * Returns the language used for documenting metadata.
227: */
228: public Locale getLanguage() {
229: return language;
230: }
231:
232: /**
233: * Set the language used for documenting metadata.
234: */
235: public synchronized void setLanguage(final Locale newValue) {
236: checkWritePermission();
237: language = newValue;
238: }
239:
240: /**
241: * Returns the full name of the character coding standard used for the metadata set.
242: */
243: public CharacterSet getCharacterSet() {
244: return characterSet;
245: }
246:
247: /**
248: * Set the full name of the character coding standard used for the metadata set.
249: */
250: public synchronized void setCharacterSet(final CharacterSet newValue) {
251: checkWritePermission();
252: characterSet = newValue;
253: }
254:
255: /**
256: * Returns the file identifier of the metadata to which this metadata is a subset (child).
257: */
258: public String getParentIdentifier() {
259: return parentIdentifier;
260: }
261:
262: /**
263: * Set the file identifier of the metadata to which this metadata is a subset (child).
264: */
265: public synchronized void setParentIdentifier(final String newValue) {
266: checkWritePermission();
267: fileIdentifier = newValue;
268: }
269:
270: /**
271: * Returns the scope to which the metadata applies.
272: */
273: public synchronized Collection getHierarchyLevels() {
274: return hierarchyLevels = nonNullCollection(hierarchyLevels,
275: ScopeCode.class);
276: }
277:
278: /**
279: * Set the scope to which the metadata applies.
280: */
281: public synchronized void setHierarchyLevels(
282: final Collection newValues) {
283: hierarchyLevels = copyCollection(newValues, hierarchyLevels,
284: ScopeCode.class);
285: }
286:
287: /**
288: * Returns the name of the hierarchy levels for which the metadata is provided.
289: */
290: public synchronized Collection getHierarchyLevelNames() {
291: return hierarchyLevelNames = nonNullCollection(
292: hierarchyLevelNames, String.class);
293: }
294:
295: /**
296: * Set the name of the hierarchy levels for which the metadata is provided.
297: */
298: public synchronized void setHierarchyLevelNames(
299: final Collection newValues) {
300: hierarchyLevelNames = copyCollection(newValues,
301: hierarchyLevelNames, String.class);
302: }
303:
304: /**
305: * Returns the party responsible for the metadata information.
306: *
307: * @deprecated use {@link #getContacts}.
308: */
309: public ResponsibleParty getContact() {
310: final Collection contacts = getContacts();
311: return contacts.isEmpty() ? null : (ResponsibleParty) contacts
312: .iterator().next();
313: }
314:
315: /**
316: * Returns the parties responsible for the metadata information.
317: */
318: public synchronized Collection getContacts() {
319: return contacts = nonNullCollection(contacts,
320: ResponsibleParty.class);
321: }
322:
323: /**
324: * Set the party responsible for the metadata information.
325: *
326: * @deprecated use {@link #setContacts}.
327: */
328: public synchronized void setContact(final ResponsibleParty newValue) {
329: setContacts(Collections.singleton(newValue));
330: }
331:
332: /**
333: * Set the parties responsible for the metadata information.
334: */
335: public synchronized void setContacts(final Collection newValues) {
336: checkWritePermission();
337: contacts = copyCollection(newValues, contacts,
338: ResponsibleParty.class);
339: }
340:
341: /**
342: * Returns the date that the metadata was created.
343: */
344: public synchronized Date getDateStamp() {
345: return (dateStamp != Long.MIN_VALUE) ? new Date(dateStamp)
346: : (Date) null;
347: }
348:
349: /**
350: * Set the date that the metadata was created.
351: */
352: public synchronized void setDateStamp(final Date newValue) {
353: checkWritePermission();
354: dateStamp = (newValue != null) ? newValue.getTime()
355: : Long.MIN_VALUE;
356: }
357:
358: /**
359: * Returns the name of the metadata standard (including profile name) used.
360: */
361: public String getMetadataStandardName() {
362: return metadataStandardName;
363: }
364:
365: /**
366: * Name of the metadata standard (including profile name) used.
367: */
368: public synchronized void setMetadataStandardName(
369: final String newValue) {
370: checkWritePermission();
371: metadataStandardName = newValue;
372: }
373:
374: /**
375: * Returns the version (profile) of the metadata standard used.
376: */
377: public String getMetadataStandardVersion() {
378: return metadataStandardVersion;
379: }
380:
381: /**
382: * Set the version (profile) of the metadata standard used.
383: */
384: public synchronized void setMetadataStandardVersion(
385: final String newValue) {
386: checkWritePermission();
387: metadataStandardVersion = newValue;
388: }
389:
390: /**
391: * Returns the digital representation of spatial information in the dataset.
392: */
393: public synchronized Collection getSpatialRepresentationInfo() {
394: return spatialRepresentationInfo = nonNullCollection(
395: spatialRepresentationInfo, SpatialRepresentation.class);
396: }
397:
398: /**
399: * Set the digital representation of spatial information in the dataset.
400: */
401: public synchronized void setSpatialRepresentationInfo(
402: final Collection newValues) {
403: spatialRepresentationInfo = copyCollection(newValues,
404: spatialRepresentationInfo, SpatialRepresentation.class);
405: }
406:
407: /**
408: * Returns the description of the spatial and temporal reference systems used in the dataset.
409: */
410: public synchronized Collection getReferenceSystemInfo() {
411: return referenceSystemInfo = nonNullCollection(
412: referenceSystemInfo, ReferenceSystem.class);
413: }
414:
415: /**
416: * Set the description of the spatial and temporal reference systems used in the dataset.
417: */
418: public synchronized void setReferenceSystemInfo(
419: final Collection newValues) {
420: referenceSystemInfo = copyCollection(newValues,
421: referenceSystemInfo, ReferenceSystem.class);
422: }
423:
424: /**
425: * Returns information describing metadata extensions.
426: */
427: public synchronized Collection getMetadataExtensionInfo() {
428: return metadataExtensionInfo = nonNullCollection(
429: metadataExtensionInfo,
430: MetadataExtensionInformation.class);
431: }
432:
433: /**
434: * Set information describing metadata extensions.
435: */
436: public synchronized void setMetadataExtensionInfo(
437: final Collection newValues) {
438: metadataExtensionInfo = copyCollection(newValues,
439: metadataExtensionInfo,
440: MetadataExtensionInformation.class);
441: }
442:
443: /**
444: * Returns basic information about the resource(s) to which the metadata applies.
445: */
446: public synchronized Collection getIdentificationInfo() {
447: return identificationInfo = nonNullCollection(
448: identificationInfo, Identification.class);
449: }
450:
451: /**
452: * Set basic information about the resource(s) to which the metadata applies.
453: */
454: public synchronized void setIdentificationInfo(
455: final Collection newValues) {
456: identificationInfo = copyCollection(newValues,
457: identificationInfo, Identification.class);
458: }
459:
460: /**
461: * Provides information about the feature catalogue and describes the coverage and
462: * image data characteristics.
463: */
464: public synchronized Collection getContentInfo() {
465: return contentInfo = nonNullCollection(contentInfo,
466: Identification.class);
467: }
468:
469: /**
470: * Set information about the feature catalogue and describes the coverage and
471: * image data characteristics.
472: */
473: public synchronized void setContentInfo(final Collection newValues) {
474: contentInfo = copyCollection(newValues, contentInfo,
475: Identification.class);
476: }
477:
478: /**
479: * Provides information about the distributor of and options for obtaining the resource(s).
480: */
481: public Distribution getDistributionInfo() {
482: return distributionInfo;
483: }
484:
485: /**
486: * Provides information about the distributor of and options for obtaining the resource(s).
487: */
488: public synchronized void setDistributionInfo(
489: final Distribution newValue) {
490: checkWritePermission();
491: distributionInfo = newValue;
492: }
493:
494: /**
495: * Provides overall assessment of quality of a resource(s).
496: */
497: public synchronized Collection getDataQualityInfo() {
498: return dataQualityInfo = nonNullCollection(dataQualityInfo,
499: DataQuality.class);
500: }
501:
502: /**
503: * Set overall assessment of quality of a resource(s).
504: */
505: public synchronized void setDataQualityInfo(
506: final Collection newValues) {
507: dataQualityInfo = copyCollection(newValues, dataQualityInfo,
508: DataQuality.class);
509: }
510:
511: /**
512: * Provides information about the catalogue of rules defined for the portrayal of a
513: * resource(s).
514: */
515: public synchronized Collection getPortrayalCatalogueInfo() {
516: return portrayalCatalogueInfo = nonNullCollection(
517: portrayalCatalogueInfo,
518: PortrayalCatalogueReference.class);
519: }
520:
521: /**
522: * Set information about the catalogue of rules defined for the portrayal of a resource(s).
523: */
524: public synchronized void setPortrayalCatalogueInfo(
525: final Collection newValues) {
526: portrayalCatalogueInfo = copyCollection(newValues,
527: portrayalCatalogueInfo,
528: PortrayalCatalogueReference.class);
529: }
530:
531: /**
532: * Provides restrictions on the access and use of data.
533: */
534: public synchronized Collection getMetadataConstraints() {
535: return metadataConstraints = nonNullCollection(
536: metadataConstraints, Constraints.class);
537: }
538:
539: /**
540: * Set restrictions on the access and use of data.
541: */
542: public synchronized void setMetadataConstraints(
543: final Collection newValues) {
544: metadataConstraints = copyCollection(newValues,
545: metadataConstraints, Constraints.class);
546: }
547:
548: /**
549: * Provides information about the conceptual schema of a dataset.
550: */
551: public synchronized Collection getApplicationSchemaInfo() {
552: return applicationSchemaInfo = nonNullCollection(
553: applicationSchemaInfo,
554: ApplicationSchemaInformation.class);
555: }
556:
557: /**
558: * Provides information about the conceptual schema of a dataset.
559: */
560: public synchronized void setApplicationSchemaInfo(
561: final Collection newValues) {
562: applicationSchemaInfo = copyCollection(newValues,
563: applicationSchemaInfo,
564: ApplicationSchemaInformation.class);
565: }
566:
567: /**
568: * Provides information about the frequency of metadata updates, and the scope of those updates.
569: */
570: public MaintenanceInformation getMetadataMaintenance() {
571: return metadataMaintenance;
572: }
573:
574: /**
575: * Set information about the frequency of metadata updates, and the scope of those updates.
576: */
577: public synchronized void setMetadataMaintenance(
578: final MaintenanceInformation newValue) {
579: checkWritePermission();
580: metadataMaintenance = newValue;
581: }
582:
583: /**
584: * Provides information about an alternatively used localized character
585: * string for a linguistic extension.
586: *
587: * @since 2.4
588: */
589: public synchronized Collection getLocales() {
590: return locales = nonNullCollection(locales, Locale.class);
591: }
592:
593: /**
594: * Set information about an alternatively used localized character
595: * string for a linguistic extension.
596: *
597: * @since 2.4
598: */
599: public synchronized void setLocales(final Collection newValues) {
600: locales = copyCollection(newValues, locales, Locale.class);
601: }
602:
603: /**
604: * Provides the URI of the dataset to which the metadata applies.
605: *
606: * @since 2.4
607: */
608: public String getDataSetUri() {
609: return dataSetUri;
610: }
611:
612: /**
613: * Sets the URI of the dataset to which the metadata applies.
614: *
615: * @since 2.4
616: */
617: public void setDataSetUri(final String newValue) {
618: checkWritePermission();
619: dataSetUri = newValue;
620: }
621: }
|