Solved

PropertyUtils  java

Posted on 2014-02-26
4
273 Views
Last Modified: 2014-04-11
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
0
Comment
Question by:gudii9
  • 3
4 Comments
 
LVL 20

Accepted Solution

by:
Amitkumar Panchal earned 500 total points
Comment Utility
PropertyUtils is written using java reflection api and provides you ability to modify properties of Java object at runtime. Hence, it make you to write highly configurable code where you can provide name of bean properties and there values from configuration rather than coded in Java program.

For more details : http://javarevisited.blogspot.com/2012/04/java-propertyutils-example-getting-and.html

Like propertyutils, Spring is also written on top of reflection api of java.
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 75
wordcount challenge 11 72
for i loop in grovy 1 32
ArrayIndexOutOfBoundException 9 30
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now