1 | /* |
2 | * jDTAUS Core API |
3 | * Copyright (C) 2005 Christian Schulte |
4 | * <cs@schulte.it> |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | * |
20 | */ |
21 | package org.jdtaus.core.container; |
22 | |
23 | import java.util.Locale; |
24 | |
25 | /** |
26 | * Gets thrown for implementation incompatibilities. |
27 | * <p>An {@code Implementation} is required to implement and to depend on a |
28 | * specification version compatible with the version in use. This exception |
29 | * gets thrown for any implementation implementing or depending on a |
30 | * specification version incompatible with the version in use.</p> |
31 | * |
32 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
33 | * @version $JDTAUS: IncompatibleImplementationException.java 8743 2012-10-07 03:06:20Z schulte $ |
34 | * |
35 | * @see Specification#getVersion() |
36 | * @see Implementation#getImplementedSpecifications() |
37 | */ |
38 | public class IncompatibleImplementationException |
39 | extends IllegalStateException |
40 | { |
41 | //--Constants--------------------------------------------------------------- |
42 | |
43 | /** Serial version UID for backwards compatibility with 1.5.x classes. */ |
44 | private static final long serialVersionUID = 4329145399712314886L; |
45 | |
46 | //---------------------------------------------------------------Constants-- |
47 | //--Constructors------------------------------------------------------------ |
48 | |
49 | /** |
50 | * Creates a new {@code IncompatibleImplementationException} instance |
51 | * taking the implementation not implementing the specification version in |
52 | * use or depending on a specification version incompatible to the |
53 | * version in use. |
54 | * |
55 | * @param specificationIdentifier the identifier of the specification. |
56 | * @param specifiedVersion the version of the specification in use. |
57 | * @param implementationIdentifier the identifier of the implementation |
58 | * incompatible to {@code specifiedVersion}. |
59 | * @param implementedVersion the version implemented or {@code null} if |
60 | * the implementation does not implement the specification. |
61 | * @param requiredVersion the version the implementation depends on or |
62 | * {@code null} if the implementation does not depend on the specification. |
63 | */ |
64 | public IncompatibleImplementationException( |
65 | final String specificationIdentifier, |
66 | final String specifiedVersion, |
67 | final String implementationIdentifier, |
68 | final String implementedVersion, |
69 | final String requiredVersion ) |
70 | { |
71 | super( IncompatibleImplementationExceptionBundle.getInstance(). |
72 | getIncompatibleImplementationMessage( |
73 | Locale.getDefault(), |
74 | implementedVersion != null ? new Integer( 0 ) : new Integer( 1 ), |
75 | specificationIdentifier, specifiedVersion, implementationIdentifier, |
76 | implementedVersion, requiredVersion ) ); |
77 | |
78 | this.specificationIdentifier = specificationIdentifier; |
79 | this.specifiedVersion = specifiedVersion; |
80 | this.implementationIdentifier = implementationIdentifier; |
81 | this.implementedVersion = implementedVersion; |
82 | this.requiredVersion = requiredVersion; |
83 | } |
84 | |
85 | //------------------------------------------------------------Constructors-- |
86 | //--IncompatibleImplementationException------------------------------------- |
87 | |
88 | /** |
89 | * The identifier of the specification. |
90 | * @serial |
91 | */ |
92 | private final String specificationIdentifier; |
93 | |
94 | /** |
95 | * The version of the specification in use. |
96 | * @serial |
97 | */ |
98 | private final String specifiedVersion; |
99 | |
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 | } |