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:
026: // OpenGIS dependencies
027: import org.opengis.metadata.citation.OnLineFunction;
028: import org.opengis.metadata.citation.OnLineResource;
029: import org.opengis.util.InternationalString;
030:
031: // Geotools dependencies
032: import org.geotools.metadata.iso.MetadataEntity;
033:
034: /**
035: * Information about on-line sources from which the dataset, specification, or
036: * community profile name and extended metadata elements can be obtained.
037: *
038: * @since 2.1
039: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/citation/OnLineResourceImpl.java $
040: * @version $Id: OnLineResourceImpl.java 27523 2007-10-17 09:14:21Z desruisseaux $
041: * @author Martin Desruisseaux
042: * @author Touraïvane
043: */
044: public class OnLineResourceImpl extends MetadataEntity implements
045: OnLineResource {
046: /**
047: * Serial number for interoperability with different versions.
048: */
049: private static final long serialVersionUID = 5412370008274334799L;
050:
051: /**
052: * The online resources for the <A HREF="http://www.opengeospatial.org">Open Geospatial Consortium</A>.
053: * "Open Geospatial consortium" is the new name for "OpenGIS consortium".
054: *
055: * @see #OPEN_GIS
056: */
057: public static final OnLineResource OGC;
058: static {
059: final OnLineResourceImpl r;
060: OGC = r = new OnLineResourceImpl(
061: "http://www.opengeospatial.org/");
062: r.freeze();
063: }
064:
065: /**
066: * The online resources for the <A HREF="http://www.opengis.org">OpenGIS consortium</A>.
067: * "OpenGIS consortium" is the old name for "Open Geospatial consortium".
068: *
069: * @see #OGC
070: */
071: public static final OnLineResource OPEN_GIS;
072: static {
073: final OnLineResourceImpl r;
074: OPEN_GIS = r = new OnLineResourceImpl("http://www.opengis.org");
075: r.freeze();
076: }
077:
078: /**
079: * The online resources for the
080: * <A HREF="http://www.epsg.org">European Petroleum Survey Group</A>.
081: */
082: public static final OnLineResource EPSG;
083: static {
084: final OnLineResourceImpl r;
085: EPSG = r = new OnLineResourceImpl("http://www.epsg.org");
086: r.freeze();
087: }
088:
089: /**
090: * The online resources for the
091: * <A HREF="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</A> group.
092: */
093: public static final OnLineResource GEOTIFF;
094: static {
095: final OnLineResourceImpl r;
096: GEOTIFF = r = new OnLineResourceImpl(
097: "http://www.remotesensing.org/geotiff");
098: r.freeze();
099: }
100:
101: /**
102: * The online resources for <A HREF="http://www.esri.com">ESRI</A>.
103: */
104: public static final OnLineResource ESRI;
105: static {
106: final OnLineResourceImpl r;
107: ESRI = r = new OnLineResourceImpl("http://www.esri.com");
108: r.freeze();
109: }
110:
111: /**
112: * The online resources for <A HREF="http://www.oracle.com">Oracle</A>.
113: */
114: public static final OnLineResource ORACLE;
115: static {
116: final OnLineResourceImpl r;
117: ORACLE = r = new OnLineResourceImpl("http://www.oracle.com");
118: r.freeze();
119: }
120:
121: /**
122: * The online resources for <A HREF="http://postgis.refractions.net">PostGIS</A>.
123: *
124: * @since 2.4
125: */
126: public static final OnLineResource POSTGIS;
127: static {
128: final OnLineResourceImpl r;
129: POSTGIS = r = new OnLineResourceImpl(
130: "http://postgis.refractions.net");
131: r.freeze();
132: }
133:
134: /**
135: * The online resources for <A HREF="http://java.sun.com/">Sun Microsystems</A>.
136: * This online resources point to the Java developper site.
137: *
138: * @since 2.2
139: */
140: public static final OnLineResource SUN_MICROSYSTEMS;
141: static {
142: final OnLineResourceImpl r;
143: SUN_MICROSYSTEMS = r = new OnLineResourceImpl(
144: "http://java.sun.com");
145: r.freeze();
146: }
147:
148: /**
149: * The online resources for the <A HREF="http://www.geotools.org">Geotools</A> project.
150: */
151: public static final OnLineResource GEOTOOLS;
152: static {
153: final OnLineResourceImpl r;
154: GEOTOOLS = r = new OnLineResourceImpl("http://www.geotools.org");
155: r.freeze();
156: }
157:
158: /**
159: * The download link for <A HREF="http://portal.opengis.org/files/?artifact_id=5316">Web Map
160: * Service</A> specification. The download link may change in future Geotools versions in
161: * order to point toward the latest specification.
162: *
163: * @since 2.2
164: */
165: public static final OnLineResource WMS;
166: static {
167: final OnLineResourceImpl r;
168: WMS = r = new OnLineResourceImpl(
169: "http://portal.opengis.org/files/?artifact_id=5316");
170: r.setFunction(OnLineFunction.DOWNLOAD);
171: r.freeze();
172: }
173:
174: /**
175: * Name of an application profile that can be used with the online resource.
176: */
177: private String applicationProfile;
178:
179: /**
180: * Detailed text description of what the online resource is/does.
181: */
182: private InternationalString description;
183:
184: /**
185: * Code for function performed by the online resource.
186: */
187: private OnLineFunction function;
188:
189: /**
190: * Location (address) for on-line access using a Uniform Resource Locator address or
191: * similar addressing scheme such as http://www.statkart.no/isotc211.
192: */
193: private URI linkage;
194:
195: /**
196: * Name of the online resources.
197: */
198: private String name;
199:
200: /**
201: * Creates an initially empty on line resource.
202: */
203: public OnLineResourceImpl() {
204: }
205:
206: /**
207: * Constructs a metadata entity initialized with the values from the specified metadata.
208: *
209: * @since 2.4
210: */
211: public OnLineResourceImpl(final OnLineResource source) {
212: super (source);
213: }
214:
215: /**
216: * Creates an on line resource initialized to the given URI.
217: * This method is private for now since, if this constructor was public, some
218: * users may expect a string argument to be for the description text instead.
219: * Furthermore, a public method should not catch the {@link URISyntaxException}
220: * and should not set a function.
221: */
222: private OnLineResourceImpl(final String linkage) {
223: try {
224: setLinkage(new URI(linkage));
225: } catch (URISyntaxException exception) {
226: // Should never happen. TODO: chain the exception in J2SE 1.5.
227: throw new IllegalArgumentException(/*exception*/);
228: }
229: setFunction(OnLineFunction.INFORMATION);
230: }
231:
232: /**
233: * Creates an on line resource initialized to the given URI.
234: */
235: public OnLineResourceImpl(final URI linkage) {
236: setLinkage(linkage);
237: }
238:
239: /**
240: * Returns the name of an application profile that can be used with the online resource.
241: * Returns {@code null} if none.
242: */
243: public String getApplicationProfile() {
244: return applicationProfile;
245: }
246:
247: /**
248: * Set the name of an application profile that can be used with the online resource.
249: */
250: public synchronized void setApplicationProfile(final String newValue) {
251: checkWritePermission();
252: applicationProfile = newValue;
253: }
254:
255: /**
256: * Name of the online resource. Returns {@code null} if none.
257: *
258: * @since 2.4
259: */
260: public String getName() {
261: return name;
262: }
263:
264: /**
265: * Set the name of the online resource.
266: *
267: * @since 2.4
268: */
269: public synchronized void setName(final String newValue) {
270: checkWritePermission();
271: name = newValue;
272: }
273:
274: /**
275: * Returns the detailed text description of what the online resource is/does.
276: * Returns {@code null} if none.
277: */
278: public InternationalString getDescription() {
279: return description;
280: }
281:
282: /**
283: * Set the detailed text description of what the online resource is/does.
284: */
285: public synchronized void setDescription(
286: final InternationalString newValue) {
287: checkWritePermission();
288: description = newValue;
289: }
290:
291: /**
292: * Returns the code for function performed by the online resource.
293: * Returns {@code null} if unspecified.
294: */
295: public OnLineFunction getFunction() {
296: return function;
297: }
298:
299: /**
300: * Set the code for function performed by the online resource.
301: */
302: public synchronized void setFunction(final OnLineFunction newValue) {
303: checkWritePermission();
304: function = newValue;
305: }
306:
307: /**
308: * Returns the location (address) for on-line access using a Uniform Resource Locator address or
309: * similar addressing scheme such as http://www.statkart.no/isotc211.
310: */
311: public URI getLinkage() {
312: return linkage;
313: }
314:
315: /**
316: * Set the location (address) for on-line access using a Uniform Resource Locator address or
317: * similar addressing scheme such as http://www.statkart.no/isotc211.
318: */
319: public synchronized void setLinkage(final URI newValue) {
320: checkWritePermission();
321: linkage = newValue;
322: }
323:
324: /**
325: * Returns the connection protocol to be used.
326: * Returns {@code null} if none.
327: */
328: public String getProtocol() {
329: final URI linkage = this.linkage;
330: return (linkage != null) ? linkage.getScheme() : null;
331: }
332: }
|