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