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