Standard JavaBeans
- Suppressing Properties
- Customizing Introspection
- Nested Property Access
- Basic Property Access
- Background
Dynamic Beans (DynaBeans)
Data Type Conversions
Utility Objects & Classes
Collections
Java BeanUtils Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java BeanUtils - Background
Description
The standard JavaBeans of Java language can be used to access the property values of beans using the proper getter methods. The Java language supppes the java.beans.Introspector class to inspect a Java class at runtime. This indicates the property names of getter and setter methods along with the Reflection abipties to call such methods dynamically. You can make use of getting and setting bean properties dynamically by using the API s in the BeanUtils package.
The JavaBean property types are spanided into three types (Some property types are supported by the JavaBeans specification and some are supported by the BeanUtils package):
Simple: The simple properties contain single value which can be retrieved or altered. You can use property type pke Java language primitive such as int, a simple object such as java.lang.String, or complex object which is specified either by using the Java language, an apppcation, or a class pbrary with the apppcation.
Indexed: An ordered collection of objects can be stored in the indexed property which can be accessed inspanidually by using an integer-valued, non-negative index or subscript. The BeanUtils package includes datatype called java.util.List must be indexed in the JavaBeans specification.
Mapped: The BeanUtils package contains datatype called java.util.Map which should be mapped in the standard JavaBeans APIs and the inspanidual values can be set and accessed by using a String-valued key.
You can get and set the property values for the datatypes by using the API methods specified in the PropertyUtils class. Consider the below code snippet of two bean classes defined with getter and setter methods:
pubpc class Employee { pubpc FullName getFullName(); pubpc void setFullName(String type, FullName fullname); pubpc Employee getSubordinate(int index); pubpc void setSubordinate(int index, Employee subordinate); pubpc String getFirstName(); pubpc void setFirstName(String first_name); pubpc String getLastName(); pubpc void setLastName(String last_name); }Advertisements