001    /*
002     *  jDTAUS Core API
003     *  Copyright (c) 2005 Christian Schulte
004     *
005     *  Christian Schulte, Haldener Strasse 72, 58095 Hagen, Germany
006     *  <schulte2005@users.sourceforge.net> (+49 2331 3543887)
007     *
008     *  This library is free software; you can redistribute it and/or
009     *  modify it under the terms of the GNU Lesser General Public
010     *  License as published by the Free Software Foundation; either
011     *  version 2.1 of the License, or any later version.
012     *
013     *  This library is distributed in the hope that it will be useful,
014     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
015     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016     *  Lesser General Public License for more details.
017     *
018     *  You should have received a copy of the GNU Lesser General Public
019     *  License along with this library; if not, write to the Free Software
020     *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
021     *
022     */
023    package org.jdtaus.core.container;
024    
025    import java.util.Locale;
026    
027    /**
028     * Gets thrown for implementation incompatibilities.
029     * <p>An {@code Implementation} is required to implement and to depend on a
030     * specification version compatible with the version in use. This exception
031     * gets thrown for any implementation implementing or depending on a
032     * specification version incompatible with the version in use.</p>
033     *
034     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a>
035     * @version $Id: IncompatibleImplementationException.java 8044 2009-07-02 01:29:05Z schulte2005 $
036     *
037     * @see Specification#getVersion()
038     * @see Implementation#getImplementedSpecifications()
039     */
040    public class IncompatibleImplementationException
041        extends IllegalStateException
042    {
043        //--Constants---------------------------------------------------------------
044    
045        /** Serial version UID for backwards compatibility with 1.5.x classes. */
046        private static final long serialVersionUID = 4329145399712314886L;
047    
048        //---------------------------------------------------------------Constants--
049        //--Constructors------------------------------------------------------------
050    
051        /**
052         * Creates a new {@code IncompatibleImplementationException} instance
053         * taking the implementation not implementing the specification version in
054         * use or depending on a specification version incompatible to the
055         * version in use.
056         *
057         * @param specificationIdentifier the identifier of the specification.
058         * @param specifiedVersion the version of the specification in use.
059         * @param implementationIdentifier the identifier of the implementation
060         * incompatible to {@code specifiedVersion}.
061         * @param implementedVersion the version implemented or {@code null} if
062         * the implementation does not implement the specification.
063         * @param requiredVersion the version the implementation depends on or
064         * {@code null} if the implementation does not depend on the specification.
065         */
066        public IncompatibleImplementationException(
067            final String specificationIdentifier,
068            final String specifiedVersion,
069            final String implementationIdentifier,
070            final String implementedVersion,
071            final String requiredVersion )
072        {
073            super( IncompatibleImplementationExceptionBundle.getInstance().
074                   getIncompatibleImplementationMessage(
075                   Locale.getDefault(), ( implementedVersion != null
076                   ? new Integer( 0 )
077                   : new Integer( 1 ) ), specificationIdentifier, specifiedVersion,
078                   implementationIdentifier, implementedVersion, requiredVersion ) );
079    
080            this.specificationIdentifier = specificationIdentifier;
081            this.specifiedVersion = specifiedVersion;
082            this.implementationIdentifier = implementationIdentifier;
083            this.implementedVersion = implementedVersion;
084            this.requiredVersion = requiredVersion;
085        }
086    
087        //------------------------------------------------------------Constructors--
088        //--IncompatibleImplementationException-------------------------------------
089    
090        /**
091         * The identifier of the specification.
092         * @serial
093         */
094        private String specificationIdentifier;
095    
096        /**
097         * The version of the specification in use.
098         * @serial
099         */
100        private String specifiedVersion;
101    
102        /**
103         * The identifier of the implementation not implementing the specification
104         * version in use.
105         * @serial
106         */
107        private String implementationIdentifier;
108    
109        /**
110         * The implemented version of the specification in use or {@code null} if
111         * the implementation does not implement the specification.
112         * @serial
113         */
114        private String implementedVersion;
115    
116        /**
117         * The version the implementation depends on or {@code null} if the
118         * implementation does not depend on the specification.
119         * @serial
120         */
121        private String requiredVersion;
122    
123        /**
124         * Gets the identifier of the specification.
125         *
126         * @return the identifier of the specification.
127         */
128        public String getSpecificationIdentifier()
129        {
130            return this.specificationIdentifier;
131        }
132    
133        /**
134         * Gets the version of the specification in use.
135         *
136         * @return the version of the specification in use.
137         */
138        public String getSpecifiedVersion()
139        {
140            return this.specifiedVersion;
141        }
142    
143        /**
144         * Gets the identifier of the implementation not implementing the
145         * specification version in use.
146         *
147         * @return the identifier of the implementation not implementing the
148         * specification version in use.
149         */
150        public String getImplementationIdentifier()
151        {
152            return this.implementationIdentifier;
153        }
154    
155        /**
156         * Gets the implemented version of the specification in use.
157         *
158         * @return the implemented version of the specification in use or
159         * {@code null} if the implementation does not implement the specification.
160         */
161        public String getImplementedVersion()
162        {
163            return this.implementedVersion;
164        }
165    
166        /**
167         * Gets the required version of the specification in use.
168         *
169         * @return the version the implementation depends on or {@code null} if the
170         * implementation does not depend on the specification.
171         */
172        public String getRequiredVersion()
173        {
174            return this.requiredVersion;
175        }
176    
177        //-------------------------------------IncompatibleImplementationException--
178    }