Source Code Cross Referenced for BigIntegerLocaleConverter.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » locale » converters » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons beanutils 1.8.0 BETA src » org.apache.commons.beanutils.locale.converters 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.beanutils.locale.converters;
019:
020:        import java.util.Locale;
021:        import java.math.BigInteger;
022:        import java.text.ParseException;
023:        import org.apache.commons.beanutils.ConversionException;
024:
025:        /**
026:         * <p>Standard {@link org.apache.commons.beanutils.locale.LocaleConverter} 
027:         * implementation that converts an incoming
028:         * locale-sensitive String into a <code>java.math.BigInteger</code> object,
029:         * optionally using a default value or throwing a 
030:         * {@link org.apache.commons.beanutils.ConversionException}
031:         * if a conversion error occurs.</p>
032:         *
033:         * @author Yauheny Mikulski
034:         */
035:
036:        public class BigIntegerLocaleConverter extends DecimalLocaleConverter {
037:
038:            // ----------------------------------------------------------- Constructors
039:
040:            /**
041:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
042:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
043:             * if a conversion error occurs. The locale is the default locale for
044:             * this instance of the Java Virtual Machine and an unlocalized pattern is used
045:             * for the convertion.
046:             *
047:             */
048:            public BigIntegerLocaleConverter() {
049:
050:                this (false);
051:            }
052:
053:            /**
054:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
055:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
056:             * if a conversion error occurs. The locale is the default locale for
057:             * this instance of the Java Virtual Machine.
058:             *
059:             * @param locPattern    Indicate whether the pattern is localized or not
060:             */
061:            public BigIntegerLocaleConverter(boolean locPattern) {
062:
063:                this (Locale.getDefault(), locPattern);
064:            }
065:
066:            /**
067:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
068:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
069:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
070:             *
071:             * @param locale        The locale
072:             */
073:            public BigIntegerLocaleConverter(Locale locale) {
074:
075:                this (locale, false);
076:            }
077:
078:            /**
079:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
080:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
081:             * if a conversion error occurs.
082:             *
083:             * @param locale        The locale
084:             * @param locPattern    Indicate whether the pattern is localized or not
085:             */
086:            public BigIntegerLocaleConverter(Locale locale, boolean locPattern) {
087:
088:                this (locale, (String) null, locPattern);
089:            }
090:
091:            /**
092:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
093:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
094:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
095:             *
096:             * @param locale        The locale
097:             * @param pattern       The convertion pattern
098:             */
099:            public BigIntegerLocaleConverter(Locale locale, String pattern) {
100:
101:                this (locale, pattern, false);
102:            }
103:
104:            /**
105:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
106:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
107:             * if a conversion error occurs.
108:             *
109:             * @param locale        The locale
110:             * @param pattern       The convertion pattern
111:             * @param locPattern    Indicate whether the pattern is localized or not
112:             */
113:            public BigIntegerLocaleConverter(Locale locale, String pattern,
114:                    boolean locPattern) {
115:
116:                super (locale, pattern, locPattern);
117:            }
118:
119:            /**
120:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
121:             * that will return the specified default value
122:             * if a conversion error occurs. The locale is the default locale for
123:             * this instance of the Java Virtual Machine and an unlocalized pattern is used
124:             * for the convertion.
125:             *
126:             * @param defaultValue  The default value to be returned
127:             */
128:            public BigIntegerLocaleConverter(Object defaultValue) {
129:
130:                this (defaultValue, false);
131:            }
132:
133:            /**
134:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
135:             * that will return the specified default value
136:             * if a conversion error occurs. The locale is the default locale for
137:             * this instance of the Java Virtual Machine.
138:             *
139:             * @param defaultValue  The default value to be returned
140:             * @param locPattern    Indicate whether the pattern is localized or not
141:             */
142:            public BigIntegerLocaleConverter(Object defaultValue,
143:                    boolean locPattern) {
144:
145:                this (defaultValue, Locale.getDefault(), locPattern);
146:            }
147:
148:            /**
149:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
150:             * that will return the specified default value
151:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
152:             *
153:             * @param defaultValue  The default value to be returned
154:             * @param locale        The locale
155:             */
156:            public BigIntegerLocaleConverter(Object defaultValue, Locale locale) {
157:
158:                this (defaultValue, locale, false);
159:            }
160:
161:            /**
162:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
163:             * that will return the specified default value
164:             * if a conversion error occurs.
165:             *
166:             * @param defaultValue  The default value to be returned
167:             * @param locale        The locale
168:             * @param locPattern    Indicate whether the pattern is localized or not
169:             */
170:            public BigIntegerLocaleConverter(Object defaultValue,
171:                    Locale locale, boolean locPattern) {
172:
173:                this (defaultValue, locale, null, locPattern);
174:            }
175:
176:            /**
177:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
178:             * that will return the specified default value
179:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
180:             *
181:             * @param defaultValue  The default value to be returned
182:             * @param locale        The locale
183:             * @param pattern       The convertion pattern
184:             */
185:            public BigIntegerLocaleConverter(Object defaultValue,
186:                    Locale locale, String pattern) {
187:
188:                this (defaultValue, locale, pattern, false);
189:            }
190:
191:            /**
192:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
193:             * that will return the specified default value
194:             * if a conversion error occurs.
195:             *
196:             * @param defaultValue  The default value to be returned
197:             * @param locale        The locale
198:             * @param pattern       The convertion pattern
199:             * @param locPattern    Indicate whether the pattern is localized or not
200:             */
201:            public BigIntegerLocaleConverter(Object defaultValue,
202:                    Locale locale, String pattern, boolean locPattern) {
203:
204:                super (defaultValue, locale, pattern, locPattern);
205:            }
206:
207:            /**
208:             * Convert the specified locale-sensitive input object into an output object of
209:             * BigInteger type.
210:             *
211:             * @param value The input object to be converted
212:             * @param pattern The pattern is used for the convertion
213:             * @return The converted value
214:             *
215:             * @exception ConversionException if conversion cannot be performed
216:             *  successfully
217:             * @throws ParseException if an error occurs parsing a String to a Number
218:             */
219:            protected Object parse(Object value, String pattern)
220:                    throws ParseException {
221:
222:                Object result = super .parse(value, pattern);
223:
224:                if (result == null || result instanceof  BigInteger) {
225:                    return result;
226:                }
227:
228:                if (result instanceof  Number) {
229:                    return BigInteger.valueOf(((Number) result).longValue());
230:                }
231:
232:                try {
233:                    return new BigInteger(result.toString());
234:                } catch (NumberFormatException ex) {
235:                    throw new ConversionException(
236:                            "Suplied number is not of type BigInteger: "
237:                                    + result);
238:                }
239:
240:            }
241:
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.