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.banking.Textschluessel;
025import org.jdtaus.banking.dtaus.LogicalFileType;
026import org.jdtaus.core.container.ContainerFactory;
027import org.jdtaus.core.text.Message;
028
029/**
030 * Message stating that a {@code Textschluessel} cannot be used in combination with a logical file type.
031 *
032 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
033 * @version $JDTAUS: TextschluesselConstraintMessage.java 8810 2012-12-04 00:45:37Z schulte $
034 */
035public final class TextschluesselConstraintMessage extends Message
036{
037
038    /** Serial version UID for backwards compatibility with 1.0.x classes. */
039    private static final long serialVersionUID = 998685158483386658L;
040
041    /**
042     * The type of the logical file incompatible with {@code textschluessel}.
043     * @serial
044     */
045    private final LogicalFileType fileType;
046
047    /**
048     * The {@code Textschluessel} incompatible with {@code fileType}.
049     * @serial
050     */
051    private final Textschluessel textschluessel;
052
053    /**
054     * Creates a new {@code TextschluesselConstraintMessage} taking the logical file's type and the incompatible
055     * {@code Textschluessel}.
056     *
057     * @param fileType The type of the logical file causing this exception.
058     * @param textschluessel The {@code Textschluessel} incompatible with {@code fileType}.
059     *
060     * @throws NullPointerException if either {@code fileType} or {@code textschluessel} is {@code null}.
061     */
062    public TextschluesselConstraintMessage( final LogicalFileType fileType, final Textschluessel textschluessel )
063    {
064        super();
065
066        if ( fileType == null )
067        {
068            throw new NullPointerException( "fileType" );
069        }
070        if ( textschluessel == null )
071        {
072            throw new NullPointerException( "textschluessel" );
073        }
074
075        this.fileType = fileType;
076        this.textschluessel = textschluessel;
077    }
078
079    /**
080     * {@inheritDoc}
081     *
082     * @return The DTAUS code of the file's type and the key and extension of the incompatible {@code Textschluessel}.
083     * <ul>
084     * <li>[0]: the DTAUS code of the file's type.</li>
085     * <li>[!]: the key of the incompatible {@code Textschluessel}.</li>
086     * <li>[2]: the extension of the incompatible {@code Textschluessel}.</li>
087     * </ul>
088     */
089    public Object[] getFormatArguments( final Locale locale )
090    {
091        return new Object[]
092            {
093                this.fileType.getCode(),
094                new Integer( this.textschluessel.getKey() ),
095                new Integer( this.textschluessel.getExtension() )
096            };
097    }
098
099    /**
100     * {@inheritDoc}
101     *
102     * @return The corresponding text from the message's {@code ResourceBundle}
103     * <blockquote><pre>
104     * A logical file with label {0} cannot hold transactions with Textschlüssel {1,number,00}{2,number,000}.
105     * </pre></blockquote>
106     */
107    public String getText( final Locale locale )
108    {
109        return this.getTextschluesselConstraintMessage(
110            locale, this.fileType.getShortDescription( locale ),
111            new Integer( this.textschluessel.getKey() ),
112            new Integer( this.textschluessel.getExtension() ) );
113
114    }
115
116    //--Messages----------------------------------------------------------------
117
118// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages
119    // This section is managed by jdtaus-container-mojo.
120
121    /**
122     * Gets the text of message <code>textschluesselConstraint</code>.
123     * <blockquote><pre>Eine logische Datei vom Typ {0} kann keine {1,number,00}{2,number,000} Textschlüssel speichern.</pre></blockquote>
124     * <blockquote><pre>A logical file with label {0} cannot hold transactions with Textschlüssel {1,number,00}{2,number,000}.</pre></blockquote>
125     *
126     * @param locale The locale of the message instance to return.
127     * @param label format parameter.
128     * @param key format parameter.
129     * @param extension format parameter.
130     *
131     * @return the text of message <code>textschluesselConstraint</code>.
132     */
133    private String getTextschluesselConstraintMessage( final Locale locale,
134            final java.lang.String label,
135            final java.lang.Number key,
136            final java.lang.Number extension )
137    {
138        return ContainerFactory.getContainer().
139            getMessage( this, "textschluesselConstraint", locale,
140                new Object[]
141                {
142                    label,
143                    key,
144                    extension
145                });
146
147    }
148
149// </editor-fold>//GEN-END:jdtausMessages
150
151    //----------------------------------------------------------------Messages--
152}