1 /*
2  *    GeoAPI - Java interfaces for OGC/ISO standards
3  *    http://www.geoapi.org
4  *
5  *    Copyright (C) 2008-2011 Open Geospatial Consortium, Inc.
6  *    All Rights Reserved. http://www.opengeospatial.org/ogc/legal
7  *
8  *    Permission to use, copy, and modify this software and its documentation, with
9  *    or without modification, for any purpose and without fee or royalty is hereby
10  *    granted, provided that you include the following on ALL copies of the software
11  *    and documentation or portions thereof, including modifications, that you make:
12  *
13  *    1. The full text of this NOTICE in a location viewable to users of the
14  *       redistributed or derivative work.
15  *    2. Notice of any changes or modifications to the OGC files, including the
16  *       date changes were made.
17  *
18  *    THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
19  *    NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
20  *    TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
21  *    THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
22  *    PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
23  *
24  *    COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
25  *    CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
26  *
27  *    The name and trademarks of copyright holders may NOT be used in advertising or
28  *    publicity pertaining to the software without specific, written prior permission.
29  *    Title to copyright in this software and any associated documentation will at all
30  *    times remain with copyright holders.
31  */
32 package org.opengis.test;
33 
34 import org.opengis.util.*;
35 import org.opengis.metadata.extent.*;
36 import org.opengis.metadata.citation.*;
37 import org.opengis.geometry.*;
38 import org.opengis.parameter.*;
39 import org.opengis.referencing.*;
40 import org.opengis.referencing.cs.*;
41 import org.opengis.referencing.crs.*;
42 import org.opengis.referencing.datum.*;
43 import org.opengis.referencing.operation.*;
44 
45 // Following imports are for javadoc
46 import org.opengis.test.util.*;
47 import org.opengis.test.geometry.*;
48 import org.opengis.test.metadata.*;
49 import org.opengis.test.referencing.*;
50 
51 
52 /**
53  * A set of convenience static methods for validating GeoAPI implementations. Every
54  * {@code validate} method defined in this class delegate their work to one of many
55  * {@link Validator} objects in various packages. This class is especially convenient
56  * when used with the {@code static import} feature of Java 5.
57  *
58  * <p>To override some validation process on a system-wide basis, vendors can change the
59  * {@link #DEFAULT} static field or change the configuration of the object referenced
60  * by that field.</p>
61  *
62  * <p>To override some validation process without changing the system-wide setting,
63  * users can create a new instance of {@link ValidatorContainer} and use that instance
64  * instead of this class.</p>
65  *
66  * @author  Martin Desruisseaux (Geomatys)
67  * @version 3.0
68  * @since   2.2
69  */
70 public class Validators {
71     /**
72      * The default container to be used by all static {@code validate} methods.
73      * Vendors can change this field to a different container, or change the setting
74      * of the referenced container. This field shall not be set to {@code null} however.
75      */
76     public static ValidatorContainer DEFAULT = new ValidatorContainer();
77 
78     /**
79      * For subclass constructors only.
80      */
Validators()81     protected Validators() {
82     }
83 
84     /**
85      * Dispatches the given object to one of the {@code validate(object)} methods.
86      * Use this method only if the type is unknow at compile-time.
87      *
88      * @param object The object to test, or {@code null}.
89      */
dispatch(final Object object)90     public final void dispatch(final Object object) {
91         DEFAULT.dispatch(object);
92     }
93 
94     /**
95      * Tests the conformance of the given object.
96      *
97      * @param object The object to test, or {@code null}.
98      * @see ExtentValidator#validate(Extent)
99      */
validate(final Extent object)100     public static void validate(final Extent object) {
101         DEFAULT.validate(object);
102     }
103 
104     /**
105      * Tests the conformance of the given object.
106      *
107      * @param object The object to test, or {@code null}.
108      * @see ExtentValidator#validate(TemporalExtent)
109      */
validate(final TemporalExtent object)110     public static void validate(final TemporalExtent object) {
111         DEFAULT.validate(object);
112     }
113 
114     /**
115      * Tests the conformance of the given object.
116      *
117      * @param object The object to test, or {@code null}.
118      * @see ExtentValidator#validate(VerticalExtent)
119      */
validate(final VerticalExtent object)120     public static void validate(final VerticalExtent object) {
121         DEFAULT.validate(object);
122     }
123 
124     /**
125      * Tests the conformance of the given object.
126      *
127      * @param object The object to test, or {@code null}.
128      * @see ExtentValidator#dispatch(GeographicExtent)
129      */
validate(final GeographicExtent object)130     public static void validate(final GeographicExtent object) {
131         DEFAULT.validate(object);
132     }
133 
134     /**
135      * Tests the conformance of the given object.
136      *
137      * @param object The object to test, or {@code null}.
138      * @see ExtentValidator#validate(GeographicDescription)
139      */
validate(final GeographicDescription object)140     public static void validate(final GeographicDescription object) {
141         DEFAULT.validate(object);
142     }
143 
144     /**
145      * Tests the conformance of the given object.
146      *
147      * @param object The object to test, or {@code null}.
148      * @see ExtentValidator#validate(BoundingPolygon)
149      */
validate(final BoundingPolygon object)150     public static void validate(final BoundingPolygon object) {
151         DEFAULT.validate(object);
152     }
153 
154     /**
155      * Tests the conformance of the given object.
156      *
157      * @param object The object to test, or {@code null}.
158      * @see ExtentValidator#validate(GeographicBoundingBox)
159      */
validate(final GeographicBoundingBox object)160     public static void validate(final GeographicBoundingBox object) {
161         DEFAULT.validate(object);
162     }
163 
164     /**
165      * Tests the conformance of the given object.
166      *
167      * @param object The object to test, or {@code null}.
168      * @see GeometryValidator#validate(Envelope)
169      */
validate(final Envelope object)170     public static void validate(final Envelope object) {
171         DEFAULT.validate(object);
172     }
173 
174     /**
175      * Tests the conformance of the given object.
176      *
177      * @param object The object to test, or {@code null}.
178      * @see GeometryValidator#validate(DirectPosition)
179      */
validate(final DirectPosition object)180     public static void validate(final DirectPosition object) {
181         DEFAULT.validate(object);
182     }
183 
184     /**
185      * Tests the conformance of the given object.
186      *
187      * @param object The object to test, or {@code null}.
188      * @see CRSValidator#dispatch(CoordinateReferenceSystem)
189      */
validate(final CoordinateReferenceSystem object)190     public static void validate(final CoordinateReferenceSystem object) {
191         DEFAULT.validate(object);
192     }
193 
194     /**
195      * Tests the conformance of the given object.
196      *
197      * @param object The object to test, or {@code null}.
198      * @see CRSValidator#validate(GeocentricCRS)
199      */
validate(final GeocentricCRS object)200     public static void validate(final GeocentricCRS object) {
201         DEFAULT.validate(object);
202     }
203 
204     /**
205      * Tests the conformance of the given object.
206      *
207      * @param object The object to test, or {@code null}.
208      * @see CRSValidator#validate(GeographicCRS)
209      */
validate(final GeographicCRS object)210     public static void validate(final GeographicCRS object) {
211         DEFAULT.validate(object);
212     }
213 
214     /**
215      * Validates the given coordinate reference system.
216      *
217      * @param object The object to validate, or {@code null}.
218      * @see CRSValidator#validate(ProjectedCRS)
219      */
validate(final ProjectedCRS object)220     public static void validate(final ProjectedCRS object) {
221         DEFAULT.validate(object);
222     }
223 
224     /**
225      * Validates the given coordinate reference system.
226      *
227      * @param object The object to validate, or {@code null}.
228      * @see CRSValidator#validate(DerivedCRS)
229      */
validate(final DerivedCRS object)230     public static void validate(final DerivedCRS object) {
231         DEFAULT.validate(object);
232     }
233 
234     /**
235      * Validates the given coordinate reference system.
236      *
237      * @param object The object to validate, or {@code null}.
238      * @see CRSValidator#validate(ImageCRS)
239      */
validate(final ImageCRS object)240     public static void validate(final ImageCRS object) {
241         DEFAULT.validate(object);
242     }
243 
244     /**
245      * Validates the given coordinate reference system.
246      *
247      * @param object The object to validate, or {@code null}.
248      * @see CRSValidator#validate(EngineeringCRS)
249      */
validate(final EngineeringCRS object)250     public static void validate(final EngineeringCRS object) {
251         DEFAULT.validate(object);
252     }
253 
254     /**
255      * Validates the given coordinate reference system.
256      *
257      * @param object The object to validate, or {@code null}.
258      * @see CRSValidator#validate(VerticalCRS)
259      */
validate(final VerticalCRS object)260     public static void validate(final VerticalCRS object) {
261         DEFAULT.validate(object);
262     }
263 
264     /**
265      * Validates the given coordinate reference system.
266      *
267      * @param object The object to validate, or {@code null}.
268      * @see CRSValidator#validate(TemporalCRS)
269      */
validate(final TemporalCRS object)270     public static void validate(final TemporalCRS object) {
271         DEFAULT.validate(object);
272     }
273 
274     /**
275      * Tests the conformance of the given object.
276      *
277      * @param object The object to test, or {@code null}.
278      * @see CSValidator#dispatch(CoordinateSystem)
279      */
validate(final CoordinateSystem object)280     public static void validate(final CoordinateSystem object) {
281         DEFAULT.validate(object);
282     }
283 
284     /**
285      * Tests the conformance of the given object.
286      *
287      * @param object The object to test, or {@code null}.
288      * @see CSValidator#validate(CartesianCS)
289      */
validate(final CartesianCS object)290     public static void validate(final CartesianCS object) {
291         DEFAULT.validate(object);
292     }
293 
294     /**
295      * Tests the conformance of the given object.
296      *
297      * @param object The object to test, or {@code null}.
298      * @see CSValidator#validate(EllipsoidalCS)
299      */
validate(final EllipsoidalCS object)300     public static void validate(final EllipsoidalCS object) {
301         DEFAULT.validate(object);
302     }
303 
304     /**
305      * Tests the conformance of the given object.
306      *
307      * @param object The object to test, or {@code null}.
308      * @see CSValidator#validate(SphericalCS)
309      */
validate(final SphericalCS object)310     public static void validate(final SphericalCS object) {
311         DEFAULT.validate(object);
312     }
313 
314     /**
315      * Tests the conformance of the given object.
316      *
317      * @param object The object to test, or {@code null}.
318      * @see CSValidator#validate(CylindricalCS)
319      */
validate(final CylindricalCS object)320     public static void validate(final CylindricalCS object) {
321         DEFAULT.validate(object);
322     }
323 
324     /**
325      * Tests the conformance of the given object.
326      *
327      * @param object The object to test, or {@code null}.
328      * @see CSValidator#validate(PolarCS)
329      */
validate(final PolarCS object)330     public static void validate(final PolarCS object) {
331         DEFAULT.validate(object);
332     }
333 
334     /**
335      * Tests the conformance of the given object.
336      *
337      * @param object The object to test, or {@code null}.
338      * @see CSValidator#validate(LinearCS)
339      */
validate(final LinearCS object)340     public static void validate(final LinearCS object) {
341         DEFAULT.validate(object);
342     }
343 
344     /**
345      * Tests the conformance of the given object.
346      *
347      * @param object The object to test, or {@code null}.
348      * @see CSValidator#validate(VerticalCS)
349      */
validate(final VerticalCS object)350     public static void validate(final VerticalCS object) {
351         DEFAULT.validate(object);
352     }
353 
354     /**
355      * Tests the conformance of the given object.
356      *
357      * @param object The object to test, or {@code null}.
358      * @see CSValidator#validate(TimeCS)
359      */
validate(final TimeCS object)360     public static void validate(final TimeCS object) {
361         DEFAULT.validate(object);
362     }
363 
364     /**
365      * Tests the conformance of the given object.
366      *
367      * @param object The object to test, or {@code null}.
368      * @see CSValidator#validate(UserDefinedCS)
369      */
validate(final UserDefinedCS object)370     public static void validate(final UserDefinedCS object) {
371         DEFAULT.validate(object);
372     }
373 
374     /**
375      * Tests the conformance of the given object.
376      *
377      * @param object The object to test, or {@code null}.
378      * @see CSValidator#validate(CoordinateSystemAxis)
379      */
validate(final CoordinateSystemAxis object)380     public static void validate(final CoordinateSystemAxis object) {
381         DEFAULT.validate(object);
382     }
383 
384     /**
385      * Tests the conformance of the given object.
386      *
387      * @param object The object to test, or {@code null}.
388      * @see DatumValidator#dispatch(Datum)
389      */
validate(final Datum object)390     public static void validate(final Datum object) {
391         DEFAULT.validate(object);
392     }
393 
394     /**
395      * Tests the conformance of the given object.
396      *
397      * @param object The object to test, or {@code null}.
398      * @see DatumValidator#validate(PrimeMeridian)
399      */
validate(final PrimeMeridian object)400     public static void validate(final PrimeMeridian object) {
401         DEFAULT.validate(object);
402     }
403 
404     /**
405      * Tests the conformance of the given object.
406      *
407      * @param object The object to test, or {@code null}.
408      * @see DatumValidator#validate(Ellipsoid)
409      */
validate(final Ellipsoid object)410     public static void validate(final Ellipsoid object) {
411         DEFAULT.validate(object);
412     }
413 
414     /**
415      * Tests the conformance of the given object.
416      *
417      * @param object The object to test, or {@code null}.
418      * @see DatumValidator#validate(GeodeticDatum)
419      */
validate(final GeodeticDatum object)420     public static void validate(final GeodeticDatum object) {
421         DEFAULT.validate(object);
422     }
423 
424     /**
425      * Tests the conformance of the given object.
426      *
427      * @param object The object to test, or {@code null}.
428      * @see DatumValidator#validate(VerticalDatum)
429      */
validate(final VerticalDatum object)430     public static void validate(final VerticalDatum object) {
431         DEFAULT.validate(object);
432     }
433 
434     /**
435      * Tests the conformance of the given object.
436      *
437      * @param object The object to test, or {@code null}.
438      * @see DatumValidator#validate(TemporalDatum)
439      */
validate(final TemporalDatum object)440     public static void validate(final TemporalDatum object) {
441         DEFAULT.validate(object);
442     }
443 
444     /**
445      * Tests the conformance of the given object.
446      *
447      * @param object The object to test, or {@code null}.
448      * @see DatumValidator#validate(ImageDatum)
449      */
validate(final ImageDatum object)450     public static void validate(final ImageDatum object) {
451         DEFAULT.validate(object);
452     }
453 
454     /**
455      * Tests the conformance of the given object.
456      *
457      * @param object The object to test, or {@code null}.
458      * @see DatumValidator#validate(EngineeringDatum)
459      */
validate(final EngineeringDatum object)460     public static void validate(final EngineeringDatum object) {
461         DEFAULT.validate(object);
462     }
463 
464     /**
465      * Tests the conformance of the given object.
466      *
467      * @param object The object to test, or {@code null}.
468      * @see OperationValidator#dispatch(CoordinateOperation)
469      */
validate(final CoordinateOperation object)470     public static void validate(final CoordinateOperation object) {
471         DEFAULT.validate(object);
472     }
473 
474     /**
475      * Tests the conformance of the given object.
476      *
477      * @param object The object to test, or {@code null}.
478      * @see OperationValidator#validate(Conversion)
479      */
validate(final Conversion object)480     public static void validate(final Conversion object) {
481         DEFAULT.validate(object);
482     }
483 
484     /**
485      * Tests the conformance of the given object.
486      *
487      * @param object The object to test, or {@code null}.
488      * @see OperationValidator#validate(Transformation)
489      */
validate(final Transformation object)490     public static void validate(final Transformation object) {
491         DEFAULT.validate(object);
492     }
493 
494     /**
495      * Tests the conformance of the given object.
496      *
497      * @param object The object to test, or {@code null}.
498      * @see OperationValidator#validate(ConcatenatedOperation)
499      */
validate(final ConcatenatedOperation object)500     public static void validate(final ConcatenatedOperation object) {
501         DEFAULT.validate(object);
502     }
503 
504     /**
505      * Tests the conformance of the given object.
506      *
507      * @param object The object to test, or {@code null}.
508      * @see OperationValidator#validate(PassThroughOperation)
509      */
validate(final PassThroughOperation object)510     public static void validate(final PassThroughOperation object) {
511         DEFAULT.validate(object);
512     }
513 
514     /**
515      * Tests the conformance of the given object.
516      *
517      * @param object The object to test, or {@code null}.
518      * @see OperationValidator#validate(OperationMethod)
519      */
validate(final OperationMethod object)520     public static void validate(final OperationMethod object) {
521         DEFAULT.validate(object);
522     }
523 
524     /**
525      * Tests the conformance of the given object.
526      *
527      * @param object The object to test, or {@code null}.
528      * @see OperationValidator#validate(Formula)
529      */
validate(final Formula object)530     public static void validate(final Formula object) {
531         DEFAULT.validate(object);
532     }
533 
534     /**
535      * Tests the conformance of the given object.
536      *
537      * @param object The object to test, or {@code null}.
538      * @see OperationValidator#validate(MathTransform)
539      */
validate(final MathTransform object)540     public static void validate(final MathTransform object) {
541         DEFAULT.validate(object);
542     }
543 
544     /**
545      * Tests the conformance of the given object.
546      *
547      * @param object The object to test, or {@code null}.
548      * @see ParameterValidator#dispatch(GeneralParameterDescriptor)
549      */
validate(final GeneralParameterDescriptor object)550     public static void validate(final GeneralParameterDescriptor object) {
551         DEFAULT.validate(object);
552     }
553 
554     /**
555      * Tests the conformance of the given object.
556      *
557      * @param object The object to test, or {@code null}.
558      * @see ParameterValidator#validate(ParameterDescriptor)
559      */
validate(final ParameterDescriptor<?> object)560     public static void validate(final ParameterDescriptor<?> object) {
561         DEFAULT.validate(object);
562     }
563 
564     /**
565      * Tests the conformance of the given object.
566      *
567      * @param object The object to test, or {@code null}.
568      * @see ParameterValidator#validate(ParameterDescriptorGroup)
569      */
validate(final ParameterDescriptorGroup object)570     public static void validate(final ParameterDescriptorGroup object) {
571         DEFAULT.validate(object);
572     }
573 
574     /**
575      * Tests the conformance of the given object.
576      *
577      * @param object The object to test, or {@code null}.
578      * @see ParameterValidator#dispatch(GeneralParameterValue)
579      */
validate(final GeneralParameterValue object)580     public static void validate(final GeneralParameterValue object) {
581         DEFAULT.validate(object);
582     }
583 
584     /**
585      * Tests the conformance of the given object.
586      *
587      * @param object The object to test, or {@code null}.
588      * @see ParameterValidator#validate(ParameterValue)
589      */
validate(final ParameterValue<?> object)590     public static void validate(final ParameterValue<?> object) {
591         DEFAULT.validate(object);
592     }
593 
594     /**
595      * Tests the conformance of the given object.
596      *
597      * @param object The object to test, or {@code null}.
598      * @see ParameterValidator#validate(ParameterValueGroup)
599      */
validate(final ParameterValueGroup object)600     public static void validate(final ParameterValueGroup object) {
601         DEFAULT.validate(object);
602     }
603 
604     /**
605      * Tests the conformance of the given object.
606      *
607      * @param object The object to test, or {@code null}.
608      * @see ReferencingValidator#dispatchObject(IdentifiedObject)
609      */
validate(final IdentifiedObject object)610     public static void validate(final IdentifiedObject object) {
611         DEFAULT.validate(object);
612     }
613 
614     /**
615      * Tests the conformance of the given object.
616      *
617      * @param object The object to test, or {@code null}.
618      * @see ReferencingValidator#validate(ReferenceIdentifier)
619      */
validate(final ReferenceIdentifier object)620     public static void validate(final ReferenceIdentifier object) {
621         DEFAULT.validate(object);
622     }
623 
624     /**
625      * Tests the conformance of the given object.
626      *
627      * @param object The object to test, or {@code null}.
628      * @see CitationValidator#validate(Citation)
629      */
validate(final Citation object)630     public static void validate(final Citation object) {
631         DEFAULT.validate(object);
632     }
633 
634     /**
635      * Tests the conformance of the given object.
636      *
637      * @param object The object to test, or {@code null}.
638      * @see NameValidator#dispatch(GenericName)
639      */
validate(final GenericName object)640     public static void validate(final GenericName object) {
641         DEFAULT.validate(object);
642     }
643 
644     /**
645      * Tests the conformance of the given object.
646      *
647      * @param object The object to test, or {@code null}.
648      * @see NameValidator#validate(LocalName)
649      */
validate(final LocalName object)650     public static void validate(final LocalName object) {
651         DEFAULT.validate(object);
652     }
653 
654     /**
655      * Tests the conformance of the given object.
656      *
657      * @param object The object to test, or {@code null}.
658      * @see NameValidator#validate(ScopedName)
659      */
validate(final ScopedName object)660     public static void validate(final ScopedName object) {
661         DEFAULT.validate(object);
662     }
663 
664     /**
665      * Tests the conformance of the given object.
666      *
667      * @param object The object to test, or {@code null}.
668      * @see NameValidator#validate(NameSpace)
669      */
validate(final NameSpace object)670     public static void validate(final NameSpace object) {
671         DEFAULT.validate(object);
672     }
673 
674     /**
675      * Tests the conformance of the given object.
676      *
677      * @param object The object to test, or {@code null}.
678      * @see NameValidator#validate(InternationalString)
679      */
validate(final InternationalString object)680     public static void validate(final InternationalString object) {
681         DEFAULT.validate(object);
682     }
683 }
684