package com.javaworld.JavaBeans.XMLBeans; import java.beans.*; import java.lang.reflect.*; public class XMLPropertyDescriptor extends PropertyDescriptor { protected boolean _bVisible = true; protected Method _domReadMethod = null; protected Method _domWriteMethod = null; // Set just the property name and the bean class public XMLPropertyDescriptor(String propertyName, Class beanClass) throws IntrospectionException, NoSuchMethodException { super(propertyName, beanClass); _domReadMethod = null; String domGetterName = "get" + Util.capitalize(propertyName) + "AsDOM"; try { _domReadMethod = beanClass.getMethod(domGetterName, new Class[] {org.w3c.dom.Document.class}); } catch (NoSuchMethodException ex) { // Ignore } _domWriteMethod = null; String domSetterName = "set" + Util.capitalize(propertyName) + "AsDOM"; try { _domWriteMethod = beanClass.getMethod(domSetterName, new Class[] {org.w3c.dom.Node.class}); } catch (NoSuchMethodException ex) { // Ignore } } // Set the property name and the class, plus the names // of the setter and getter (which set/get property by // value) and the domSetter and domGetter (which get/set // property from a DOM Element object. // Throws NoSuchMethodException if a nonexistent method of beanClass // is specified. public XMLPropertyDescriptor(String propertyName, Class beanClass, String getterName, String setterName, String domGetterName, String domSetterName) throws IntrospectionException, NoSuchMethodException { super(propertyName, beanClass, getterName, setterName); _domReadMethod = beanClass.getMethod(domGetterName, new Class[] { org.w3c.dom.Document.class }); _domWriteMethod = beanClass.getMethod(domSetterName, new Class[] { org.w3c.dom.Node.class }); } // Set the property name, plus the Method objects // for the setter and getter (which set/get property by // value) and the domSetter and domGetter (which get/set // property from a DOM Element object. public XMLPropertyDescriptor(String propertyName, Method getter, Method setter, Method domGetter, Method domSetter) throws IntrospectionException { super(propertyName, getter, setter); // Initialize setter and getter methods _domReadMethod = domGetter; _domWriteMethod = domSetter; } // Ask for read/write methods from DOM public Method getDOMReadMethod() { return _domReadMethod; } public Method getDOMWriteMethod() { return _domWriteMethod; } public boolean isVisible() { return _bVisible; } // Internal use only protected void setDOMReadMethod(Method domReadMethod_) { _domReadMethod = domReadMethod_; } protected void setDOMWriteMethod(Method domWriteMethod_) { _domWriteMethod = domWriteMethod_; } public void setVisible(boolean bVisible_) { _bVisible = bVisible_; } }