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 property overwrite constraint violations.
029     * <p>A {@code Dependency} is allowed to provide values for any properties
030     * declared for its specification only if the specification applies to scope
031     * {@code SCOPE_MULTITON}. An implementation must provide values for all
032     * properties declared for its implemented specifications. This exception gets
033     * thrown for any violations to these restrictions.</p>
034     *
035     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a>
036     * @version $Id: PropertyOverwriteConstraintException.java 8044 2009-07-02 01:29:05Z schulte2005 $
037     *
038     * @see Implementation#getProperties()
039     * @see Dependency#getProperties()
040     */
041    public class PropertyOverwriteConstraintException extends IllegalStateException
042    {
043        //--Constants---------------------------------------------------------------
044    
045        /** Serial version UID for backwards compatibility with 1.2.x classes. */
046        private static final long serialVersionUID = -6382737345293763298L;
047    
048        //---------------------------------------------------------------Constants--
049        //--Constructors------------------------------------------------------------
050    
051        /**
052         * Creates a new {@code PropertyOverwriteConstraintException} instance
053         * taking the identifier of an implementation defining a dependency
054         * providing property values although the specification does not apply to
055         * the multiton scope.
056         *
057         * @param implementationIdentifier identifier of the implementation defining
058         * a dependency violating the constraint.
059         * @param dependencyName name of the dependency defined for the
060         * implementation identified by {@code implementationIdentifier} violating
061         * the constraint.
062         */
063        public PropertyOverwriteConstraintException(
064            final String implementationIdentifier, final String dependencyName )
065        {
066            super( PropertyOverwriteConstraintExceptionBundle.getInstance().
067                   getPropertyOverwriteConstraintMessage( Locale.getDefault(),
068                                                          implementationIdentifier,
069                                                          dependencyName ) );
070    
071            this.implementationIdentifier = implementationIdentifier;
072            this.specificationIdentifier = null;
073            this.dependencyName = dependencyName;
074            this.propertyName = null;
075        }
076    
077        /**
078         * Creates a new {@code PropertyOverwriteConstraintException} instance
079         * taking the identifier of an implementation not implementing a
080         * specification property together with information regarding the
081         * unimplemented property.
082         *
083         * @param implementationIdentifier identifier of the implementation not
084         * implementing a specification property.
085         * @param specificationIdentifier identifier of the specification an
086         * implementation does not implement a property of.
087         * @param propertyName name of the unimplemented property.
088         */
089        public PropertyOverwriteConstraintException(
090            final String implementationIdentifier,
091            final String specificationIdentifier, final String propertyName )
092        {
093            super( PropertyOverwriteConstraintExceptionBundle.getInstance().
094                   getPropertyNotImplementedMessage( Locale.getDefault(),
095                                                     implementationIdentifier,
096                                                     specificationIdentifier,
097                                                     propertyName ) );
098    
099            this.implementationIdentifier = implementationIdentifier;
100            this.specificationIdentifier = specificationIdentifier;
101            this.propertyName = propertyName;
102            this.dependencyName = null;
103        }
104    
105        //------------------------------------------------------------Constructors--
106        //--PropertyOverwriteConstraintException------------------------------------
107    
108        /**
109         * Identifier of the implementation defining a dependency violating the
110         * constraint.
111         * @serial
112         */
113        private final String implementationIdentifier;
114    
115        /**
116         * Identifier of the specification defining a property not implemented by
117         * the implementation.
118         * @serial
119         */
120        private final String specificationIdentifier;
121    
122        /**
123         * Name of the dependency defined for the implementation identified by
124         * property {@code implementationIdentifier} violating the constraint.
125         * @serial
126         */
127        private final String dependencyName;
128    
129        /**
130         * Name of the property not implemented by the implementation.
131         * @serial
132         */
133        private final String propertyName;
134    
135        /**
136         * Gets the identifier of the implementation defining a dependency
137         * violating the constraint.
138         *
139         * @return identifier of the implementation defining a dependency
140         * violating the constraint.
141         */
142        public String getImplementationIdentifier()
143        {
144            return this.implementationIdentifier;
145        }
146    
147        /**
148         * Gets the identifier of the specification defining a property not
149         * implemented by the implementation.
150         *
151         * @return identifier of the specification defining a property not
152         * implemented by the implementation or {@code null}.
153         */
154        public String getSpecificationIdentifier()
155        {
156            return this.specificationIdentifier;
157        }
158    
159        /**
160         * Gets the name of the dependency defined for the implementation identified
161         * by the value of property {@code implementationIdentifier} violating the
162         * constraint.
163         *
164         * @return name of the dependency defined for the implementation identified
165         * by the value of property {@code implementationIdentifier} violating the
166         * constraint or {@code null}.
167         */
168        public String getDependencyName()
169        {
170            return this.dependencyName;
171        }
172    
173        /**
174         * Gets the name of the property not implemented by the implementation.
175         *
176         * @return name of the property not implemented by the implementation or
177         * {@code null}.
178         */
179        public String getPropertyName()
180        {
181            return this.propertyName;
182        }
183    
184        //------------------------------------PropertyOverwriteConstraintException--
185    }