| 1 | /* | 
| 2 |  *  jDTAUS Banking 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.banking; | 
| 22 |   | 
| 23 | import java.util.Locale; | 
| 24 | import org.jdtaus.core.container.ContainerFactory; | 
| 25 | import org.jdtaus.core.text.Message; | 
| 26 |   | 
| 27 | /** | 
| 28 |  * Gets thrown whenever an illegal Textschlüssel is passed to a method expecting a legal Textschlüssel. | 
| 29 |  * <p>Example: Catching an {@code IllegalTextschluesselException}<br/><blockquote><pre> | 
| 30 |  * catch(IllegalTextschluesselException e) | 
| 31 |  * { | 
| 32 |  *     if(e.getMessages().length > 0) | 
| 33 |  *     { | 
| 34 |  *         <i>Fetch messages for well-known properties first (optional).</i> | 
| 35 |  *         e.getMessages(Textschluessel.PROP_<i>XYZ</i>); | 
| 36 |  *         ... | 
| 37 |  *         <i>Fetch all remaining messages.</i> | 
| 38 |  *         e.getMessages(); | 
| 39 |  *         ... | 
| 40 |  *     } | 
| 41 |  * }</pre></blockquote></p> | 
| 42 |  * | 
| 43 |  * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> | 
| 44 |  * @version $JDTAUS: IllegalTextschluesselException.java 8661 2012-09-27 11:29:58Z schulte $ | 
| 45 |  */ | 
| 46 | public abstract class IllegalTextschluesselException extends IllegalArgumentException | 
| 47 | { | 
| 48 |   | 
| 49 |     /** Serial version UID for backwards compatibility with 1.1.x classes. */ | 
| 50 |     private static final long serialVersionUID = 7472131429277078032L; | 
| 51 |   | 
| 52 |     /** Creates a new {@code IllegalTextschluesselException} instance. */ | 
| 53 |     public IllegalTextschluesselException() | 
| 54 |     { | 
| 55 |         super(); | 
| 56 |     } | 
| 57 |   | 
| 58 |     /** | 
| 59 |      * Gets all messages describing the exception. | 
| 60 |      * | 
| 61 |      * @return An array of messages describing the exception or an empty array if the instance does not hold any | 
| 62 |      * messages. | 
| 63 |      */ | 
| 64 |     public abstract Message[] getMessages(); | 
| 65 |   | 
| 66 |     /** | 
| 67 |      * Gets messages bound to a property removing these messages from the instance. | 
| 68 |      * | 
| 69 |      * @param propertyName The name of a property to return any messages for. | 
| 70 |      * | 
| 71 |      * @return All messages bound to a property with name {@code propertyName} or an empty array if the instance does | 
| 72 |      * not hold messages for a property with name {@code propertyName}. | 
| 73 |      * | 
| 74 |      * @throws NullPointerException if {@code propertyName} is {@code null}. | 
| 75 |      */ | 
| 76 |     public abstract Message[] getMessages( final String propertyName ); | 
| 77 |   | 
| 78 |     /** | 
| 79 |      * Gets the names of all properties for which the exception holds messages. | 
| 80 |      * | 
| 81 |      * @return An array of the names of all properties for which the exception holds messages or an empty array if the | 
| 82 |      * exception does not hold any message bound to a property. | 
| 83 |      */ | 
| 84 |     public abstract String[] getPropertyNames(); | 
| 85 |   | 
| 86 |     /** | 
| 87 |      * Returns the message of the exception. | 
| 88 |      * | 
| 89 |      * @return The message of the exception. | 
| 90 |      */ | 
| 91 |     public String getMessage() | 
| 92 |     { | 
| 93 |         return this.getIllegalTextschluesselMessage( this.getLocale() ); | 
| 94 |     } | 
| 95 |   | 
| 96 |     //--Dependencies------------------------------------------------------------ | 
| 97 |   | 
| 98 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies | 
| 99 |     // This section is managed by jdtaus-container-mojo. | 
| 100 |   | 
| 101 |     /** | 
| 102 |      * Gets the configured <code>Locale</code> implementation. | 
| 103 |      * | 
| 104 |      * @return The configured <code>Locale</code> implementation. | 
| 105 |      */ | 
| 106 |     private Locale getLocale() | 
| 107 |     { | 
| 108 |         return (Locale) ContainerFactory.getContainer(). | 
| 109 |             getDependency( this, "Locale" ); | 
| 110 |   | 
| 111 |     } | 
| 112 |   | 
| 113 | // </editor-fold>//GEN-END:jdtausDependencies | 
| 114 |   | 
| 115 |     //------------------------------------------------------------Dependencies-- | 
| 116 |     //--Messages---------------------------------------------------------------- | 
| 117 |   | 
| 118 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages | 
| 119 |     // This section is managed by jdtaus-container-mojo. | 
| 120 |   | 
| 121 |     /** | 
| 122 |      * Gets the text of message <code>illegalTextschluessel</code>. | 
| 123 |      * <blockquote><pre>Ungültiger Textschlüssel.</pre></blockquote> | 
| 124 |      * <blockquote><pre>Illegal Textschlüssel.</pre></blockquote> | 
| 125 |      * | 
| 126 |      * @param locale The locale of the message instance to return. | 
| 127 |      * | 
| 128 |      * @return the text of message <code>illegalTextschluessel</code>. | 
| 129 |      */ | 
| 130 |     private String getIllegalTextschluesselMessage( final Locale locale ) | 
| 131 |     { | 
| 132 |         return ContainerFactory.getContainer(). | 
| 133 |             getMessage( this, "illegalTextschluessel", locale, null ); | 
| 134 |   | 
| 135 |     } | 
| 136 |   | 
| 137 | // </editor-fold>//GEN-END:jdtausMessages | 
| 138 |   | 
| 139 |     //----------------------------------------------------------------Messages-- | 
| 140 | } |