001/* 002 * jDTAUS Banking Messages 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.messages; 022 023import java.util.Date; 024import java.util.Locale; 025import org.jdtaus.core.container.ContainerFactory; 026import org.jdtaus.core.text.Message; 027 028/** 029 * Message stating that a currency is invalid at a given date. 030 * 031 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 032 * @version $JDTAUS: IllegalCurrencyMessage.java 8865 2014-01-10 17:13:42Z schulte $ 033 */ 034public final class IllegalCurrencyMessage extends Message 035{ 036 037 /** Serial version UID for backwards compatibility with 1.0.x classes. */ 038 private static final long serialVersionUID = -2259517733162759316L; 039 040 /** 041 * The ISO currency code of the illegal currency. 042 * @serial 043 */ 044 private final String currencyCode; 045 046 /** 047 * The date at which {@code currenycCode} is illegal. 048 * @serial 049 */ 050 private final Date date; 051 052 /** 053 * Creates a new {@code IllegalCurrencyMessage} instance taking the ISO currency code of the illegal currency at a 054 * given date. 055 * 056 * @param currencyCode The ISO currency code of the illegal currency. 057 * @param date The date at which {@code currencyCode} is illegal. 058 * 059 * @throws NullPointerException if either {@code currencyCode} or {@code date} is {@code null}. 060 */ 061 public IllegalCurrencyMessage( final String currencyCode, final Date date ) 062 { 063 super(); 064 065 if ( currencyCode == null ) 066 { 067 throw new NullPointerException( "currencyCode" ); 068 } 069 if ( date == null ) 070 { 071 throw new NullPointerException( "date" ); 072 } 073 074 this.currencyCode = currencyCode; 075 this.date = (Date) date.clone(); 076 } 077 078 /** 079 * {@inheritDoc} 080 * 081 * @return The ISO currency code of the illegal currency with corresponding date. 082 * <ul> 083 * <li>[0]: ISO currency code.</li> 084 * <li>[1]: date.</li> 085 * </ul> 086 */ 087 public Object[] getFormatArguments( final Locale locale ) 088 { 089 return new Object[] 090 { 091 this.currencyCode, this.date 092 }; 093 } 094 095 /** 096 * {@inheritDoc} 097 * 098 * @return The corresponding text from the message's {@code ResourceBundle} 099 * <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}