পৃষ্ঠাসমূহ

Search Your Article

CS

Pageviews

Showing posts with label Java BeanUtils Tutorial. Show all posts
Showing posts with label Java BeanUtils Tutorial. Show all posts

Friday, February 3, 2017

Java BeanUtils - Overview

Description

The Java BeanUtils are the components of the Apache Commons which are derived from JavaAPI and provides component architecture for the Java language. The Java BeanUtils design patterns uses utility classes that helps to get and set the property values on Java classes for retrieving and defining the bean properties.

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 supplies the java.beans.Introspector class to inspect a Java class at runtime.

Java BeanUtils - Basic Property Access

Description

You can access the basic properties by using the following ways:
  • Simple Property
  • Indexed Property
  • Mapped Property

Java BeanUtils - Nested Property Access

Description

You can access the value of nested property of the bean by concatenating the property names of the access path by using "." separators.
You can get and set the values of Nested property by using the below methods:

Java BeanUtils - Customizing Introspection

Description

The introspection tool can be used to learn about the properties and operations provided by your class. BeanUtils package is depending on JavaBeans specification that determines the available properties for a particular bean class.

Java BeanUtils - Suppressing Properties

Description

You can suppress the specific properties by using the bean introspection mechanism. The specialized BeanIntrospector interface is implemented by the type called SuppressPropertiesBeanIntrospector which suppresses the special class properties of Java beans.

Java BeanUtils - Background (DynaBeans)

Description

You can give dynamic property access on the existing JavaBean classes without altering with the help of PropertyUtils class. The dynamically calculated property values as JavaBean can also represented by using dynamic property access without writing a Java class to render these properties.

Java BeanUtils - Basic DynaBeans

Description

The implementation of BasicDynaBean and BasicDynaClass specifies the capacity of dynamic property to provide the set of properties dynamically. You can start with DynaClass to establish the set of properties. A newInstance() method will create a new DynaBean instances to DynaClass and occupy its initial values as shown in the below example.

Java BeanUtils - ResultSetDynaClass

Description

The ResultSet can be wrapped in the DynaBeans by using the ResultSetDynaClass which renders the results of SQL query as series of DynaBeans. The most commonly used collection is java.sql.ResultSet which is returned when JDBC driver uses SQL SELECT statement.

Java BeanUtils - RowSetDynaClass

Description

The RowSetDynaClass copies the undisclosed data in the DynaBeans memory while creating an instance which displays the result and using this class, you can close the ResultSet data before proceeding the actual data that was returned.

Java BeanUtils - WrapDynaBean

Description

As we have seen in the previous chapters, DynaBeans APIs provides get() and set() methods to access simple, indexed and mapped properties of DynaBeans dynamically.

Java BeanUtils - Lazy DynaBeans

Description

Lazy DynaBeans is an implementation of DynaBean, which gives the characteristics of Lazy List and Lazy Map this connects the properties of DynaClass. There are four types of Lazy DynaBeans:

Java BeanUtils - Background (Data Type Conversions)

Description

Data type conversion is a process of changing value from one data type to another. In the previous chapters, dynamically accessed properties of data types are recognized and to achieve the type conversions, we can use Java casts. The BeanUtils package gives various types of APIs and design patterns for performing the data type conversions.

Java BeanUtils - BeanUtils and ConvertUtils

Description

The BeanUtils is defined as a utility method for populating JavaBeans properties and ConvertUtils method converts string scalar values to objects, string arrays to arrays of the specified class.

Java BeanUtils - Create Custom Converters

Description

BeanUtils package allows creating your own string object to convert for any java class and the registered converters can be used by all the BeanUtils methods.
The following are the steps to create and register your own converter:

Java BeanUtils - Locale Aware Conversions

Description

The regular classes available in org.apache.commons.beanutils are not assigned for any specific event. These classes provide a clear interface to make use of situations very easily where the locale is not main thing. You can use Locale-aware extensions of beanutils classes which helps localization, from the org.apache.commons.beanutils.locale package.

Java BeanUtils - Utility Objects & Classes

Description

The utility classes such as BeanUtils, ConvertUtils and PropertyUtils can be accessed through utility objects and shares the same caches and registered converters. You can instantiate corresponding class with same functionality for each static utility class.

Java BeanUtils - Comparing Beans

Description

In Apache Commons Beanutils, you can compare the JavaBean objects by using the BeanComparator class based on a specified shared property value. This can be done by using the org.apache.commons.beanutils.BeanComparator comparator.

Java BeanUtils - Operating On Collections

Description

The Commons-Collections are build upon interfaces, implementations and utilities. It contains Closure interface in the code that can be applied on the arbitrary input object and code permits to apply Closures to contents of collection.

Java BeanUtils - Querying Or Filtering Collections

Description

The collections of beans can be filtered in the commons-collections by using the interface Predicate and also provides either true or false value on the evaluation of an input object. There is a Predicate called BeanPropertyValueEqualsPredicate which will assess the set property value against the given value.