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.Locale;
024import org.jdtaus.core.container.ContainerFactory;
025import org.jdtaus.core.text.Message;
026
027/**
028 * Message stating that in illegal amount of descriptions is used.
029 *
030 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
031 * @version $JDTAUS: IllegalDescriptionCountMessage.java 8810 2012-12-04 00:45:37Z schulte $
032 */
033public final class IllegalDescriptionCountMessage extends Message
034{
035
036    /** Serial version UID for backwards compatibility with 1.0.x classes. */
037    private static final long serialVersionUID = 1131942219877499068L;
038
039    /**
040     * Maximum number of supported descriptions.
041     * @serial
042     */
043    private final int maxDescriptions;
044
045    /**
046     * Requested number of descriptions.
047     * @serial
048     */
049    private final int requestedDescriptions;
050
051    /**
052     * Creates a new {@code IllegalDescriptionCountMessage} instance taking the maximum number of supported descriptions
053     * and the number of requested descriptions.
054     *
055     * @param maxDescriptions The maximum number of supported descriptions.
056     * @param requestedDescriptions The requested number of descriptions.
057     */
058    public IllegalDescriptionCountMessage( final int maxDescriptions, final int requestedDescriptions )
059    {
060        super();
061        this.maxDescriptions = maxDescriptions;
062        this.requestedDescriptions = requestedDescriptions;
063    }
064
065    /**
066     * {@inheritDoc}
067     *
068     * @return The maximum number of supported descriptions and the requested number of descriptions.
069     * <ul>
070     * <li>[0]: the maximum number of supported descriptions.</li>
071     * <li>[1]: the requested number of descriptions.</li>
072     * </ul>
073     */
074    public Object[] getFormatArguments( final Locale locale )
075    {
076        return new Object[]
077            {
078                new Integer( this.maxDescriptions ),
079                new Integer( this.requestedDescriptions )
080            };
081    }
082
083    /**
084     * {@inheritDoc}
085     *
086     * @return The corresponding text from the message's {@code ResourceBundle}
087     * <blockquote><pre>
088     * The number of descriptions ({1,number}) exceeds the possible number {0,number}.
089     * </pre></blockquote>
090     */
091    public String getText( final Locale locale )
092    {
093        return this.getIllegalDescriptionCountMessage(
094            locale, new Integer( this.requestedDescriptions ), new Integer( this.maxDescriptions ) );
095
096    }
097
098    //--Messages----------------------------------------------------------------
099
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}