Source Code Cross Referenced for LocaleBeanUtils.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.beanutils.BeanUtils;
021:
022:        import java.lang.reflect.InvocationTargetException;
023:        import java.util.Locale;
024:
025:        /**
026:         * <p>Utility methods for populating JavaBeans properties
027:         * via reflection in a locale-dependent manner.</p>
028:         *
029:         * <p>The implementations for these methods are provided by <code>LocaleBeanUtilsBean</code>.
030:         * For more details see {@link LocaleBeanUtilsBean}.</p>
031:         *
032:         * @author Craig R. McClanahan
033:         * @author Ralph Schaer
034:         * @author Chris Audley
035:         * @author Rey Francois
036:         * @author Gregor Rayman
037:         * @author Yauheny Mikulski
038:         */
039:
040:        public class LocaleBeanUtils extends BeanUtils {
041:
042:            // ----------------------------------------------------- Instance Variables
043:
044:            /**
045:             * <p>Gets the locale used when no locale is passed.</p>
046:             *
047:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
048:             *
049:             * @return the default locale
050:             * @see LocaleBeanUtilsBean#getDefaultLocale()
051:             */
052:            public static Locale getDefaultLocale() {
053:
054:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
055:                        .getDefaultLocale();
056:            }
057:
058:            /**
059:             * <p>Sets the locale used when no locale is passed.</p>
060:             *
061:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
062:             *
063:             * @param locale the default locale
064:             * @see LocaleBeanUtilsBean#setDefaultLocale(Locale)
065:             */
066:            public static void setDefaultLocale(Locale locale) {
067:
068:                LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
069:                        .setDefaultLocale(locale);
070:            }
071:
072:            /**
073:             * <p>Gets whether the pattern is localized or not.</p>
074:             *
075:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
076:             *
077:             * @return <code>true</code> if pattern is localized,
078:             * otherwise <code>false</code>
079:             * @see LocaleBeanUtilsBean#getApplyLocalized()
080:             */
081:            public static boolean getApplyLocalized() {
082:
083:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
084:                        .getApplyLocalized();
085:            }
086:
087:            /**
088:             * <p>Sets whether the pattern is localized or not.</p>
089:             *
090:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
091:             *
092:             * @param newApplyLocalized <code>true</code> if pattern is localized,
093:             * otherwise <code>false</code>
094:             * @see LocaleBeanUtilsBean#setApplyLocalized(boolean)
095:             */
096:            public static void setApplyLocalized(boolean newApplyLocalized) {
097:
098:                LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
099:                        .setApplyLocalized(newApplyLocalized);
100:            }
101:
102:            // --------------------------------------------------------- Public Methods
103:
104:            /**
105:             * <p>Return the value of the specified locale-sensitive indexed property
106:             * of the specified bean, as a String.</p>
107:             *
108:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
109:             *
110:             * @param bean Bean whose property is to be extracted
111:             * @param name <code>propertyname[index]</code> of the property value
112:             *  to be extracted
113:             * @param pattern The conversion pattern
114:             * @return The indexed property's value, converted to a String
115:             *
116:             * @exception IllegalAccessException if the caller does not have
117:             *  access to the property accessor method
118:             * @exception InvocationTargetException if the property accessor method
119:             *  throws an exception
120:             * @exception NoSuchMethodException if an accessor method for this
121:             *  propety cannot be found
122:             *
123:             * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, String)
124:             */
125:            public static String getIndexedProperty(Object bean, String name,
126:                    String pattern) throws IllegalAccessException,
127:                    InvocationTargetException, NoSuchMethodException {
128:
129:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
130:                        .getIndexedProperty(bean, name, pattern);
131:            }
132:
133:            /**
134:             * Return the value of the specified locale-sensitive indexed property
135:             * of the specified bean, as a String using the default conversion pattern of
136:             * the corresponding {@link LocaleConverter}.
137:             *
138:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
139:             *
140:             * @param bean Bean whose property is to be extracted
141:             * @param name <code>propertyname[index]</code> of the property value
142:             *  to be extracted
143:             * @return The indexed property's value, converted to a String
144:             *
145:             * @exception IllegalAccessException if the caller does not have
146:             *  access to the property accessor method
147:             * @exception InvocationTargetException if the property accessor method
148:             *  throws an exception
149:             * @exception NoSuchMethodException if an accessor method for this
150:             *  propety cannot be found
151:             *
152:             * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String)
153:             */
154:            public static String getIndexedProperty(Object bean, String name)
155:                    throws IllegalAccessException, InvocationTargetException,
156:                    NoSuchMethodException {
157:
158:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
159:                        .getIndexedProperty(bean, name);
160:            }
161:
162:            /**
163:             * <p>Return the value of the specified locale-sensetive indexed property
164:             * of the specified bean, as a String using the specified conversion pattern.</p>
165:             *
166:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
167:             *
168:             * @param bean Bean whose property is to be extracted
169:             * @param name Simple property name of the property value to be extracted
170:             * @param index Index of the property value to be extracted
171:             * @param pattern The conversion pattern
172:             * @return The indexed property's value, converted to a String
173:             *
174:             * @exception IllegalAccessException if the caller does not have
175:             *  access to the property accessor method
176:             * @exception InvocationTargetException if the property accessor method
177:             *  throws an exception
178:             * @exception NoSuchMethodException if an accessor method for this
179:             *  propety cannot be found
180:             *
181:             * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int, String)
182:             */
183:            public static String getIndexedProperty(Object bean, String name,
184:                    int index, String pattern) throws IllegalAccessException,
185:                    InvocationTargetException, NoSuchMethodException {
186:
187:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
188:                        .getIndexedProperty(bean, name, index, pattern);
189:            }
190:
191:            /**
192:             * <p>Return the value of the specified locale-sensetive indexed property
193:             * of the specified bean, as a String using the default conversion pattern of
194:             * the corresponding {@link LocaleConverter}.</p>
195:             *
196:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
197:             *
198:             * @param bean Bean whose property is to be extracted
199:             * @param name Simple property name of the property value to be extracted
200:             * @param index Index of the property value to be extracted
201:             * @return The indexed property's value, converted to a String
202:             *
203:             * @exception IllegalAccessException if the caller does not have
204:             *  access to the property accessor method
205:             * @exception InvocationTargetException if the property accessor method
206:             *  throws an exception
207:             * @exception NoSuchMethodException if an accessor method for this
208:             *  propety cannot be found
209:             *
210:             * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int)
211:             */
212:            public static String getIndexedProperty(Object bean, String name,
213:                    int index) throws IllegalAccessException,
214:                    InvocationTargetException, NoSuchMethodException {
215:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
216:                        .getIndexedProperty(bean, name, index);
217:            }
218:
219:            /**
220:             * <p>Return the value of the specified simple locale-sensitive property
221:             * of the specified bean, converted to a String using the specified
222:             * conversion pattern.</p>
223:             *
224:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
225:             *
226:             * @param bean Bean whose property is to be extracted
227:             * @param name Name of the property to be extracted
228:             * @param pattern The conversion pattern
229:             * @return The property's value, converted to a String
230:             *
231:             * @exception IllegalAccessException if the caller does not have
232:             *  access to the property accessor method
233:             * @exception InvocationTargetException if the property accessor method
234:             *  throws an exception
235:             * @exception NoSuchMethodException if an accessor method for this
236:             *  propety cannot be found
237:             *
238:             * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String, String)
239:             */
240:            public static String getSimpleProperty(Object bean, String name,
241:                    String pattern) throws IllegalAccessException,
242:                    InvocationTargetException, NoSuchMethodException {
243:
244:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
245:                        .getSimpleProperty(bean, name, pattern);
246:            }
247:
248:            /**
249:             * <p>Return the value of the specified simple locale-sensitive property
250:             * of the specified bean, converted to a String using the default
251:             * conversion pattern of the corresponding {@link LocaleConverter}.</p>
252:             *
253:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
254:             *
255:             * @param bean Bean whose property is to be extracted
256:             * @param name Name of the property to be extracted
257:             * @return The property's value, converted to a String
258:             *
259:             * @exception IllegalAccessException if the caller does not have
260:             *  access to the property accessor method
261:             * @exception InvocationTargetException if the property accessor method
262:             *  throws an exception
263:             * @exception NoSuchMethodException if an accessor method for this
264:             *  propety cannot be found
265:             *
266:             * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String)
267:             */
268:            public static String getSimpleProperty(Object bean, String name)
269:                    throws IllegalAccessException, InvocationTargetException,
270:                    NoSuchMethodException {
271:
272:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
273:                        .getSimpleProperty(bean, name);
274:            }
275:
276:            /**
277:             * <p>Return the value of the specified mapped locale-sensitive property
278:             * of the specified bean, as a String using the specified conversion pattern.</p>
279:             *
280:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
281:             *
282:             * @param bean Bean whose property is to be extracted
283:             * @param name Simple property name of the property value to be extracted
284:             * @param key Lookup key of the property value to be extracted
285:             * @param pattern The conversion pattern
286:             * @return The mapped property's value, converted to a String
287:             *
288:             * @exception IllegalAccessException if the caller does not have
289:             *  access to the property accessor method
290:             * @exception InvocationTargetException if the property accessor method
291:             *  throws an exception
292:             * @exception NoSuchMethodException if an accessor method for this
293:             *  propety cannot be found
294:             *
295:             * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String, String)
296:             */
297:            public static String getMappedProperty(Object bean, String name,
298:                    String key, String pattern) throws IllegalAccessException,
299:                    InvocationTargetException, NoSuchMethodException {
300:
301:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
302:                        .getMappedProperty(bean, name, key, pattern);
303:            }
304:
305:            /**
306:             * <p>Return the value of the specified mapped locale-sensitive property
307:             * of the specified bean, as a String
308:             * The key is specified as a method parameter and must *not* be included
309:             * in the property name expression.</p>
310:             *
311:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
312:             *
313:             * @param bean Bean whose property is to be extracted
314:             * @param name Simple property name of the property value to be extracted
315:             * @param key Lookup key of the property value to be extracted
316:             * @return The mapped property's value, converted to a String
317:             *
318:             * @exception IllegalAccessException if the caller does not have
319:             *  access to the property accessor method
320:             * @exception InvocationTargetException if the property accessor method
321:             *  throws an exception
322:             * @exception NoSuchMethodException if an accessor method for this
323:             *  propety cannot be found
324:             *
325:             * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String)
326:             */
327:            public static String getMappedProperty(Object bean, String name,
328:                    String key) throws IllegalAccessException,
329:                    InvocationTargetException, NoSuchMethodException {
330:
331:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
332:                        .getMappedProperty(bean, name, key);
333:            }
334:
335:            /**
336:             * <p>Return the value of the specified locale-sensitive mapped property
337:             * of the specified bean, as a String using the specified pattern.</p>
338:             *
339:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
340:             *
341:             * @param bean Bean whose property is to be extracted
342:             * @param name <code>propertyname(index)</code> of the property value
343:             *  to be extracted
344:             * @param pattern The conversion pattern
345:             * @return The mapped property's value, converted to a String
346:             *
347:             * @exception IllegalAccessException if the caller does not have
348:             *  access to the property accessor method
349:             * @exception InvocationTargetException if the property accessor method
350:             *  throws an exception
351:             * @exception NoSuchMethodException if an accessor method for this
352:             *  propety cannot be found
353:             *
354:             * @see LocaleBeanUtilsBean#getMappedPropertyLocale(Object, String, String)
355:             */
356:            public static String getMappedPropertyLocale(Object bean,
357:                    String name, String pattern) throws IllegalAccessException,
358:                    InvocationTargetException, NoSuchMethodException {
359:
360:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
361:                        .getMappedPropertyLocale(bean, name, pattern);
362:            }
363:
364:            /**
365:             * <p>Return the value of the specified locale-sensitive mapped property
366:             * of the specified bean, as a String using the default
367:             * conversion pattern of the corresponding {@link LocaleConverter}.</p>
368:             *
369:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
370:             *
371:             * @param bean Bean whose property is to be extracted
372:             * @param name <code>propertyname(index)</code> of the property value
373:             *  to be extracted
374:             * @return The mapped property's value, converted to a String
375:             *
376:             * @exception IllegalAccessException if the caller does not have
377:             *  access to the property accessor method
378:             * @exception InvocationTargetException if the property accessor method
379:             *  throws an exception
380:             * @exception NoSuchMethodException if an accessor method for this
381:             *  propety cannot be found
382:             *
383:             * @see LocaleBeanUtilsBean#getMappedProperty(Object, String)
384:             */
385:            public static String getMappedProperty(Object bean, String name)
386:                    throws IllegalAccessException, InvocationTargetException,
387:                    NoSuchMethodException {
388:
389:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
390:                        .getMappedProperty(bean, name);
391:            }
392:
393:            /**
394:             * <p>Return the value of the (possibly nested) locale-sensitive property
395:             * of the specified name, for the specified bean,
396:             * as a String using the specified pattern.</p>
397:             *
398:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
399:             *
400:             * @param bean Bean whose property is to be extracted
401:             * @param name Possibly nested name of the property to be extracted
402:             * @param pattern The conversion pattern
403:             * @return The nested property's value, converted to a String
404:             *
405:             * @exception IllegalAccessException if the caller does not have
406:             *  access to the property accessor method
407:             * @exception InvocationTargetException if the property accessor method
408:             *  throws an exception
409:             * @exception NoSuchMethodException if an accessor method for this
410:             *  propety cannot be found
411:             *
412:             * @see LocaleBeanUtilsBean#getNestedProperty(Object, String, String)
413:             */
414:            public static String getNestedProperty(Object bean, String name,
415:                    String pattern) throws IllegalAccessException,
416:                    InvocationTargetException, NoSuchMethodException {
417:
418:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
419:                        .getNestedProperty(bean, name, pattern);
420:            }
421:
422:            /**
423:             * <p>Return the value of the (possibly nested) locale-sensitive property
424:             * of the specified name.</p>
425:             *
426:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
427:             *
428:             * @param bean Bean whose property is to be extracted
429:             * @param name Possibly nested name of the property to be extracted
430:             * @return The nested property's value, converted to a String
431:             *
432:             * @exception IllegalAccessException if the caller does not have
433:             *  access to the property accessor method
434:             * @exception InvocationTargetException if the property accessor method
435:             *  throws an exception
436:             * @exception NoSuchMethodException if an accessor method for this
437:             *  propety cannot be found
438:             *
439:             * @see LocaleBeanUtilsBean#getNestedProperty(Object, String)
440:             */
441:            public static String getNestedProperty(Object bean, String name)
442:                    throws IllegalAccessException, InvocationTargetException,
443:                    NoSuchMethodException {
444:
445:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
446:                        .getNestedProperty(bean, name);
447:            }
448:
449:            /**
450:             * <p>Return the value of the specified locale-sensitive property
451:             * of the specified bean.</p>
452:             *
453:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
454:             *
455:             * @param bean Bean whose property is to be extracted
456:             * @param name Possibly indexed and/or nested name of the property
457:             *  to be extracted
458:             * @param pattern The conversion pattern
459:             * @return The nested property's value, converted to a String
460:             *
461:             * @exception IllegalAccessException if the caller does not have
462:             *  access to the property accessor method
463:             * @exception InvocationTargetException if the property accessor method
464:             *  throws an exception
465:             * @exception NoSuchMethodException if an accessor method for this
466:             *  propety cannot be found
467:             *
468:             * @see LocaleBeanUtilsBean#getProperty(Object, String, String)
469:             */
470:            public static String getProperty(Object bean, String name,
471:                    String pattern) throws IllegalAccessException,
472:                    InvocationTargetException, NoSuchMethodException {
473:
474:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
475:                        .getProperty(bean, name, pattern);
476:            }
477:
478:            /**
479:             * <p>Return the value of the specified locale-sensitive property
480:             * of the specified bean.</p>
481:             *
482:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
483:             *
484:             * @param bean Bean whose property is to be extracted
485:             * @param name Possibly indexed and/or nested name of the property
486:             *  to be extracted
487:             * @return The property's value, converted to a String
488:             *
489:             * @exception IllegalAccessException if the caller does not have
490:             *  access to the property accessor method
491:             * @exception InvocationTargetException if the property accessor method
492:             *  throws an exception
493:             * @exception NoSuchMethodException if an accessor method for this
494:             *  propety cannot be found
495:             *
496:             * @see LocaleBeanUtilsBean#getProperty(Object, String)
497:             */
498:            public static String getProperty(Object bean, String name)
499:                    throws IllegalAccessException, InvocationTargetException,
500:                    NoSuchMethodException {
501:
502:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
503:                        .getProperty(bean, name);
504:            }
505:
506:            /**
507:             * <p>Set the specified locale-sensitive property value, performing type
508:             * conversions as required to conform to the type of the destination property
509:             * using the default conversion pattern of the corresponding {@link LocaleConverter}.</p>
510:             *
511:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
512:             *
513:             * @param bean Bean on which setting is to be performed
514:             * @param name Property name (can be nested/indexed/mapped/combo)
515:             * @param value Value to be set
516:             *
517:             * @exception IllegalAccessException if the caller does not have
518:             *  access to the property accessor method
519:             * @exception InvocationTargetException if the property accessor method
520:             *  throws an exception
521:             *
522:             * @see LocaleBeanUtilsBean#setProperty(Object, String, Object)
523:             */
524:            public static void setProperty(Object bean, String name,
525:                    Object value) throws IllegalAccessException,
526:                    InvocationTargetException {
527:
528:                LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(
529:                        bean, name, value);
530:            }
531:
532:            /**
533:             * <p>Set the specified locale-sensitive property value, performing type
534:             * conversions as required to conform to the type of the destination
535:             * property using the specified conversion pattern.</p>
536:             *
537:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
538:             *
539:             * @param bean Bean on which setting is to be performed
540:             * @param name Property name (can be nested/indexed/mapped/combo)
541:             * @param value Value to be set
542:             * @param pattern The conversion pattern
543:             *
544:             * @exception IllegalAccessException if the caller does not have
545:             *  access to the property accessor method
546:             * @exception InvocationTargetException if the property accessor method
547:             *  throws an exception
548:             *
549:             * @see LocaleBeanUtilsBean#setProperty(Object, String, Object, String)
550:             */
551:            public static void setProperty(Object bean, String name,
552:                    Object value, String pattern)
553:                    throws IllegalAccessException, InvocationTargetException {
554:
555:                LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(
556:                        bean, name, value, pattern);
557:            }
558:
559:            /**
560:             * <p>Calculate the property type.</p>
561:             *
562:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
563:             *
564:             * @param target The bean
565:             * @param name The property name
566:             * @param propName The Simple name of target property
567:             * @return The property's type
568:             *
569:             * @exception IllegalAccessException if the caller does not have
570:             *  access to the property accessor method
571:             * @exception InvocationTargetException if the property accessor method
572:             *  throws an exception
573:             *
574:             * @see LocaleBeanUtilsBean#definePropertyType(Object, String, String)
575:             */
576:            protected static Class definePropertyType(Object target,
577:                    String name, String propName)
578:                    throws IllegalAccessException, InvocationTargetException {
579:
580:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
581:                        .definePropertyType(target, name, propName);
582:            }
583:
584:            /**
585:             * <p>Convert the specified value to the required type using the
586:             * specified conversion pattern.</p>
587:             *
588:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
589:             *
590:             * @param type The Java type of target property
591:             * @param index The indexed subscript value (if any)
592:             * @param value The value to be converted
593:             * @param pattern The conversion pattern
594:             * @return The converted value
595:             * @see LocaleBeanUtilsBean#convert(Class, int, Object, String)
596:             */
597:            protected static Object convert(Class type, int index,
598:                    Object value, String pattern) {
599:
600:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
601:                        .convert(type, index, value, pattern);
602:            }
603:
604:            /**
605:             * <p>Convert the specified value to the required type.</p>
606:             *
607:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
608:             *
609:             * @param type The Java type of target property
610:             * @param index The indexed subscript value (if any)
611:             * @param value The value to be converted
612:             * @return The converted value
613:             * @see LocaleBeanUtilsBean#convert(Class, int, Object)
614:             */
615:            protected static Object convert(Class type, int index, Object value) {
616:
617:                return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance()
618:                        .convert(type, index, value);
619:            }
620:
621:            /**
622:             * <p>Invoke the setter method.</p>
623:             *
624:             * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
625:             *
626:             * @param target The bean
627:             * @param propName The Simple name of target property
628:             * @param key The Mapped key value (if any)
629:             * @param index The indexed subscript value (if any)
630:             * @param newValue The value to be set
631:             *
632:             * @exception IllegalAccessException if the caller does not have
633:             *  access to the property accessor method
634:             * @exception InvocationTargetException if the property accessor method
635:             *  throws an exception
636:             *
637:             * @see LocaleBeanUtilsBean#invokeSetter(Object, String, String, int, Object)
638:             */
639:            protected static void invokeSetter(Object target, String propName,
640:                    String key, int index, Object newValue)
641:                    throws IllegalAccessException, InvocationTargetException {
642:
643:                LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().invokeSetter(
644:                        target, propName, key, index, newValue);
645:            }
646:
647:            /**
648:             * Resolve any nested expression to get the actual target bean.
649:             *
650:             * @deprecated moved into <code>LocaleBeanUtilsBean</code>
651:             * @param bean The bean
652:             * @param name The property name
653:             * @return The property's descriptor
654:             *
655:             * @exception IllegalAccessException if the caller does not have
656:             *  access to the property accessor method
657:             * @exception InvocationTargetException if the property accessor method
658:             *  throws an exception
659:             */
660:            protected static Descriptor calculate(Object bean, String name)
661:                    throws IllegalAccessException, InvocationTargetException {
662:
663:                org.apache.commons.beanutils.locale.LocaleBeanUtilsBean.Descriptor descriptor = LocaleBeanUtilsBean
664:                        .getLocaleBeanUtilsInstance().calculate(bean, name);
665:                return new Descriptor(descriptor.getTarget(), descriptor
666:                        .getName(), descriptor.getPropName(), descriptor
667:                        .getKey(), descriptor.getIndex());
668:            }
669:
670:            /** @deprecated moved into <code>LocaleBeanUtils</code> */
671:            protected static class Descriptor {
672:
673:                private int index = -1; // Indexed subscript value (if any)
674:                private String name;
675:                private String propName; // Simple name of target property
676:                private String key; // Mapped key value (if any)
677:                private Object target;
678:
679:                /**
680:                 * Construct a descriptor instance for the target bean and property.
681:                 *
682:                 * @param target The target bean
683:                 * @param name The property name (includes indexed/mapped expr)
684:                 * @param propName The property name
685:                 * @param key The mapped property key (if any)
686:                 * @param index The indexed property index (if any)
687:                 */
688:                public Descriptor(Object target, String name, String propName,
689:                        String key, int index) {
690:
691:                    setTarget(target);
692:                    setName(name);
693:                    setPropName(propName);
694:                    setKey(key);
695:                    setIndex(index);
696:                }
697:
698:                /**
699:                 * Return the target bean.
700:                 *
701:                 * @return The descriptors target bean
702:                 */
703:                public Object getTarget() {
704:                    return target;
705:                }
706:
707:                /**
708:                 * Set the target bean.
709:                 *
710:                 * @param target The target bean
711:                 */
712:                public void setTarget(Object target) {
713:                    this .target = target;
714:                }
715:
716:                /**
717:                 * Return the mapped property key.
718:                 *
719:                 * @return the mapped property key (if any)
720:                 */
721:                public String getKey() {
722:                    return key;
723:                }
724:
725:                /**
726:                 * Set the mapped property key.
727:                 *
728:                 * @param key The mapped property key (if any)
729:                 */
730:                public void setKey(String key) {
731:                    this .key = key;
732:                }
733:
734:                /**
735:                 * Return indexed property index.
736:                 *
737:                 * @return indexed property index (if any)
738:                 */
739:                public int getIndex() {
740:                    return index;
741:                }
742:
743:                /**
744:                 * Set the indexed property index.
745:                 *
746:                 * @param index The indexed property index (if any)
747:                 */
748:                public void setIndex(int index) {
749:                    this .index = index;
750:                }
751:
752:                /**
753:                 * Return property name (includes indexed/mapped expr).
754:                 *
755:                 * @return The property name (includes indexed/mapped expr)
756:                 */
757:                public String getName() {
758:                    return name;
759:                }
760:
761:                /**
762:                 * Set the property name (includes indexed/mapped expr).
763:                 *
764:                 * @param name The property name (includes indexed/mapped expr)
765:                 */
766:                public void setName(String name) {
767:                    this .name = name;
768:                }
769:
770:                /**
771:                 * Return the property name.
772:                 *
773:                 * @return The property name
774:                 */
775:                public String getPropName() {
776:                    return propName;
777:                }
778:
779:                /**
780:                 * Set the property name.
781:                 *
782:                 * @param propName The property name
783:                 */
784:                public void setPropName(String propName) {
785:                    this.propName = propName;
786:                }
787:            }
788:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.