Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

PropertyUtils java

Hi,

I am going through below link on property utils

http://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/PropertyUtils.html#getPropertyDescriptor(java.lang.Object


What for they used and why and when. How they are related to collections.
please advise
Any links resources ideas highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Am P
Am P
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

PropertyUtils is written using java reflection api and provides you ability to modify properties of Java object at runtime.

In the link
 http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html
it was mentioned as below
Remember we don’t know anything about Object on compile time. On runtime Object is provided to program along with name of property to retrieve or modify:

Read more: http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html#ixzz2uX3g47Zr




Why we do not know anything about object at compile time but  runtime Object is provided to program along with name of property to retrieve or modify.

I am not clear on those statements.
I ran above program in the javarevisited link, I got output as below
PropertyUtils Example property value: blue

what is the meaning of output

I see we are setting and getting colr from PropertyUtils
   
  //here color and blue strings can come from variety or sources
        //e.g. configuration files, database, any upstream system or via HTTP Request
        PropertyUtils.setProperty(flexiColor, "color", "blue");
        String value = (String) PropertyUtils.getProperty(flexiColor, "color");
        System.out.println("PropertyUtils Example property value: " + value);

How is it different from regular getter and setter from a bean.

 PropertyUtils.setProperty(flexiColor, "color", "blue");

Where is this setter defined.

please advise
Avatar of gudii9

ASKER

I see code as below

    PropertyUtils.getPropertyDescriptor(obj, fieldName).getWriteMethod().invoke(obj, list);

What is the meaning of above code while parsing a text document which has not only primitives but also list kind of objects before sending to one other system.
please advise
Avatar of gudii9

ASKER

How the reflection on class, method, field are different.
Any practical example to understand this reflection concept end to end better with set up on eclipse. please advise