View Javadoc
1   /*
2    *  jDTAUS Banking Messages
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.messages;
22  
23  import java.util.Date;
24  import java.util.Locale;
25  import org.jdtaus.core.container.ContainerFactory;
26  import org.jdtaus.core.text.Message;
27  
28  /**
29   * Message stating that a currency is invalid at a given date.
30   *
31   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32   * @version $JDTAUS: IllegalCurrencyMessage.java 8865 2014-01-10 17:13:42Z schulte $
33   */
34  public final class IllegalCurrencyMessage extends Message
35  {
36  
37      /** Serial version UID for backwards compatibility with 1.0.x classes. */
38      private static final long serialVersionUID = -2259517733162759316L;
39  
40      /**
41       * The ISO currency code of the illegal currency.
42       * @serial
43       */
44      private final String currencyCode;
45  
46      /**
47       * The date at which {@code currenycCode} is illegal.
48       * @serial
49       */
50      private final Date date;
51  
52      /**
53       * Creates a new {@code IllegalCurrencyMessage} instance taking the ISO currency code of the illegal currency at a
54       * given date.
55       *
56       * @param currencyCode The ISO currency code of the illegal currency.
57       * @param date The date at which {@code currencyCode} is illegal.
58       *
59       * @throws NullPointerException if either {@code currencyCode} or {@code date} is {@code null}.
60       */
61      public IllegalCurrencyMessage( final String currencyCode, final Date date )
62      {
63          super();
64  
65          if ( currencyCode == null )
66          {
67              throw new NullPointerException( "currencyCode" );
68          }
69          if ( date == null )
70          {
71              throw new NullPointerException( "date" );
72          }
73  
74          this.currencyCode = currencyCode;
75          this.date = (Date) date.clone();
76      }
77  
78      /**
79       * {@inheritDoc}
80       *
81       * @return The ISO currency code of the illegal currency with corresponding date.
82       * <ul>
83       * <li>[0]: ISO currency code.</li>
84       * <li>[1]: date.</li>
85       * </ul>
86       */
87      public Object[] getFormatArguments( final Locale locale )
88      {
89          return new Object[]
90              {
91                  this.currencyCode, this.date
92              };
93      }
94  
95      /**
96       * {@inheritDoc}
97       *
98       * @return The corresponding text from the message's {@code ResourceBundle}
99       * <blockquote><pre>
100      * The currency {0} is illegal at {1,date,long}.
101      * </pre></blockquote>
102      */
103     public String getText( final Locale locale )
104     {
105         return this.getIllegalCurrencyMessage( locale, this.currencyCode, this.date );
106     }
107 
108     //--Messages----------------------------------------------------------------
109 
110 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages
111     // This section is managed by jdtaus-container-mojo.
112 
113     /**
114      * Gets the text of message <code>illegalCurrency</code>.
115      * <blockquote><pre>Die {0} Währung ist am {1,date,long} ungültig.</pre></blockquote>
116      * <blockquote><pre>The currency {0} is illegal at {1,date,long}.</pre></blockquote>
117      *
118      * @param locale The locale of the message instance to return.
119      * @param cur format parameter.
120      * @param dat format parameter.
121      *
122      * @return the text of message <code>illegalCurrency</code>.
123      */
124     private String getIllegalCurrencyMessage( final Locale locale,
125             final java.lang.String cur,
126             final java.util.Date dat )
127     {
128         return ContainerFactory.getContainer().
129             getMessage( this, "illegalCurrency", locale,
130                 new Object[]
131                 {
132                     cur,
133                     dat
134                 });
135 
136     }
137 
138 // </editor-fold>//GEN-END:jdtausMessages
139 
140     //----------------------------------------------------------------Messages--
141 }