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.banking.Textschluessel; |
25 | import org.jdtaus.banking.dtaus.LogicalFileType; |
26 | import org.jdtaus.core.container.ContainerFactory; |
27 | import org.jdtaus.core.text.Message; |
28 | |
29 | /** |
30 | * Message stating that a {@code Textschluessel} cannot be used in combination with a logical file type. |
31 | * |
32 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
33 | * @version $JDTAUS: TextschluesselConstraintMessage.java 8810 2012-12-04 00:45:37Z schulte $ |
34 | */ |
35 | public final class TextschluesselConstraintMessage extends Message |
36 | { |
37 | |
38 | /** Serial version UID for backwards compatibility with 1.0.x classes. */ |
39 | private static final long serialVersionUID = 998685158483386658L; |
40 | |
41 | /** |
42 | * The type of the logical file incompatible with {@code textschluessel}. |
43 | * @serial |
44 | */ |
45 | private final LogicalFileType fileType; |
46 | |
47 | /** |
48 | * The {@code Textschluessel} incompatible with {@code fileType}. |
49 | * @serial |
50 | */ |
51 | private final Textschluessel textschluessel; |
52 | |
53 | /** |
54 | * Creates a new {@code TextschluesselConstraintMessage} taking the logical file's type and the incompatible |
55 | * {@code Textschluessel}. |
56 | * |
57 | * @param fileType The type of the logical file causing this exception. |
58 | * @param textschluessel The {@code Textschluessel} incompatible with {@code fileType}. |
59 | * |
60 | * @throws NullPointerException if either {@code fileType} or {@code textschluessel} is {@code null}. |
61 | */ |
62 | public TextschluesselConstraintMessage( final LogicalFileType fileType, final Textschluessel textschluessel ) |
63 | { |
64 | super(); |
65 | |
66 | if ( fileType == null ) |
67 | { |
68 | throw new NullPointerException( "fileType" ); |
69 | } |
70 | if ( textschluessel == null ) |
71 | { |
72 | throw new NullPointerException( "textschluessel" ); |
73 | } |
74 | |
75 | this.fileType = fileType; |
76 | this.textschluessel = textschluessel; |
77 | } |
78 | |
79 | /** |
80 | * {@inheritDoc} |
81 | * |
82 | * @return The DTAUS code of the file's type and the key and extension of the incompatible {@code Textschluessel}. |
83 | * <ul> |
84 | * <li>[0]: the DTAUS code of the file's type.</li> |
85 | * <li>[!]: the key of the incompatible {@code Textschluessel}.</li> |
86 | * <li>[2]: the extension of the incompatible {@code Textschluessel}.</li> |
87 | * </ul> |
88 | */ |
89 | public Object[] getFormatArguments( final Locale locale ) |
90 | { |
91 | return new Object[] |
92 | { |
93 | this.fileType.getCode(), |
94 | new Integer( this.textschluessel.getKey() ), |
95 | new Integer( this.textschluessel.getExtension() ) |
96 | }; |
97 | } |
98 | |
99 | /** |
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 | } |