tagDescription.setDefaultNamespace(ConfigEditorBoot.NAMESPACE);
tagDescription.setNamespaceHasCData(ConfigEditorBoot.NAMESPACE, false);
tagDescription.setElementHasCData(ConfigEditorBoot.NAMESPACE, "text", true);
tagDescription.setElementHasCData(ConfigEditorBoot.NAMESPACE, "description", true);
final XmlWriter dwriter = new XmlWriter(writer, tagDescription);
dwriter.writeXmlDeclaration(encoding);
dwriter.writeTag(ConfigEditorBoot.NAMESPACE,
"config-description", attList, XmlWriterSupport.OPEN); //$NON-NLS-1$
final CharacterEntityParser parser = CharacterEntityParser.createXMLEntityParser();
for (int i = 0; i < getSize(); i++)
{
final ConfigDescriptionEntry entry = get(i);
final AttributeList p = new AttributeList();
p.setAttribute(ConfigEditorBoot.NAMESPACE, "name", entry.getKeyName()); //$NON-NLS-1$
p.setAttribute(ConfigEditorBoot.NAMESPACE, "global", String.valueOf(entry.isGlobal())); //$NON-NLS-1$
p.setAttribute(ConfigEditorBoot.NAMESPACE, "hidden", String.valueOf(entry.isHidden())); //$NON-NLS-1$
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "key", p, XmlWriterSupport.OPEN); //$NON-NLS-1$
if (entry.getDescription() != null)
{
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "description", XmlWriterSupport.OPEN); //$NON-NLS-1$
writer.write(parser.encodeEntities(entry.getDescription()));
dwriter.writeCloseTag();
}
if (entry instanceof ClassConfigDescriptionEntry)
{
final ClassConfigDescriptionEntry ce = (ClassConfigDescriptionEntry) entry;
if (ce.getBaseClass() != null)
{
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "class", "instanceof", //$NON-NLS-1$ //$NON-NLS-2$
ce.getBaseClass().getName(), XmlWriterSupport.CLOSE);
}
else
{
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "class", "instanceof", //$NON-NLS-1$ //$NON-NLS-2$
"java.lang.Object", XmlWriterSupport.CLOSE); //$NON-NLS-1$
}
}
else if (entry instanceof TextConfigDescriptionEntry)
{
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "text", //$NON-NLS-1$
new AttributeList(), XmlWriterSupport.CLOSE);
}
else if (entry instanceof EnumConfigDescriptionEntry)
{
final EnumConfigDescriptionEntry en = (EnumConfigDescriptionEntry) entry;
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "enum", XmlWriterSupport.OPEN); //$NON-NLS-1$
final String[] alts = en.getOptions();
if (alts != null)
{
for (int optCount = 0; optCount < alts.length; optCount++)
{
dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "text", XmlWriterSupport.OPEN); //$NON-NLS-1$
dwriter.writeTextNormalized(alts[optCount], false);
dwriter.writeCloseTag();
}
}
dwriter.writeCloseTag();
}
dwriter.writeCloseTag();
}
dwriter.writeCloseTag();
writer.flush();
}