001/*
002 *  jDTAUS Banking API
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.banking;
022
023import java.util.Locale;
024import org.jdtaus.core.container.ContainerFactory;
025
026/**
027 * Gets thrown whenever the {@code BankleitzahlenVerzeichnis} is queried for
028 * a Bankleitzahl which got deleted in the past.
029 *
030 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
031 * @version $JDTAUS: BankleitzahlExpirationException.java 8810 2012-12-04 00:45:37Z schulte $
032 */
033public class BankleitzahlExpirationException extends Exception
034{
035
036    /** Serial version UID for backwards compatibility with 1.1.x classes. */
037    private static final long serialVersionUID = -1834668094534345716L;
038
039    /**
040     * Information about the expired Bankleitzahl.
041     * @serial
042     */
043    private final BankleitzahlInfo info;
044
045    /**
046     * Information about the Bankleitzahl replacing the expired Bankleitzahl.
047     * @serial
048     */
049    private final BankleitzahlInfo replacement;
050
051    /**
052     * Creates a new {@code BankleitzahlExpirationException} taking the bankcode information of the expired
053     * Bankleitzahl.
054     *
055     * @param info The bankcode information of the expired Bankleitzahl.
056     * @param replacement The bankcode information of the Bankleitzahl replacing {@code info}.
057     *
058     * @throws NullPointerException if either {@code info} or {@code replacement} is {@code null}.
059     */
060    public BankleitzahlExpirationException( final BankleitzahlInfo info, final BankleitzahlInfo replacement )
061    {
062        super();
063        this.info = info;
064        this.replacement = replacement;
065    }
066
067    /**
068     * Gets information about the expired Bankleitzahl.
069     *
070     * @return Information about the expired Bankleitzahl.
071     */
072    public BankleitzahlInfo getExpiredBankleitzahlInfo()
073    {
074        return this.info;
075    }
076
077    /**
078     * Gets information about the Bankleitzahl replacing the expired Bankleitzahl.
079     *
080     * @return information about the Bankleitzahl replacing the expired Bankleitzahl.
081     */
082    public BankleitzahlInfo getReplacingBankleitzahlInfo()
083    {
084        return this.replacement;
085    }
086
087    /**
088     * Returns the message of the exception.
089     *
090     * @return The message of the exception.
091     */
092    public String getMessage()
093    {
094        return this.getBankleitzahlExpirationMessage(
095            this.getLocale(), this.info.getBankCode().format( Bankleitzahl.LETTER_FORMAT ),
096            this.replacement.getBankCode().format( Bankleitzahl.LETTER_FORMAT ) );
097
098    }
099
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}