Source Code Cross Referenced for PropertyUtils.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » 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 
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;
019:
020:        import java.beans.PropertyDescriptor;
021:        import java.lang.reflect.InvocationTargetException;
022:        import java.lang.reflect.Method;
023:        import java.util.Map;
024:
025:        import org.apache.commons.collections.FastHashMap;
026:
027:        /**
028:         * <p>Utility methods for using Java Reflection APIs to facilitate generic
029:         * property getter and setter operations on Java objects.</p>
030:         *
031:         * <p>The implementations for these methods are provided by <code>PropertyUtilsBean</code>.
032:         * For more details see {@link PropertyUtilsBean}.</p>
033:         *
034:         * @author Craig R. McClanahan
035:         * @author Ralph Schaer
036:         * @author Chris Audley
037:         * @author Rey Francois
038:         * @author Gregor Rayman
039:         * @author Jan Sorensen
040:         * @author Scott Sanders
041:         * @version $Revision: 555845 $ $Date: 2007-07-13 03:52:05 +0100 (Fri, 13 Jul 2007) $
042:         * @see PropertyUtilsBean
043:         * @see org.apache.commons.beanutils.expression.Resolver
044:         */
045:
046:        public class PropertyUtils {
047:
048:            // ----------------------------------------------------- Manifest Constants
049:
050:            /**
051:             * The delimiter that preceeds the zero-relative subscript for an
052:             * indexed reference.
053:             *
054:             * @deprecated The notation used for property name expressions is now
055:             * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
056:             * implementation being used.
057:             */
058:            public static final char INDEXED_DELIM = '[';
059:
060:            /**
061:             * The delimiter that follows the zero-relative subscript for an
062:             * indexed reference.
063:             *
064:             * @deprecated The notation used for property name expressions is now
065:             * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
066:             * implementation being used.
067:             */
068:            public static final char INDEXED_DELIM2 = ']';
069:
070:            /**
071:             * The delimiter that preceeds the key of a mapped property.
072:             *
073:             * @deprecated The notation used for property name expressions is now
074:             * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
075:             * implementation being used.
076:             */
077:            public static final char MAPPED_DELIM = '(';
078:
079:            /**
080:             * The delimiter that follows the key of a mapped property.
081:             *
082:             * @deprecated The notation used for property name expressions is now
083:             * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
084:             * implementation being used.
085:             */
086:            public static final char MAPPED_DELIM2 = ')';
087:
088:            /**
089:             * The delimiter that separates the components of a nested reference.
090:             *
091:             * @deprecated The notation used for property name expressions is now
092:             * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
093:             * implementation being used.
094:             */
095:            public static final char NESTED_DELIM = '.';
096:
097:            // ------------------------------------------------------- Static Variables
098:
099:            /**
100:             * The debugging detail level for this component.
101:             * 
102:             * Note that this static variable will have unexpected side-effects if
103:             * this class is deployed in a shared classloader within a container.
104:             * However as it is actually completely ignored by this class due to its
105:             * deprecated status, it doesn't do any actual harm.
106:             *
107:             * @deprecated The <code>debug</code> static property is no longer used
108:             */
109:            private static int debug = 0;
110:
111:            /**
112:             * The <code>debug</code> static property is no longer used
113:             * @return debug property
114:             * @deprecated The <code>debug</code> static property is no longer used
115:             */
116:            public static int getDebug() {
117:                return (debug);
118:            }
119:
120:            /**
121:             * The <code>debug</code> static property is no longer used
122:             * @param newDebug debug property
123:             * @deprecated The <code>debug</code> static property is no longer used
124:             */
125:            public static void setDebug(int newDebug) {
126:                debug = newDebug;
127:            }
128:
129:            // --------------------------------------------------------- Public Methods
130:
131:            /**
132:             * Clear any cached property descriptors information for all classes
133:             * loaded by any class loaders.  This is useful in cases where class
134:             * loaders are thrown away to implement class reloading.
135:             *
136:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
137:             *
138:             * @see PropertyUtilsBean#clearDescriptors  
139:             */
140:            public static void clearDescriptors() {
141:
142:                PropertyUtilsBean.getInstance().clearDescriptors();
143:
144:            }
145:
146:            /**
147:             * <p>Copy property values from the "origin" bean to the "destination" bean
148:             * for all cases where the property names are the same (even though the
149:             * actual getter and setter methods might have been customized via
150:             * <code>BeanInfo</code> classes).</p>
151:             *
152:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
153:             *
154:             * @param dest Destination bean whose properties are modified
155:             * @param orig Origin bean whose properties are retrieved
156:             *
157:             * @exception IllegalAccessException if the caller does not have
158:             *  access to the property accessor method
159:             * @exception IllegalArgumentException if the <code>dest</code> or
160:             *  <code>orig</code> argument is null
161:             * @exception InvocationTargetException if the property accessor method
162:             *  throws an exception
163:             * @exception NoSuchMethodException if an accessor method for this
164:             *  propety cannot be found
165:             * @see PropertyUtilsBean#copyProperties  
166:             */
167:            public static void copyProperties(Object dest, Object orig)
168:                    throws IllegalAccessException, InvocationTargetException,
169:                    NoSuchMethodException {
170:
171:                PropertyUtilsBean.getInstance().copyProperties(dest, orig);
172:            }
173:
174:            /**
175:             * <p>Return the entire set of properties for which the specified bean
176:             * provides a read method.</p>
177:             *
178:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
179:             *
180:             * @param bean Bean whose properties are to be extracted
181:             * @return The set of properties for the bean
182:             *
183:             * @exception IllegalAccessException if the caller does not have
184:             *  access to the property accessor method
185:             * @exception IllegalArgumentException if <code>bean</code> is null
186:             * @exception InvocationTargetException if the property accessor method
187:             *  throws an exception
188:             * @exception NoSuchMethodException if an accessor method for this
189:             *  propety cannot be found
190:             * @see PropertyUtilsBean#describe  
191:             */
192:            public static Map describe(Object bean)
193:                    throws IllegalAccessException, InvocationTargetException,
194:                    NoSuchMethodException {
195:
196:                return (PropertyUtilsBean.getInstance().describe(bean));
197:
198:            }
199:
200:            /**
201:             * <p>Return the value of the specified indexed property of the specified
202:             * bean, with no type conversions.</p>
203:             *
204:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
205:             *
206:             * @param bean Bean whose property is to be extracted
207:             * @param name <code>propertyname[index]</code> of the property value
208:             *  to be extracted
209:             * @return the indexed property value
210:             *
211:             * @exception IndexOutOfBoundsException if the specified index
212:             *  is outside the valid range for the underlying property
213:             * @exception IllegalAccessException if the caller does not have
214:             *  access to the property accessor method
215:             * @exception IllegalArgumentException if <code>bean</code> or
216:             *  <code>name</code> is null
217:             * @exception InvocationTargetException if the property accessor method
218:             *  throws an exception
219:             * @exception NoSuchMethodException if an accessor method for this
220:             *  propety cannot be found
221:             * @see PropertyUtilsBean#getIndexedProperty(Object,String)  
222:             */
223:            public static Object getIndexedProperty(Object bean, String name)
224:                    throws IllegalAccessException, InvocationTargetException,
225:                    NoSuchMethodException {
226:
227:                return (PropertyUtilsBean.getInstance().getIndexedProperty(
228:                        bean, name));
229:
230:            }
231:
232:            /**
233:             * <p>Return the value of the specified indexed property of the specified
234:             * bean, with no type conversions.</p>
235:             *
236:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
237:             *
238:             * @param bean Bean whose property is to be extracted
239:             * @param name Simple property name of the property value to be extracted
240:             * @param index Index of the property value to be extracted
241:             * @return the indexed property value
242:             *
243:             * @exception IndexOutOfBoundsException if the specified index
244:             *  is outside the valid range for the underlying property
245:             * @exception IllegalAccessException if the caller does not have
246:             *  access to the property accessor method
247:             * @exception IllegalArgumentException if <code>bean</code> or
248:             *  <code>name</code> is null
249:             * @exception InvocationTargetException if the property accessor method
250:             *  throws an exception
251:             * @exception NoSuchMethodException if an accessor method for this
252:             *  propety cannot be found
253:             * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)  
254:             */
255:            public static Object getIndexedProperty(Object bean, String name,
256:                    int index) throws IllegalAccessException,
257:                    InvocationTargetException, NoSuchMethodException {
258:
259:                return (PropertyUtilsBean.getInstance().getIndexedProperty(
260:                        bean, name, index));
261:            }
262:
263:            /**
264:             * <p>Return the value of the specified mapped property of the
265:             * specified bean, with no type conversions.</p>
266:             *
267:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
268:             *
269:             * @param bean Bean whose property is to be extracted
270:             * @param name <code>propertyname(key)</code> of the property value
271:             *  to be extracted
272:             * @return the mapped property value
273:             *
274:             * @exception IllegalAccessException if the caller does not have
275:             *  access to the property accessor method
276:             * @exception InvocationTargetException if the property accessor method
277:             *  throws an exception
278:             * @exception NoSuchMethodException if an accessor method for this
279:             *  propety cannot be found
280:             * @see PropertyUtilsBean#getMappedProperty(Object,String)  
281:             */
282:            public static Object getMappedProperty(Object bean, String name)
283:                    throws IllegalAccessException, InvocationTargetException,
284:                    NoSuchMethodException {
285:
286:                return (PropertyUtilsBean.getInstance().getMappedProperty(bean,
287:                        name));
288:
289:            }
290:
291:            /**
292:             * <p>Return the value of the specified mapped property of the specified
293:             * bean, with no type conversions.</p>
294:             *
295:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
296:             *
297:             * @param bean Bean whose property is to be extracted
298:             * @param name Mapped property name of the property value to be extracted
299:             * @param key Key of the property value to be extracted
300:             * @return the mapped property value
301:             *
302:             * @exception IllegalAccessException if the caller does not have
303:             *  access to the property accessor method
304:             * @exception InvocationTargetException if the property accessor method
305:             *  throws an exception
306:             * @exception NoSuchMethodException if an accessor method for this
307:             *  propety cannot be found
308:             * @see PropertyUtilsBean#getMappedProperty(Object,String, String)  
309:             */
310:            public static Object getMappedProperty(Object bean, String name,
311:                    String key) throws IllegalAccessException,
312:                    InvocationTargetException, NoSuchMethodException {
313:
314:                return PropertyUtilsBean.getInstance().getMappedProperty(bean,
315:                        name, key);
316:
317:            }
318:
319:            /**
320:             * <p>Return the mapped property descriptors for this bean class.</p>
321:             *
322:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
323:             *
324:             * @param beanClass Bean class to be introspected
325:             * @return the mapped property descriptors
326:             * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class)
327:             * @deprecated This method should not be exposed
328:             */
329:            public static FastHashMap getMappedPropertyDescriptors(
330:                    Class beanClass) {
331:
332:                return PropertyUtilsBean.getInstance()
333:                        .getMappedPropertyDescriptors(beanClass);
334:
335:            }
336:
337:            /**
338:             * <p>Return the mapped property descriptors for this bean.</p>
339:             *
340:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
341:             *
342:             * @param bean Bean to be introspected
343:             * @return the mapped property descriptors
344:             * @see PropertyUtilsBean#getMappedPropertyDescriptors(Object)
345:             * @deprecated This method should not be exposed
346:             */
347:            public static FastHashMap getMappedPropertyDescriptors(Object bean) {
348:
349:                return PropertyUtilsBean.getInstance()
350:                        .getMappedPropertyDescriptors(bean);
351:
352:            }
353:
354:            /**
355:             * <p>Return the value of the (possibly nested) property of the specified
356:             * name, for the specified bean, with no type conversions.</p>
357:             *
358:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
359:             *
360:             * @param bean Bean whose property is to be extracted
361:             * @param name Possibly nested name of the property to be extracted
362:             * @return the nested property value
363:             *
364:             * @exception IllegalAccessException if the caller does not have
365:             *  access to the property accessor method
366:             * @exception IllegalArgumentException if <code>bean</code> or
367:             *  <code>name</code> is null
368:             * @exception NestedNullException if a nested reference to a
369:             *  property returns null
370:             * @exception InvocationTargetException 
371:             * if the property accessor method throws an exception
372:             * @exception NoSuchMethodException if an accessor method for this
373:             *  propety cannot be found
374:             * @see PropertyUtilsBean#getNestedProperty
375:             */
376:            public static Object getNestedProperty(Object bean, String name)
377:                    throws IllegalAccessException, InvocationTargetException,
378:                    NoSuchMethodException {
379:
380:                return PropertyUtilsBean.getInstance().getNestedProperty(bean,
381:                        name);
382:
383:            }
384:
385:            /**
386:             * <p>Return the value of the specified property of the specified bean,
387:             * no matter which property reference format is used, with no
388:             * type conversions.</p>
389:             *
390:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
391:             *
392:             * @param bean Bean whose property is to be extracted
393:             * @param name Possibly indexed and/or nested name of the property
394:             *  to be extracted
395:             * @return the property value
396:             *
397:             * @exception IllegalAccessException if the caller does not have
398:             *  access to the property accessor method
399:             * @exception IllegalArgumentException if <code>bean</code> or
400:             *  <code>name</code> is null
401:             * @exception InvocationTargetException if the property accessor method
402:             *  throws an exception
403:             * @exception NoSuchMethodException if an accessor method for this
404:             *  propety cannot be found
405:             * @see PropertyUtilsBean#getProperty
406:             */
407:            public static Object getProperty(Object bean, String name)
408:                    throws IllegalAccessException, InvocationTargetException,
409:                    NoSuchMethodException {
410:
411:                return (PropertyUtilsBean.getInstance().getProperty(bean, name));
412:
413:            }
414:
415:            /**
416:             * <p>Retrieve the property descriptor for the specified property of the
417:             * specified bean, or return <code>null</code> if there is no such
418:             * descriptor.</p>
419:             *
420:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
421:             *
422:             * @param bean Bean for which a property descriptor is requested
423:             * @param name Possibly indexed and/or nested name of the property for
424:             *  which a property descriptor is requested
425:             * @return the property descriptor
426:             *
427:             * @exception IllegalAccessException if the caller does not have
428:             *  access to the property accessor method
429:             * @exception IllegalArgumentException if <code>bean</code> or
430:             *  <code>name</code> is null
431:             * @exception IllegalArgumentException if a nested reference to a
432:             *  property returns null
433:             * @exception InvocationTargetException if the property accessor method
434:             *  throws an exception
435:             * @exception NoSuchMethodException if an accessor method for this
436:             *  propety cannot be found
437:             * @see PropertyUtilsBean#getPropertyDescriptor
438:             */
439:            public static PropertyDescriptor getPropertyDescriptor(Object bean,
440:                    String name) throws IllegalAccessException,
441:                    InvocationTargetException, NoSuchMethodException {
442:
443:                return PropertyUtilsBean.getInstance().getPropertyDescriptor(
444:                        bean, name);
445:
446:            }
447:
448:            /**
449:             * <p>Retrieve the property descriptors for the specified class,
450:             * introspecting and caching them the first time a particular bean class
451:             * is encountered.</p>
452:             *
453:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
454:             *
455:             * @param beanClass Bean class for which property descriptors are requested
456:             * @return the property descriptors
457:             * @exception IllegalArgumentException if <code>beanClass</code> is null
458:             * @see PropertyUtilsBean#getPropertyDescriptors(Class)
459:             */
460:            public static PropertyDescriptor[] getPropertyDescriptors(
461:                    Class beanClass) {
462:
463:                return PropertyUtilsBean.getInstance().getPropertyDescriptors(
464:                        beanClass);
465:
466:            }
467:
468:            /**
469:             * <p>Retrieve the property descriptors for the specified bean,
470:             * introspecting and caching them the first time a particular bean class
471:             * is encountered.</p>
472:             *
473:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
474:             *
475:             * @param bean Bean for which property descriptors are requested
476:             * @return the property descriptors
477:             * @exception IllegalArgumentException if <code>bean</code> is null
478:             * @see PropertyUtilsBean#getPropertyDescriptors(Object)
479:             */
480:            public static PropertyDescriptor[] getPropertyDescriptors(
481:                    Object bean) {
482:
483:                return PropertyUtilsBean.getInstance().getPropertyDescriptors(
484:                        bean);
485:
486:            }
487:
488:            /**
489:             * <p>Return the Java Class repesenting the property editor class that has
490:             * been registered for this property (if any).</p>
491:             *
492:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
493:             *
494:             * @param bean Bean for which a property descriptor is requested
495:             * @param name Possibly indexed and/or nested name of the property for
496:             *  which a property descriptor is requested
497:             * @return the property editor class
498:             *
499:             * @exception IllegalAccessException if the caller does not have
500:             *  access to the property accessor method
501:             * @exception IllegalArgumentException if <code>bean</code> or
502:             *  <code>name</code> is null
503:             * @exception IllegalArgumentException if a nested reference to a
504:             *  property returns null
505:             * @exception InvocationTargetException if the property accessor method
506:             *  throws an exception
507:             * @exception NoSuchMethodException if an accessor method for this
508:             *  propety cannot be found
509:             * @see PropertyUtilsBean#getPropertyEditorClass(Object,String)
510:             */
511:            public static Class getPropertyEditorClass(Object bean, String name)
512:                    throws IllegalAccessException, InvocationTargetException,
513:                    NoSuchMethodException {
514:
515:                return PropertyUtilsBean.getInstance().getPropertyEditorClass(
516:                        bean, name);
517:
518:            }
519:
520:            /**
521:             * <p>Return the Java Class representing the property type of the specified
522:             * property, or <code>null</code> if there is no such property for the
523:             * specified bean.</p>
524:             *
525:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
526:             *
527:             * @param bean Bean for which a property descriptor is requested
528:             * @param name Possibly indexed and/or nested name of the property for
529:             *  which a property descriptor is requested
530:             * @return The property type
531:             *
532:             * @exception IllegalAccessException if the caller does not have
533:             *  access to the property accessor method
534:             * @exception IllegalArgumentException if <code>bean</code> or
535:             *  <code>name</code> is null
536:             * @exception IllegalArgumentException if a nested reference to a
537:             *  property returns null
538:             * @exception InvocationTargetException if the property accessor method
539:             *  throws an exception
540:             * @exception NoSuchMethodException if an accessor method for this
541:             *  propety cannot be found
542:             * @see PropertyUtilsBean#getPropertyType(Object, String)
543:             */
544:            public static Class getPropertyType(Object bean, String name)
545:                    throws IllegalAccessException, InvocationTargetException,
546:                    NoSuchMethodException {
547:
548:                return PropertyUtilsBean.getInstance().getPropertyType(bean,
549:                        name);
550:            }
551:
552:            /**
553:             * <p>Return an accessible property getter method for this property,
554:             * if there is one; otherwise return <code>null</code>.</p>
555:             *
556:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
557:             *
558:             * @param descriptor Property descriptor to return a getter for
559:             * @return The read method
560:             * @see PropertyUtilsBean#getReadMethod
561:             */
562:            public static Method getReadMethod(PropertyDescriptor descriptor) {
563:
564:                return (PropertyUtilsBean.getInstance()
565:                        .getReadMethod(descriptor));
566:
567:            }
568:
569:            /**
570:             * <p>Return the value of the specified simple property of the specified
571:             * bean, with no type conversions.</p>
572:             *
573:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
574:             *
575:             * @param bean Bean whose property is to be extracted
576:             * @param name Name of the property to be extracted
577:             * @return The property value
578:             *
579:             * @exception IllegalAccessException if the caller does not have
580:             *  access to the property accessor method
581:             * @exception IllegalArgumentException if <code>bean</code> or
582:             *  <code>name</code> is null
583:             * @exception IllegalArgumentException if the property name
584:             *  is nested or indexed
585:             * @exception InvocationTargetException if the property accessor method
586:             *  throws an exception
587:             * @exception NoSuchMethodException if an accessor method for this
588:             *  propety cannot be found
589:             * @see PropertyUtilsBean#getSimpleProperty
590:             */
591:            public static Object getSimpleProperty(Object bean, String name)
592:                    throws IllegalAccessException, InvocationTargetException,
593:                    NoSuchMethodException {
594:
595:                return PropertyUtilsBean.getInstance().getSimpleProperty(bean,
596:                        name);
597:
598:            }
599:
600:            /**
601:             * <p>Return an accessible property setter method for this property,
602:             * if there is one; otherwise return <code>null</code>.</p>
603:             *
604:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
605:             *
606:             * @param descriptor Property descriptor to return a setter for
607:             * @return The write method
608:             * @see PropertyUtilsBean#getWriteMethod
609:             */
610:            public static Method getWriteMethod(PropertyDescriptor descriptor) {
611:
612:                return PropertyUtilsBean.getInstance().getWriteMethod(
613:                        descriptor);
614:
615:            }
616:
617:            /**
618:             * <p>Return <code>true</code> if the specified property name identifies
619:             * a readable property on the specified bean; otherwise, return
620:             * <code>false</code>.</p>
621:             *
622:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
623:             *
624:             * @param bean Bean to be examined (may be a {@link DynaBean}
625:             * @param name Property name to be evaluated
626:             * @return <code>true</code> if the property is readable,
627:             * otherwise <code>false</code>
628:             *
629:             * @exception IllegalArgumentException if <code>bean</code>
630:             *  or <code>name</code> is <code>null</code>
631:             * @see PropertyUtilsBean#isReadable
632:             * @since BeanUtils 1.6
633:             */
634:            public static boolean isReadable(Object bean, String name) {
635:
636:                return PropertyUtilsBean.getInstance().isReadable(bean, name);
637:            }
638:
639:            /**
640:             * <p>Return <code>true</code> if the specified property name identifies
641:             * a writeable property on the specified bean; otherwise, return
642:             * <code>false</code>.</p>
643:             *
644:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
645:             *
646:             * @param bean Bean to be examined (may be a {@link DynaBean}
647:             * @param name Property name to be evaluated
648:             * @return <code>true</code> if the property is writeable,
649:             * otherwise <code>false</code>
650:             *
651:             * @exception IllegalArgumentException if <code>bean</code>
652:             *  or <code>name</code> is <code>null</code>
653:             * @see PropertyUtilsBean#isWriteable
654:             * @since BeanUtils 1.6
655:             */
656:            public static boolean isWriteable(Object bean, String name) {
657:
658:                return PropertyUtilsBean.getInstance().isWriteable(bean, name);
659:            }
660:
661:            /**
662:             * <p>Sets the value of the specified indexed property of the specified
663:             * bean, with no type conversions.</p>
664:             *
665:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
666:             *
667:             * @param bean Bean whose property is to be modified
668:             * @param name <code>propertyname[index]</code> of the property value
669:             *  to be modified
670:             * @param value Value to which the specified property element
671:             *  should be set
672:             *
673:             * @exception IndexOutOfBoundsException if the specified index
674:             *  is outside the valid range for the underlying property
675:             * @exception IllegalAccessException if the caller does not have
676:             *  access to the property accessor method
677:             * @exception IllegalArgumentException if <code>bean</code> or
678:             *  <code>name</code> is null
679:             * @exception InvocationTargetException if the property accessor method
680:             *  throws an exception
681:             * @exception NoSuchMethodException if an accessor method for this
682:             *  propety cannot be found
683:             * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
684:             */
685:            public static void setIndexedProperty(Object bean, String name,
686:                    Object value) throws IllegalAccessException,
687:                    InvocationTargetException, NoSuchMethodException {
688:
689:                PropertyUtilsBean.getInstance().setIndexedProperty(bean, name,
690:                        value);
691:
692:            }
693:
694:            /**
695:             * <p>Sets the value of the specified indexed property of the specified
696:             * bean, with no type conversions.</p>
697:             *
698:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
699:             *
700:             * @param bean Bean whose property is to be set
701:             * @param name Simple property name of the property value to be set
702:             * @param index Index of the property value to be set
703:             * @param value Value to which the indexed property element is to be set
704:             *
705:             * @exception IndexOutOfBoundsException if the specified index
706:             *  is outside the valid range for the underlying property
707:             * @exception IllegalAccessException if the caller does not have
708:             *  access to the property accessor method
709:             * @exception IllegalArgumentException if <code>bean</code> or
710:             *  <code>name</code> is null
711:             * @exception InvocationTargetException if the property accessor method
712:             *  throws an exception
713:             * @exception NoSuchMethodException if an accessor method for this
714:             *  propety cannot be found
715:             * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
716:             */
717:            public static void setIndexedProperty(Object bean, String name,
718:                    int index, Object value) throws IllegalAccessException,
719:                    InvocationTargetException, NoSuchMethodException {
720:
721:                PropertyUtilsBean.getInstance().setIndexedProperty(bean, name,
722:                        index, value);
723:            }
724:
725:            /**
726:             * <p>Sets the value of the specified mapped property of the
727:             * specified bean, with no type conversions.</p>
728:             *
729:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
730:             *
731:             * @param bean Bean whose property is to be set
732:             * @param name <code>propertyname(key)</code> of the property value
733:             *  to be set
734:             * @param value The property value to be set
735:             *
736:             * @exception IllegalAccessException if the caller does not have
737:             *  access to the property accessor method
738:             * @exception InvocationTargetException if the property accessor method
739:             *  throws an exception
740:             * @exception NoSuchMethodException if an accessor method for this
741:             *  propety cannot be found
742:             * @see PropertyUtilsBean#setMappedProperty(Object, String, Object)
743:             */
744:            public static void setMappedProperty(Object bean, String name,
745:                    Object value) throws IllegalAccessException,
746:                    InvocationTargetException, NoSuchMethodException {
747:
748:                PropertyUtilsBean.getInstance().setMappedProperty(bean, name,
749:                        value);
750:            }
751:
752:            /**
753:             * <p>Sets the value of the specified mapped property of the specified
754:             * bean, with no type conversions.</p>
755:             *
756:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
757:             *
758:             * @param bean Bean whose property is to be set
759:             * @param name Mapped property name of the property value to be set
760:             * @param key Key of the property value to be set
761:             * @param value The property value to be set
762:             *
763:             * @exception IllegalAccessException if the caller does not have
764:             *  access to the property accessor method
765:             * @exception InvocationTargetException if the property accessor method
766:             *  throws an exception
767:             * @exception NoSuchMethodException if an accessor method for this
768:             *  propety cannot be found
769:             * @see PropertyUtilsBean#setMappedProperty(Object, String, String, Object)
770:             */
771:            public static void setMappedProperty(Object bean, String name,
772:                    String key, Object value) throws IllegalAccessException,
773:                    InvocationTargetException, NoSuchMethodException {
774:
775:                PropertyUtilsBean.getInstance().setMappedProperty(bean, name,
776:                        key, value);
777:            }
778:
779:            /**
780:             * <p>Sets the value of the (possibly nested) property of the specified
781:             * name, for the specified bean, with no type conversions.</p>
782:             *
783:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
784:             *
785:             * @param bean Bean whose property is to be modified
786:             * @param name Possibly nested name of the property to be modified
787:             * @param value Value to which the property is to be set
788:             *
789:             * @exception IllegalAccessException if the caller does not have
790:             *  access to the property accessor method
791:             * @exception IllegalArgumentException if <code>bean</code> or
792:             *  <code>name</code> is null
793:             * @exception IllegalArgumentException if a nested reference to a
794:             *  property returns null
795:             * @exception InvocationTargetException if the property accessor method
796:             *  throws an exception
797:             * @exception NoSuchMethodException if an accessor method for this
798:             *  propety cannot be found
799:             * @see PropertyUtilsBean#setNestedProperty
800:             */
801:            public static void setNestedProperty(Object bean, String name,
802:                    Object value) throws IllegalAccessException,
803:                    InvocationTargetException, NoSuchMethodException {
804:
805:                PropertyUtilsBean.getInstance().setNestedProperty(bean, name,
806:                        value);
807:            }
808:
809:            /**
810:             * <p>Set the value of the specified property of the specified bean,
811:             * no matter which property reference format is used, with no
812:             * type conversions.</p>
813:             *
814:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
815:             *
816:             * @param bean Bean whose property is to be modified
817:             * @param name Possibly indexed and/or nested name of the property
818:             *  to be modified
819:             * @param value Value to which this property is to be set
820:             *
821:             * @exception IllegalAccessException if the caller does not have
822:             *  access to the property accessor method
823:             * @exception IllegalArgumentException if <code>bean</code> or
824:             *  <code>name</code> is null
825:             * @exception InvocationTargetException if the property accessor method
826:             *  throws an exception
827:             * @exception NoSuchMethodException if an accessor method for this
828:             *  propety cannot be found
829:             * @see PropertyUtilsBean#setProperty
830:             */
831:            public static void setProperty(Object bean, String name,
832:                    Object value) throws IllegalAccessException,
833:                    InvocationTargetException, NoSuchMethodException {
834:
835:                PropertyUtilsBean.getInstance().setProperty(bean, name, value);
836:
837:            }
838:
839:            /**
840:             * <p>Set the value of the specified simple property of the specified bean,
841:             * with no type conversions.</p>
842:             *
843:             * <p>For more details see <code>PropertyUtilsBean</code>.</p>
844:             *
845:             * @param bean Bean whose property is to be modified
846:             * @param name Name of the property to be modified
847:             * @param value Value to which the property should be set
848:             *
849:             * @exception IllegalAccessException if the caller does not have
850:             *  access to the property accessor method
851:             * @exception IllegalArgumentException if <code>bean</code> or
852:             *  <code>name</code> is null
853:             * @exception IllegalArgumentException if the property name is
854:             *  nested or indexed
855:             * @exception InvocationTargetException if the property accessor method
856:             *  throws an exception
857:             * @exception NoSuchMethodException if an accessor method for this
858:             *  propety cannot be found
859:             * @see PropertyUtilsBean#setSimpleProperty
860:             */
861:            public static void setSimpleProperty(Object bean, String name,
862:                    Object value) throws IllegalAccessException,
863:                    InvocationTargetException, NoSuchMethodException {
864:
865:                PropertyUtilsBean.getInstance().setSimpleProperty(bean, name,
866:                        value);
867:            }
868:
869:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.