wood burning stoves 2.0*
The moose likes Java in General and the fly likes Java Bean retrieving all Non-Null Attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Bean retrieving all Non-Null Attributes" Watch "Java Bean retrieving all Non-Null Attributes" New topic

Java Bean retrieving all Non-Null Attributes

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Suppose I have a class

class People(){
String firstName;
String lastName;
int name;
public String getFirstName()
public void setFirstName(String firstName);

And i intend to obtain all the non Null attributes of an object that is an instance of this class

for instance

People people=new People();

Array tempMap=someutilityClass(people);

someutilityClass would return an array of attributes that are not null, Any pointers on how to accomplish this
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Use java.beans.Introspector to get a list of PropertyDescriptors, then check each property to see if it's null or not. Were you expecting something more?

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link: http://aspose.com/file-tools
subject: Java Bean retrieving all Non-Null Attributes
Similar Threads
Extracting data from a bean
Problem in deploying Entity Bean
problem with if statement
Problem with refresh() method of EntityManamger in JPA
Passing Array of objects to a different class