aspose file tools*
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
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
Author

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();
people.setFirstName("george");
people.setLastName("May");

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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