private IXMLElement createElement(Object bean, String name)
throws XMLException
{
IXMLElement elem = null;
BeanInfo info = null;
try
{
if (bean != null)
{
info = Introspector.getBeanInfo(bean.getClass(), Object.class);
}
}
catch (IntrospectionException ex)
{
throw new XMLException(ex);
}
elem = new XMLElement(name != null ? name : XMLConstants.BEAN_ELEMENT_NAME);
if (info != null)
{
if (bean instanceof IXMLAboutToBeWritten)
{
((IXMLAboutToBeWritten) bean).aboutToBeWritten();
}
PropertyDescriptor[] propDesc = info.getPropertyDescriptors();
elem = new XMLElement(name != null ? name : XMLConstants.BEAN_ELEMENT_NAME);
elem.setAttribute(XMLConstants.CLASS_ATTRIBUTE_NAME,
bean.getClass().getName());
for (int i = 0; i < propDesc.length; ++i)
{