All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.intarsys.tools.tree.BeanPropertiesNode Maven / Gradle / Ivy

There is a newer version: 4.11
Show newest version
package de.intarsys.tools.tree;

import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.List;

/**
 * A {@link PropertiesNode} that reflects the object properties using plain Java
 * beans techniques.
 * 
 */
public class BeanPropertiesNode extends PropertiesNode {

	public BeanPropertiesNode(CommonNode parent, Object object) {
		super(parent, object);
	};

	@Override
	protected void createPropertyNodes(List properties) {
		try {
			BeanInfo info = Introspector.getBeanInfo(getObject().getClass());
			PropertyDescriptor[] propertyDescriptors = info
					.getPropertyDescriptors();
			for (int i = 0; i < propertyDescriptors.length; i++) {
				PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
				PropertyNode tempNode = new PropertyNode(this, getObject(),
						propertyDescriptor.getDisplayName(),
						propertyDescriptor.getName(), false);
				Object tempValue = tempNode.getPropertyValue();
				if (tempValue instanceof String || tempValue instanceof Number) {
					properties.add(tempNode);
				}
			}
		} catch (Exception e) {
			//
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy