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 given schedule is invalid. 30 * 31 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 32 * @version $JDTAUS: IllegalScheduleMessage.java 8865 2014-01-10 17:13:42Z schulte $ 33 */ 34 public final class IllegalScheduleMessage extends Message 35 { 36 37 /** Serial version UID for backwards compatibility with 1.0.x classes. */ 38 private static final long serialVersionUID = -8689097743116031670L; 39 40 /** 41 * Create date of the illegal schedule. 42 * @serial 43 */ 44 private final Date createDate; 45 46 /** 47 * Execution date of the illegal schedule. 48 * @serial 49 */ 50 private final Date executionDate; 51 52 /** 53 * Maximum number of days allowed between {@code createDate} and 54 * {@code executionDate}. 55 * @serial 56 */ 57 private final int maxDays; 58 59 /** 60 * Creates a new {@code IllegalScheduleMessage} instance taking the create date and the date of execution not 61 * forming a valid schedule for a maximum number of days between them. 62 * 63 * @param createDate The create date of the schedule. 64 * @param executionDate The execution date of the schedule. 65 * @param maxDays The maximum number of days allowed between {@code createDate} and {@code executionDate}. 66 * 67 * @throws NullPointerException if {@code createDate} is {@code null}. 68 * @throws IllegalArgumentException if {@code maxDays} is negative. 69 */ 70 public IllegalScheduleMessage( final Date createDate, final Date executionDate, final int maxDays ) 71 { 72 super(); 73 if ( createDate == null ) 74 { 75 throw new NullPointerException( "createDate" ); 76 } 77 if ( maxDays < 0 ) 78 { 79 throw new IllegalArgumentException( Integer.toString( maxDays ) ); 80 } 81 82 this.createDate = (Date) createDate.clone(); 83 this.executionDate = (Date) ( executionDate == null ? null : executionDate.clone() ); 84 this.maxDays = maxDays; 85 } 86 87 /** 88 * {@inheritDoc} 89 * 90 * @return The create date and the date of execution. 91 * <ul> 92 * <li>[0]: the create date of the schedule.</li> 93 * <li>[1]: the date of execution of the invalid schedule.</li> 94 * <li>[2]: the maximum number of days allowed between create date and 95 * execution date.</li> 96 * </ul> 97 */ 98 public Object[] getFormatArguments( final Locale locale ) 99 { 100 return new Object[] 101 { 102 this.createDate, this.executionDate, new Integer( this.maxDays ) 103 }; 104 } 105 106 /** 107 * {@inheritDoc} 108 * 109 * @return The corresponding text from the message's {@code ResourceBundle} 110 * <blockquote><pre> 111 * The executiondate {1,date,long} is before create date {0,date,long} or more than {2,number} days thereafter. 112 * </pre></blockquote> 113 */ 114 public String getText( final Locale locale ) 115 { 116 return this.getIllegalScheduleMessage( locale, this.createDate, this.executionDate, 117 new Integer( this.maxDays ) ); 118 119 } 120 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>illegalSchedule</code>. 128 * <blockquote><pre>Das Ausführungsdatum {1,date,long} liegt vor dem Dateierstellungsdatum {0,date,long} oder mehr als {2,number} Kalendertage dahinter.</pre></blockquote> 129 * <blockquote><pre>The executiondate {1,date,long} is before create date {0,date,long} or more than {2,number} days thereafter.</pre></blockquote> 130 * 131 * @param locale The locale of the message instance to return. 132 * @param cdat format parameter. 133 * @param edat format parameter. 134 * @param max format parameter. 135 * 136 * @return the text of message <code>illegalSchedule</code>. 137 */ 138 private String getIllegalScheduleMessage( final Locale locale, 139 final java.util.Date cdat, 140 final java.util.Date edat, 141 final java.lang.Number max ) 142 { 143 return ContainerFactory.getContainer(). 144 getMessage( this, "illegalSchedule", locale, 145 new Object[] 146 { 147 cdat, 148 edat, 149 max 150 }); 151 152 } 153 154 // </editor-fold>//GEN-END:jdtausMessages 155 156 //----------------------------------------------------------------Messages-- 157 }