1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.beanutils.locale.converters;
  17. import java.util.Locale;
  18. /**
  19. * <p>Standard {@link org.apache.commons.beanutils.locale.LocaleConverter}
  20. * implementation that converts an incoming
  21. * locale-sensitive String into a <code>java.math.BigDecimal</code> object,
  22. * optionally using a default value or throwing a
  23. * {@link org.apache.commons.beanutils.ConversionException}
  24. * if a conversion error occurs.</p>
  25. *
  26. * @author Yauheny Mikulski
  27. */
  28. public class BigDecimalLocaleConverter extends DecimalLocaleConverter {
  29. // ----------------------------------------------------------- Constructors
  30. /**
  31. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  32. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  33. * if a conversion error occurs. The locale is the default locale for
  34. * this instance of the Java Virtual Machine and an unlocalized pattern is used
  35. * for the convertion.
  36. *
  37. */
  38. public BigDecimalLocaleConverter() {
  39. this(false);
  40. }
  41. /**
  42. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  43. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  44. * if a conversion error occurs. The locale is the default locale for
  45. * this instance of the Java Virtual Machine.
  46. *
  47. * @param locPattern Indicate whether the pattern is localized or not
  48. */
  49. public BigDecimalLocaleConverter(boolean locPattern) {
  50. this(Locale.getDefault(), locPattern);
  51. }
  52. /**
  53. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  54. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  55. * if a conversion error occurs. An unlocalized pattern is used for the convertion.
  56. *
  57. * @param locale The locale
  58. */
  59. public BigDecimalLocaleConverter(Locale locale) {
  60. this(locale, false);
  61. }
  62. /**
  63. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  64. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  65. * if a conversion error occurs.
  66. *
  67. * @param locale The locale
  68. * @param locPattern Indicate whether the pattern is localized or not
  69. */
  70. public BigDecimalLocaleConverter(Locale locale, boolean locPattern) {
  71. this(locale, (String) null, locPattern);
  72. }
  73. /**
  74. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  75. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  76. * if a conversion error occurs. An unlocalized pattern is used for the convertion.
  77. *
  78. * @param locale The locale
  79. * @param pattern The convertion pattern
  80. */
  81. public BigDecimalLocaleConverter(Locale locale, String pattern) {
  82. this(locale, pattern, false);
  83. }
  84. /**
  85. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  86. * that will throw a {@link org.apache.commons.beanutils.ConversionException}
  87. * if a conversion error occurs.
  88. *
  89. * @param locale The locale
  90. * @param pattern The convertion pattern
  91. * @param locPattern Indicate whether the pattern is localized or not
  92. */
  93. public BigDecimalLocaleConverter(Locale locale, String pattern, boolean locPattern) {
  94. super(locale, pattern, locPattern);
  95. }
  96. /**
  97. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  98. * that will return the specified default value
  99. * if a conversion error occurs. The locale is the default locale for
  100. * this instance of the Java Virtual Machine and an unlocalized pattern is used
  101. * for the convertion.
  102. *
  103. * @param defaultValue The default value to be returned
  104. */
  105. public BigDecimalLocaleConverter(Object defaultValue) {
  106. this(defaultValue, false);
  107. }
  108. /**
  109. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  110. * that will return the specified default value
  111. * if a conversion error occurs. The locale is the default locale for
  112. * this instance of the Java Virtual Machine.
  113. *
  114. * @param defaultValue The default value to be returned
  115. * @param locPattern Indicate whether the pattern is localized or not
  116. */
  117. public BigDecimalLocaleConverter(Object defaultValue, boolean locPattern) {
  118. this(defaultValue, Locale.getDefault(), locPattern);
  119. }
  120. /**
  121. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  122. * that will return the specified default value
  123. * if a conversion error occurs. An unlocalized pattern is used for the convertion.
  124. *
  125. * @param defaultValue The default value to be returned
  126. * @param locale The locale
  127. */
  128. public BigDecimalLocaleConverter(Object defaultValue, Locale locale) {
  129. this(defaultValue, locale, false);
  130. }
  131. /**
  132. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  133. * that will return the specified default value
  134. * if a conversion error occurs.
  135. *
  136. * @param defaultValue The default value to be returned
  137. * @param locale The locale
  138. * @param locPattern Indicate whether the pattern is localized or not
  139. */
  140. public BigDecimalLocaleConverter(Object defaultValue, Locale locale, boolean locPattern) {
  141. this(defaultValue, locale, null, locPattern);
  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. * @param pattern The convertion pattern
  151. */
  152. public BigDecimalLocaleConverter(Object defaultValue, Locale locale, String pattern) {
  153. this(defaultValue, locale, pattern, false);
  154. }
  155. /**
  156. * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter}
  157. * that will return the specified default value
  158. * if a conversion error occurs.
  159. *
  160. * @param defaultValue The default value to be returned
  161. * @param locale The locale
  162. * @param pattern The convertion pattern
  163. * @param locPattern Indicate whether the pattern is localized or not
  164. */
  165. public BigDecimalLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) {
  166. super(defaultValue, locale, pattern);
  167. }
  168. }