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.referencing.factory;
021:
022: // J2SE dependencies
023: import java.util.Collection;
024: import java.util.Collections;
025: import java.util.logging.Logger;
026:
027: // OpenGIS dependencies
028: import org.opengis.metadata.citation.Citation;
029: import org.opengis.parameter.InvalidParameterValueException;
030: import org.opengis.referencing.AuthorityFactory;
031: import org.opengis.referencing.Factory;
032: import org.opengis.referencing.ObjectFactory;
033:
034: // Geotools dependencies
035: import org.geotools.factory.AbstractFactory;
036: import org.geotools.metadata.iso.citation.Citations;
037: import org.geotools.metadata.iso.citation.CitationImpl;
038: import org.geotools.util.logging.Logging;
039: import org.geotools.resources.i18n.Errors;
040: import org.geotools.resources.i18n.ErrorKeys;
041: import org.geotools.resources.i18n.Vocabulary;
042: import org.geotools.resources.i18n.VocabularyKeys;
043:
044: /**
045: * Base class for all factories in the referencing module.
046: * Factories can be grouped in two categories:
047: *
048: * <ul>
049: * <li><p>{@linkplain AuthorityFactory Authority factories} creates objects from
050: * a compact string defined by an authority.
051: * <br><em>These classes are working as "builders": they hold the definition or recipie
052: * used to construct an objet.</em></p></li>
053: *
054: * <li><p>{@linkplain ObjectFactory Object factories} allows applications
055: * to make objects that cannot be created by an authority factory.
056: * This factory is very flexible, whereas the authority factory is
057: * easier to use.
058: * <br><em>These classes are working as "Factories": they provide a series of
059: * {@code create} methods that can be used like a constructor.</em></p></li>
060: * </ul>
061: *
062: * @since 2.1
063: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/factory/ReferencingFactory.java $
064: * @version $Id: ReferencingFactory.java 27862 2007-11-12 19:51:19Z desruisseaux $
065: * @author Martin Desruisseaux
066: */
067: public class ReferencingFactory extends AbstractFactory implements
068: Factory {
069: /**
070: * The logger for event related to Geotools's factories.
071: */
072: public static final Logger LOGGER = Logging
073: .getLogger("org.geotools.referencing.factory");
074:
075: /**
076: * A citation which contains only the title "All" in localized language. Used
077: * as a pseudoèauthority name for {@link AllAuthoritiesFactory}. Declared here
078: * because processed specially by {@link IdentifiedObjectFinder}, since it is
079: * not a valid authority name (not declared in {@link AllAuthoritiesFactory}
080: * because we want to avoid this dependency in {@link IdentifiedObjectFinder}).
081: */
082: static final Citation ALL;
083: static {
084: final CitationImpl citation = new CitationImpl(Vocabulary
085: .format(VocabularyKeys.ALL));
086: citation.freeze();
087: ALL = citation;
088: }
089:
090: /**
091: * Constructs a factory with the default priority.
092: */
093: protected ReferencingFactory() {
094: super ();
095: }
096:
097: /**
098: * Constructs a factory with the specified priority.
099: *
100: * @param priority The priority for this factory, as a number between
101: * {@link #MINIMUM_PRIORITY MINIMUM_PRIORITY} and
102: * {@link #MAXIMUM_PRIORITY MAXIMUM_PRIORITY} inclusive.
103: */
104: protected ReferencingFactory(final int priority) {
105: super (priority);
106: }
107:
108: /**
109: * Returns the vendor responsible for creating this factory implementation. Many implementations
110: * may be available for the same factory interface. The default implementation returns
111: * {@linkplain Citations#GEOTOOLS Geotools}.
112: *
113: * @return The vendor for this factory implementation.
114: */
115: public Citation getVendor() {
116: return Citations.GEOTOOLS;
117: }
118:
119: /**
120: * Makes sure that an argument is non-null. This is a
121: * convenience method for subclass methods.
122: *
123: * @param name Argument name.
124: * @param object User argument.
125: * @throws InvalidParameterValueException if {@code object} is null.
126: */
127: protected static void ensureNonNull(final String name,
128: final Object object) throws InvalidParameterValueException {
129: if (object == null) {
130: throw new InvalidParameterValueException(Errors.format(
131: ErrorKeys.NULL_ARGUMENT_$1, name), name, object);
132: }
133: }
134:
135: /**
136: * Returns the direct {@linkplain Factory factory} dependencies, which may be {@code null}.
137: * This method should not returns indirect dependencies. Elements should be instance of
138: * {@link Factory} or {@link FactoryException} if a particular dependency can't be obtained.
139: * <p>
140: * The default implementation always returns an empty set.
141: */
142: Collection/*<?>*/dependencies() {
143: return Collections.EMPTY_SET;
144: }
145: }
|