final DefaultTagDescription dtd = new DefaultTagDescription();
dtd.addDefaultDefinition(META_NAMESPACE, false);
final XmlWriter writer = new XmlWriter(new PrintWriter(System.out), dtd);
final AttributeList attrList = new AttributeList();
attrList.addNamespaceDeclaration("", META_NAMESPACE);
writer.writeTag(META_NAMESPACE, "meta-data", attrList, XmlWriter.OPEN);
for (int i = 0; i < classes.length; i++)
{
final Class aClass = classes[i];
if (OutputFunction.class.isAssignableFrom(aClass))
{
// Output functions will not be recognized.
continue;
}
if (aClass.getName().indexOf('$') >= 0)
{
// Inner-Classes will not be recognized.
continue;
}
final AttributeList expressionAttrList = new AttributeList();
expressionAttrList.setAttribute(META_NAMESPACE, "class", aClass.getName());
expressionAttrList.setAttribute(META_NAMESPACE, "bundle-name", "org.pentaho.reporting.engine.classic.core.metadata.messages");
expressionAttrList.setAttribute(META_NAMESPACE, "result", "java.lang.Object");
expressionAttrList.setAttribute(META_NAMESPACE, "expert", "false");
expressionAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
expressionAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
writer.writeTag(META_NAMESPACE, "expression", expressionAttrList, XmlWriter.OPEN);
final BeanInfo beanInfo = Introspector.getBeanInfo(aClass);
final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
for (int j = 0; j < descriptors.length; j++)
{
final PropertyDescriptor descriptor = descriptors[j];
final String key = descriptor.getName();
if ("runtime".equals(key))
{
continue;
}
if ("active".equals(key))
{
continue;
}
if ("preserve".equals(key))
{
continue;
}
if (descriptor.getReadMethod() == null || descriptor.getWriteMethod() == null)
{
continue;
}
final AttributeList propAttrList = new AttributeList();
propAttrList.setAttribute(META_NAMESPACE, "name", descriptor.getName());
if ("name".equals(key))
{
propAttrList.setAttribute(META_NAMESPACE, "mandatory", "true");
propAttrList.setAttribute(META_NAMESPACE, "preferred", "true");
propAttrList.setAttribute(META_NAMESPACE, "value-role", "Name");
propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
}
else
{
propAttrList.setAttribute(META_NAMESPACE, "mandatory", "false");
propAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
propAttrList.setAttribute(META_NAMESPACE, "value-role", "Value");
if ("dependencyLevel".equals(key))
{
propAttrList.setAttribute(META_NAMESPACE, "expert", "true");
}
else
{
propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
}
}
propAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
writer.writeTag(META_NAMESPACE, "property", propAttrList, XmlWriter.CLOSE);
}
writer.writeCloseTag();