| 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.Locale; |
| 24 | import org.jdtaus.core.container.ContainerFactory; |
| 25 | import org.jdtaus.core.text.Message; |
| 26 | |
| 27 | /** |
| 28 | * Message stating that in illegal amount of descriptions is used. |
| 29 | * |
| 30 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 31 | * @version $JDTAUS: IllegalDescriptionCountMessage.java 8810 2012-12-04 00:45:37Z schulte $ |
| 32 | */ |
| 33 | public final class IllegalDescriptionCountMessage extends Message |
| 34 | { |
| 35 | |
| 36 | /** Serial version UID for backwards compatibility with 1.0.x classes. */ |
| 37 | private static final long serialVersionUID = 1131942219877499068L; |
| 38 | |
| 39 | /** |
| 40 | * Maximum number of supported descriptions. |
| 41 | * @serial |
| 42 | */ |
| 43 | private final int maxDescriptions; |
| 44 | |
| 45 | /** |
| 46 | * Requested number of descriptions. |
| 47 | * @serial |
| 48 | */ |
| 49 | private final int requestedDescriptions; |
| 50 | |
| 51 | /** |
| 52 | * Creates a new {@code IllegalDescriptionCountMessage} instance taking the maximum number of supported descriptions |
| 53 | * and the number of requested descriptions. |
| 54 | * |
| 55 | * @param maxDescriptions The maximum number of supported descriptions. |
| 56 | * @param requestedDescriptions The requested number of descriptions. |
| 57 | */ |
| 58 | public IllegalDescriptionCountMessage( final int maxDescriptions, final int requestedDescriptions ) |
| 59 | { |
| 60 | super(); |
| 61 | this.maxDescriptions = maxDescriptions; |
| 62 | this.requestedDescriptions = requestedDescriptions; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * {@inheritDoc} |
| 67 | * |
| 68 | * @return The maximum number of supported descriptions and the requested number of descriptions. |
| 69 | * <ul> |
| 70 | * <li>[0]: the maximum number of supported descriptions.</li> |
| 71 | * <li>[1]: the requested number of descriptions.</li> |
| 72 | * </ul> |
| 73 | */ |
| 74 | public Object[] getFormatArguments( final Locale locale ) |
| 75 | { |
| 76 | return new Object[] |
| 77 | { |
| 78 | new Integer( this.maxDescriptions ), |
| 79 | new Integer( this.requestedDescriptions ) |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * {@inheritDoc} |
| 85 | * |
| 86 | * @return The corresponding text from the message's {@code ResourceBundle} |
| 87 | * <blockquote><pre> |
| 88 | * The number of descriptions ({1,number}) exceeds the possible number {0,number}. |
| 89 | * </pre></blockquote> |
| 90 | */ |
| 91 | public String getText( final Locale locale ) |
| 92 | { |
| 93 | return this.getIllegalDescriptionCountMessage( |
| 94 | locale, new Integer( this.requestedDescriptions ), new Integer( this.maxDescriptions ) ); |
| 95 | |
| 96 | } |
| 97 | |
| 98 | //--Messages---------------------------------------------------------------- |
| 99 | |
| 100 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages |
| 101 | // This section is managed by jdtaus-container-mojo. |
| 102 | |
| 103 | /** |
| 104 | * Gets the text of message <code>illegalDescriptionCount</code>. |
| 105 | * <blockquote><pre>Die Anzahl der Verwendungszweckzeilen ({1,number}) übersteigt die Anzahl der zulässigen Verwendungszweckzeilen {0,number}.</pre></blockquote> |
| 106 | * <blockquote><pre>The number of descriptions ({1,number}) exceeds the possible number {0,number}.</pre></blockquote> |
| 107 | * |
| 108 | * @param locale The locale of the message instance to return. |
| 109 | * @param descriptionCount format parameter. |
| 110 | * @param allowedDescriptions format parameter. |
| 111 | * |
| 112 | * @return the text of message <code>illegalDescriptionCount</code>. |
| 113 | */ |
| 114 | private String getIllegalDescriptionCountMessage( final Locale locale, |
| 115 | final java.lang.Number descriptionCount, |
| 116 | final java.lang.Number allowedDescriptions ) |
| 117 | { |
| 118 | return ContainerFactory.getContainer(). |
| 119 | getMessage( this, "illegalDescriptionCount", locale, |
| 120 | new Object[] |
| 121 | { |
| 122 | descriptionCount, |
| 123 | allowedDescriptions |
| 124 | }); |
| 125 | |
| 126 | } |
| 127 | |
| 128 | // </editor-fold>//GEN-END:jdtausMessages |
| 129 | |
| 130 | //----------------------------------------------------------------Messages-- |
| 131 | } |