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