1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.beanutils.locale.converters;
18
19 import java.util.Locale;
20
21
22 /**
23 * <p>Standard {@link org.apache.commons.beanutils.locale.LocaleConverter}
24 * implementation that converts an incoming
25 * locale-sensitive String into a <code>java.lang.Short</code> object,
26 * optionally using a default value or throwing a
27 * {@link org.apache.commons.beanutils.ConversionException}
28 * if a conversion error occurs.</p>
29 *
30 * @author Yauheny Mikulski
31 */
32
33 public class ShortLocaleConverter extends DecimalLocaleConverter {
34
35
36
37 /**
38 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
39 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
40 * if a conversion error occurs. The locale is the default locale for
41 * this instance of the Java Virtual Machine and an unlocalized pattern is used
42 * for the convertion.
43 *
44 */
45 public ShortLocaleConverter() {
46
47 this(false);
48 }
49
50 /**
51 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
52 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
53 * if a conversion error occurs. The locale is the default locale for
54 * this instance of the Java Virtual Machine.
55 *
56 * @param locPattern Indicate whether the pattern is localized or not
57 */
58 public ShortLocaleConverter(boolean locPattern) {
59
60 this(Locale.getDefault(), locPattern);
61 }
62
63 /**
64 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
65 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
66 * if a conversion error occurs. An unlocalized pattern is used for the convertion.
67 *
68 * @param locale The locale
69 */
70 public ShortLocaleConverter(Locale locale) {
71
72 this(locale, false);
73 }
74
75 /**
76 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
77 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
78 * if a conversion error occurs.
79 *
80 * @param locale The locale
81 * @param locPattern Indicate whether the pattern is localized or not
82 */
83 public ShortLocaleConverter(Locale locale, boolean locPattern) {
84
85 this(locale, (String) null, locPattern);
86 }
87
88 /**
89 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
90 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
91 * if a conversion error occurs. An unlocalized pattern is used for the convertion.
92 *
93 * @param locale The locale
94 * @param pattern The convertion pattern
95 */
96 public ShortLocaleConverter(Locale locale, String pattern) {
97
98 this(locale, pattern, false);
99 }
100
101 /**
102 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
103 * that will throw a {@link org.apache.commons.beanutils.ConversionException}
104 * if a conversion error occurs.
105 *
106 * @param locale The locale
107 * @param pattern The convertion pattern
108 * @param locPattern Indicate whether the pattern is localized or not
109 */
110 public ShortLocaleConverter(Locale locale, String pattern, boolean locPattern) {
111
112 super(locale, pattern, locPattern);
113 }
114
115 /**
116 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
117 * that will return the specified default value
118 * if a conversion error occurs. The locale is the default locale for
119 * this instance of the Java Virtual Machine and an unlocalized pattern is used
120 * for the convertion.
121 *
122 * @param defaultValue The default value to be returned
123 */
124 public ShortLocaleConverter(Object defaultValue) {
125
126 this(defaultValue, false);
127 }
128
129 /**
130 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
131 * that will return the specified default value
132 * if a conversion error occurs. The locale is the default locale for
133 * this instance of the Java Virtual Machine.
134 *
135 * @param defaultValue The default value to be returned
136 * @param locPattern Indicate whether the pattern is localized or not
137 */
138 public ShortLocaleConverter(Object defaultValue, boolean locPattern) {
139
140 this(defaultValue, Locale.getDefault(), locPattern);
141 }
142
143 /**
144 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
145 * that will return the specified default value
146 * if a conversion error occurs. An unlocalized pattern is used for the convertion.
147 *
148 * @param defaultValue The default value to be returned
149 * @param locale The locale
150 */
151 public ShortLocaleConverter(Object defaultValue, Locale locale) {
152
153 this(defaultValue, locale, false);
154 }
155
156 /**
157 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
158 * that will return the specified default value
159 * if a conversion error occurs.
160 *
161 * @param defaultValue The default value to be returned
162 * @param locale The locale
163 * @param locPattern Indicate whether the pattern is localized or not
164 */
165 public ShortLocaleConverter(Object defaultValue, Locale locale, boolean locPattern) {
166
167 this(defaultValue, locale, null, locPattern);
168 }
169
170 /**
171 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
172 * that will return the specified default value
173 * if a conversion error occurs. An unlocalized pattern is used for the convertion.
174 *
175 * @param defaultValue The default value to be returned
176 * @param locale The locale
177 * @param pattern The convertion pattern
178 */
179 public ShortLocaleConverter(Object defaultValue, Locale locale, String pattern) {
180
181 this(defaultValue, locale, pattern, false);
182 }
183
184 /**
185 * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
186 * that will return the specified default value
187 * if a conversion error occurs.
188 *
189 * @param defaultValue The default value to be returned
190 * @param locale The locale
191 * @param pattern The convertion pattern
192 * @param locPattern Indicate whether the pattern is localized or not
193 */
194 public ShortLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) {
195
196 super(defaultValue, locale, pattern);
197 }
198 }
199