Source Code Cross Referenced for LongLocaleConverter.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.text.ParseException;
022:
023:        /**
024:         * <p>Standard {@link org.apache.commons.beanutils.locale.LocaleConverter} 
025:         * implementation that converts an incoming
026:         * locale-sensitive String into a <code>java.lang.Long</code> object,
027:         * optionally using a default value or throwing a 
028:         * {@link org.apache.commons.beanutils.ConversionException}
029:         * if a conversion error occurs.</p>
030:         *
031:         * @author Yauheny Mikulski
032:         */
033:
034:        public class LongLocaleConverter extends DecimalLocaleConverter {
035:
036:            // ----------------------------------------------------------- Constructors
037:
038:            /**
039:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
040:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
041:             * if a conversion error occurs. The locale is the default locale for
042:             * this instance of the Java Virtual Machine and an unlocalized pattern is used
043:             * for the convertion.
044:             *
045:             */
046:            public LongLocaleConverter() {
047:
048:                this (false);
049:            }
050:
051:            /**
052:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
053:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
054:             * if a conversion error occurs. The locale is the default locale for
055:             * this instance of the Java Virtual Machine.
056:             *
057:             * @param locPattern    Indicate whether the pattern is localized or not
058:             */
059:            public LongLocaleConverter(boolean locPattern) {
060:
061:                this (Locale.getDefault(), locPattern);
062:            }
063:
064:            /**
065:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
066:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
067:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
068:             *
069:             * @param locale        The locale
070:             */
071:            public LongLocaleConverter(Locale locale) {
072:
073:                this (locale, false);
074:            }
075:
076:            /**
077:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
078:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
079:             * if a conversion error occurs.
080:             *
081:             * @param locale        The locale
082:             * @param locPattern    Indicate whether the pattern is localized or not
083:             */
084:            public LongLocaleConverter(Locale locale, boolean locPattern) {
085:
086:                this (locale, (String) null, locPattern);
087:            }
088:
089:            /**
090:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
091:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
092:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
093:             *
094:             * @param locale        The locale
095:             * @param pattern       The convertion pattern
096:             */
097:            public LongLocaleConverter(Locale locale, String pattern) {
098:
099:                this (locale, pattern, false);
100:            }
101:
102:            /**
103:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
104:             * that will throw a {@link org.apache.commons.beanutils.ConversionException}
105:             * if a conversion error occurs.
106:             *
107:             * @param locale        The locale
108:             * @param pattern       The convertion pattern
109:             * @param locPattern    Indicate whether the pattern is localized or not
110:             */
111:            public LongLocaleConverter(Locale locale, String pattern,
112:                    boolean locPattern) {
113:
114:                super (locale, pattern, locPattern);
115:            }
116:
117:            /**
118:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
119:             * that will return the specified default value
120:             * if a conversion error occurs. The locale is the default locale for
121:             * this instance of the Java Virtual Machine and an unlocalized pattern is used
122:             * for the convertion.
123:             *
124:             * @param defaultValue  The default value to be returned
125:             */
126:            public LongLocaleConverter(Object defaultValue) {
127:
128:                this (defaultValue, false);
129:            }
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. The locale is the default locale for
135:             * this instance of the Java Virtual Machine.
136:             *
137:             * @param defaultValue  The default value to be returned
138:             * @param locPattern    Indicate whether the pattern is localized or not
139:             */
140:            public LongLocaleConverter(Object defaultValue, boolean locPattern) {
141:
142:                this (defaultValue, Locale.getDefault(), locPattern);
143:            }
144:
145:            /**
146:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
147:             * that will return the specified default value
148:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
149:             *
150:             * @param defaultValue  The default value to be returned
151:             * @param locale        The locale
152:             */
153:            public LongLocaleConverter(Object defaultValue, Locale locale) {
154:
155:                this (defaultValue, locale, false);
156:            }
157:
158:            /**
159:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
160:             * that will return the specified default value
161:             * if a conversion error occurs.
162:             *
163:             * @param defaultValue  The default value to be returned
164:             * @param locale        The locale
165:             * @param locPattern    Indicate whether the pattern is localized or not
166:             */
167:            public LongLocaleConverter(Object defaultValue, Locale locale,
168:                    boolean locPattern) {
169:
170:                this (defaultValue, locale, null, locPattern);
171:            }
172:
173:            /**
174:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
175:             * that will return the specified default value
176:             * if a conversion error occurs. An unlocalized pattern is used for the convertion.
177:             *
178:             * @param defaultValue  The default value to be returned
179:             * @param locale        The locale
180:             * @param pattern       The convertion pattern
181:             */
182:            public LongLocaleConverter(Object defaultValue, Locale locale,
183:                    String pattern) {
184:
185:                this (defaultValue, locale, pattern, false);
186:            }
187:
188:            /**
189:             * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
190:             * that will return the specified default value
191:             * if a conversion error occurs.
192:             *
193:             * @param defaultValue  The default value to be returned
194:             * @param locale        The locale
195:             * @param pattern       The convertion pattern
196:             * @param locPattern    Indicate whether the pattern is localized or not
197:             */
198:            public LongLocaleConverter(Object defaultValue, Locale locale,
199:                    String pattern, boolean locPattern) {
200:
201:                super (defaultValue, locale, pattern, locPattern);
202:            }
203:
204:            /**
205:             * Convert the specified locale-sensitive input object into an output object of the
206:             * specified type. This method will return a Long type.
207:             *
208:             * @param value The input object to be converted
209:             * @param pattern The pattern is used for the convertion
210:             * @return The converted value
211:             *
212:             * @exception org.apache.commons.beanutils.ConversionException if conversion
213:             * cannot be performed successfully
214:             * @throws ParseException if an error occurs parsing a String to a Number
215:             */
216:            protected Object parse(Object value, String pattern)
217:                    throws ParseException {
218:
219:                Object result = super .parse(value, pattern);
220:
221:                if (result == null || result instanceof  Long) {
222:                    return result;
223:                }
224:
225:                return new Long(((Number) result).longValue());
226:
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.