| 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 | |
| 26 | /** |
| 27 | * Gets thrown whenever the {@code BankleitzahlenVerzeichnis} is queried for |
| 28 | * a Bankleitzahl which got deleted in the past. |
| 29 | * |
| 30 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 31 | * @version $JDTAUS: BankleitzahlExpirationException.java 8810 2012-12-04 00:45:37Z schulte $ |
| 32 | */ |
| 33 | public class BankleitzahlExpirationException extends Exception |
| 34 | { |
| 35 | |
| 36 | /** Serial version UID for backwards compatibility with 1.1.x classes. */ |
| 37 | private static final long serialVersionUID = -1834668094534345716L; |
| 38 | |
| 39 | /** |
| 40 | * Information about the expired Bankleitzahl. |
| 41 | * @serial |
| 42 | */ |
| 43 | private final BankleitzahlInfo info; |
| 44 | |
| 45 | /** |
| 46 | * Information about the Bankleitzahl replacing the expired Bankleitzahl. |
| 47 | * @serial |
| 48 | */ |
| 49 | private final BankleitzahlInfo replacement; |
| 50 | |
| 51 | /** |
| 52 | * Creates a new {@code BankleitzahlExpirationException} taking the bankcode information of the expired |
| 53 | * Bankleitzahl. |
| 54 | * |
| 55 | * @param info The bankcode information of the expired Bankleitzahl. |
| 56 | * @param replacement The bankcode information of the Bankleitzahl replacing {@code info}. |
| 57 | * |
| 58 | * @throws NullPointerException if either {@code info} or {@code replacement} is {@code null}. |
| 59 | */ |
| 60 | public BankleitzahlExpirationException( final BankleitzahlInfo info, final BankleitzahlInfo replacement ) |
| 61 | { |
| 62 | super(); |
| 63 | this.info = info; |
| 64 | this.replacement = replacement; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Gets information about the expired Bankleitzahl. |
| 69 | * |
| 70 | * @return Information about the expired Bankleitzahl. |
| 71 | */ |
| 72 | public BankleitzahlInfo getExpiredBankleitzahlInfo() |
| 73 | { |
| 74 | return this.info; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Gets information about the Bankleitzahl replacing the expired Bankleitzahl. |
| 79 | * |
| 80 | * @return information about the Bankleitzahl replacing the expired Bankleitzahl. |
| 81 | */ |
| 82 | public BankleitzahlInfo getReplacingBankleitzahlInfo() |
| 83 | { |
| 84 | return this.replacement; |
| 85 | } |
| 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.getBankleitzahlExpirationMessage( |
| 95 | this.getLocale(), this.info.getBankCode().format( Bankleitzahl.LETTER_FORMAT ), |
| 96 | this.replacement.getBankCode().format( Bankleitzahl.LETTER_FORMAT ) ); |
| 97 | |
| 98 | } |
| 99 | |
| 100 | //-----------------------------------------BankleitzahlExpirationException-- |
| 101 | //--Dependencies------------------------------------------------------------ |
| 102 | |
| 103 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies |
| 104 | // This section is managed by jdtaus-container-mojo. |
| 105 | |
| 106 | /** |
| 107 | * Gets the configured <code>Locale</code> implementation. |
| 108 | * |
| 109 | * @return The configured <code>Locale</code> implementation. |
| 110 | */ |
| 111 | private Locale getLocale() |
| 112 | { |
| 113 | return (Locale) ContainerFactory.getContainer(). |
| 114 | getDependency( this, "Locale" ); |
| 115 | |
| 116 | } |
| 117 | |
| 118 | // </editor-fold>//GEN-END:jdtausDependencies |
| 119 | |
| 120 | //------------------------------------------------------------Dependencies-- |
| 121 | //--Messages---------------------------------------------------------------- |
| 122 | |
| 123 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages |
| 124 | // This section is managed by jdtaus-container-mojo. |
| 125 | |
| 126 | /** |
| 127 | * Gets the text of message <code>bankleitzahlExpiration</code>. |
| 128 | * <blockquote><pre>Die Bankleitzahl {0} ist nicht mehr gültig. Die Bank hat die Bankleitzahl {1} als Ersatz veröffentlicht.</pre></blockquote> |
| 129 | * <blockquote><pre>The Bankleitzahl {0} has expired. The bank published the replacement Bankleitzahl {1}.</pre></blockquote> |
| 130 | * |
| 131 | * @param locale The locale of the message instance to return. |
| 132 | * @param expired format parameter. |
| 133 | * @param rplc format parameter. |
| 134 | * |
| 135 | * @return the text of message <code>bankleitzahlExpiration</code>. |
| 136 | */ |
| 137 | private String getBankleitzahlExpirationMessage( final Locale locale, |
| 138 | final java.lang.String expired, |
| 139 | final java.lang.String rplc ) |
| 140 | { |
| 141 | return ContainerFactory.getContainer(). |
| 142 | getMessage( this, "bankleitzahlExpiration", locale, |
| 143 | new Object[] |
| 144 | { |
| 145 | expired, |
| 146 | rplc |
| 147 | }); |
| 148 | |
| 149 | } |
| 150 | |
| 151 | // </editor-fold>//GEN-END:jdtausMessages |
| 152 | |
| 153 | //----------------------------------------------------------------Messages-- |
| 154 | } |