Source Code Cross Referenced for LocaleConvertUtils.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » locale » 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 
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;
019:
020:        import org.apache.commons.collections.FastHashMap;
021:
022:        import java.util.Locale;
023:
024:        /**
025:         * <p>Utility methods for converting locale-sensitive String scalar values to objects of the
026:         * specified Class, String arrays to arrays of the specified Class and
027:         * object to locale-sensitive String scalar value.</p>
028:         *
029:         * <p>The implementations for these method are provided by {@link LocaleConvertUtilsBean}.
030:         * These static utility method use the default instance. More sophisticated can be provided
031:         * by using a <code>LocaleConvertUtilsBean</code> instance.</p>
032:         *
033:         * @author Yauheny Mikulski
034:         */
035:        public class LocaleConvertUtils {
036:
037:            // ----------------------------------------------------- Instance Variables
038:
039:            /**
040:             * <p>Gets the <code>Locale</code> which will be used when 
041:             * no <code>Locale</code> is passed to a method.</p>
042:             * 
043:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
044:             * @return the default locale
045:             * @see LocaleConvertUtilsBean#getDefaultLocale()
046:             */
047:            public static Locale getDefaultLocale() {
048:
049:                return LocaleConvertUtilsBean.getInstance().getDefaultLocale();
050:            }
051:
052:            /**
053:             * <p>Sets the <code>Locale</code> which will be used when 
054:             * no <code>Locale</code> is passed to a method.</p>
055:             * 
056:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
057:             *
058:             * @param locale the default locale
059:             * @see LocaleConvertUtilsBean#setDefaultLocale(Locale)
060:             */
061:            public static void setDefaultLocale(Locale locale) {
062:
063:                LocaleConvertUtilsBean.getInstance().setDefaultLocale(locale);
064:            }
065:
066:            /**
067:             * <p>Gets applyLocalized.</p>
068:             * 
069:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
070:             *
071:             * @return <code>true</code> if pattern is localized,
072:             * otherwise <code>false</code>
073:             * @see LocaleConvertUtilsBean#getApplyLocalized()
074:             */
075:            public static boolean getApplyLocalized() {
076:                return LocaleConvertUtilsBean.getInstance().getApplyLocalized();
077:            }
078:
079:            /**
080:             * <p>Sets applyLocalized.</p>
081:             * 
082:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
083:             *
084:             * @param newApplyLocalized <code>true</code> if pattern is localized,
085:             * otherwise <code>false</code>
086:             * @see LocaleConvertUtilsBean#setApplyLocalized(boolean)
087:             */
088:            public static void setApplyLocalized(boolean newApplyLocalized) {
089:                LocaleConvertUtilsBean.getInstance().setApplyLocalized(
090:                        newApplyLocalized);
091:            }
092:
093:            // --------------------------------------------------------- Methods
094:
095:            /**
096:             * <p>Convert the specified locale-sensitive value into a String.</p>
097:             * 
098:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
099:             *
100:             * @param value The Value to be converted
101:             * @return the converted value
102:             * @see LocaleConvertUtilsBean#convert(Object)
103:             */
104:            public static String convert(Object value) {
105:                return LocaleConvertUtilsBean.getInstance().convert(value);
106:            }
107:
108:            /**
109:             * <p>Convert the specified locale-sensitive value into a String
110:             * using the conversion pattern.</p>
111:             * 
112:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
113:             *
114:             * @param value The Value to be converted
115:             * @param pattern       The convertion pattern
116:             * @return the converted value
117:             * @see LocaleConvertUtilsBean#convert(Object, String)
118:             */
119:            public static String convert(Object value, String pattern) {
120:                return LocaleConvertUtilsBean.getInstance().convert(value,
121:                        pattern);
122:            }
123:
124:            /**
125:             * <p>Convert the specified locale-sensitive value into a String
126:             * using the paticular convertion pattern.</p>
127:             * 
128:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
129:             *
130:             * @param value The Value to be converted
131:             * @param locale The locale
132:             * @param pattern The convertion pattern
133:             * @return the converted value
134:             * @see LocaleConvertUtilsBean#convert(Object, Locale, String)
135:             */
136:            public static String convert(Object value, Locale locale,
137:                    String pattern) {
138:
139:                return LocaleConvertUtilsBean.getInstance().convert(value,
140:                        locale, pattern);
141:            }
142:
143:            /**
144:             * <p>Convert the specified value to an object of the specified class (if
145:             * possible).  Otherwise, return a String representation of the value.</p>
146:             * 
147:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
148:             *
149:             * @param value The String scalar value to be converted
150:             * @param clazz The Data type to which this value should be converted.
151:             * @return the converted value
152:             * @see LocaleConvertUtilsBean#convert(String, Class)
153:             */
154:            public static Object convert(String value, Class clazz) {
155:
156:                return LocaleConvertUtilsBean.getInstance().convert(value,
157:                        clazz);
158:            }
159:
160:            /**
161:             * <p>Convert the specified value to an object of the specified class (if
162:             * possible) using the convertion pattern. Otherwise, return a String
163:             * representation of the value.</p>
164:             * 
165:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
166:             *
167:             * @param value The String scalar value to be converted
168:             * @param clazz The Data type to which this value should be converted.
169:             * @param pattern The convertion pattern
170:             * @return the converted value
171:             * @see LocaleConvertUtilsBean#convert(String, Class, String)
172:             */
173:            public static Object convert(String value, Class clazz,
174:                    String pattern) {
175:
176:                return LocaleConvertUtilsBean.getInstance().convert(value,
177:                        clazz, pattern);
178:            }
179:
180:            /**
181:             * <p>Convert the specified value to an object of the specified class (if
182:             * possible) using the convertion pattern. Otherwise, return a String
183:             * representation of the value.</p>
184:             *
185:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
186:             *
187:             * @param value The String scalar value to be converted
188:             * @param clazz The Data type to which this value should be converted.
189:             * @param locale The locale
190:             * @param pattern The convertion pattern
191:             * @return the converted value
192:             * @see LocaleConvertUtilsBean#convert(String, Class, Locale, String)
193:             */
194:            public static Object convert(String value, Class clazz,
195:                    Locale locale, String pattern) {
196:
197:                return LocaleConvertUtilsBean.getInstance().convert(value,
198:                        clazz, locale, pattern);
199:            }
200:
201:            /**
202:             * <p>Convert an array of specified values to an array of objects of the
203:             * specified class (if possible) using the convertion pattern.</p>
204:             * 
205:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
206:             *
207:             * @param values Value to be converted (may be null)
208:             * @param clazz Java array or element class to be converted to
209:             * @param pattern The convertion pattern
210:             * @return the converted value
211:             * @see LocaleConvertUtilsBean#convert(String[], Class, String)
212:             */
213:            public static Object convert(String[] values, Class clazz,
214:                    String pattern) {
215:
216:                return LocaleConvertUtilsBean.getInstance().convert(values,
217:                        clazz, pattern);
218:            }
219:
220:            /**
221:             * <p>Convert an array of specified values to an array of objects of the
222:             * specified class (if possible).</p>
223:             * 
224:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
225:             *
226:             * @param values Value to be converted (may be null)
227:             * @param clazz Java array or element class to be converted to
228:             * @return the converted value
229:             * @see LocaleConvertUtilsBean#convert(String[], Class)
230:             */
231:            public static Object convert(String[] values, Class clazz) {
232:
233:                return LocaleConvertUtilsBean.getInstance().convert(values,
234:                        clazz);
235:            }
236:
237:            /**
238:             * <p>Convert an array of specified values to an array of objects of the
239:             * specified class (if possible) using the convertion pattern.</p>
240:             *
241:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
242:             *
243:             * @param values Value to be converted (may be null)
244:             * @param clazz Java array or element class to be converted to
245:             * @param locale The locale
246:             * @param pattern The convertion pattern
247:             * @return the converted value
248:             * @see LocaleConvertUtilsBean#convert(String[], Class, Locale, String)
249:             */
250:            public static Object convert(String[] values, Class clazz,
251:                    Locale locale, String pattern) {
252:
253:                return LocaleConvertUtilsBean.getInstance().convert(values,
254:                        clazz, locale, pattern);
255:            }
256:
257:            /**
258:             * <p>Register a custom {@link LocaleConverter} for the specified destination
259:             * <code>Class</code>, replacing any previously registered converter.</p>
260:             * 
261:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
262:             *
263:             * @param converter The LocaleConverter to be registered
264:             * @param clazz The Destination class for conversions performed by this
265:             *  Converter
266:             * @param locale The locale
267:             * @see LocaleConvertUtilsBean#register(LocaleConverter, Class, Locale)
268:             */
269:            public static void register(LocaleConverter converter, Class clazz,
270:                    Locale locale) {
271:
272:                LocaleConvertUtilsBean.getInstance().register(converter, clazz,
273:                        locale);
274:            }
275:
276:            /**
277:             * <p>Remove any registered {@link LocaleConverter}.</p>
278:             * 
279:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
280:             *
281:             * @see LocaleConvertUtilsBean#deregister()
282:             */
283:            public static void deregister() {
284:
285:                LocaleConvertUtilsBean.getInstance().deregister();
286:            }
287:
288:            /**
289:             * <p>Remove any registered {@link LocaleConverter} for the specified locale.</p>
290:             * 
291:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
292:             *
293:             * @param locale The locale
294:             * @see LocaleConvertUtilsBean#deregister(Locale)
295:             */
296:            public static void deregister(Locale locale) {
297:
298:                LocaleConvertUtilsBean.getInstance().deregister(locale);
299:            }
300:
301:            /**
302:             * <p>Remove any registered {@link LocaleConverter} for the specified locale and Class.</p>
303:             * 
304:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
305:             *
306:             * @param clazz Class for which to remove a registered Converter
307:             * @param locale The locale
308:             * @see LocaleConvertUtilsBean#deregister(Class, Locale)
309:             */
310:            public static void deregister(Class clazz, Locale locale) {
311:
312:                LocaleConvertUtilsBean.getInstance().deregister(clazz, locale);
313:            }
314:
315:            /**
316:             * <p>Look up and return any registered {@link LocaleConverter} for the specified
317:             * destination class and locale; if there is no registered Converter, return
318:             * <code>null</code>.</p>
319:             * 
320:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
321:             *
322:             * @param clazz Class for which to return a registered Converter
323:             * @param locale The Locale
324:             * @return The registered locale Converter, if any
325:             * @see LocaleConvertUtilsBean#lookup(Class, Locale)
326:             */
327:            public static LocaleConverter lookup(Class clazz, Locale locale) {
328:
329:                return LocaleConvertUtilsBean.getInstance().lookup(clazz,
330:                        locale);
331:            }
332:
333:            /**
334:             * <p>Look up and return any registered FastHashMap instance for the specified locale.</p>
335:             * 
336:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
337:             *
338:             * @param locale The Locale
339:             * @return The FastHashMap instance contains the all {@link LocaleConverter} types for
340:             *  the specified locale.
341:             * @see LocaleConvertUtilsBean#lookup(Locale)
342:             * @deprecated This method will be modified to return a Map in the next release.
343:             */
344:            protected static FastHashMap lookup(Locale locale) {
345:                return LocaleConvertUtilsBean.getInstance().lookup(locale);
346:            }
347:
348:            /**
349:             * <p>Create all {@link LocaleConverter} types for specified locale.</p>
350:             * 
351:             * <p>For more details see <code>LocaleConvertUtilsBean</code></p>
352:             *
353:             * @param locale The Locale
354:             * @return The FastHashMap instance contains the all {@link LocaleConverter} types
355:             *  for the specified locale.
356:             * @see LocaleConvertUtilsBean#create(Locale)
357:             * @deprecated This method will be modified to return a Map in the next release.
358:             */
359:            protected static FastHashMap create(Locale locale) {
360:
361:                return LocaleConvertUtilsBean.getInstance().create(locale);
362:            }
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.