public void generateConfig(XmlWriter w,
ExtensionProfile extProfile) throws IOException {
List<Attribute> epAttrs = new ArrayList<Attribute>();
epAttrs.add(new Attribute("arbitraryXml", allowsArbitraryXml));
w.startElement(Namespaces.gdataConfigNs, "extensionProfile", epAttrs,
nsDecls);
for (XmlNamespace namespace : additionalNamespaces) {
List<Attribute> nsAttrs = new ArrayList<Attribute>();
nsAttrs.add(new Attribute("alias", namespace.getAlias()));
nsAttrs.add(new Attribute("uri", namespace.getUri()));
w.simpleElement(Namespaces.gdataConfigNs, "namespaceDescription",
nsAttrs, null);
}
//
// Get a list of the extended classes sorted by class name
//
TreeSet<Class<?>> extensionSet = new TreeSet<Class<?>>(
new Comparator<Class<?>>() {
public int compare(Class<?> c1, Class<?> c2) {
return c1.getName().compareTo(c2.getName());
}
@Override
public boolean equals(Object c) {
return this.getClass().equals(c.getClass());
}
});
for (Class<?> extensionPoint : profile.keySet()) {
extensionSet.add(extensionPoint);
}
for (Class<?> extensionPoint : extensionSet) {
ExtensionManifest manifest = profile.get(extensionPoint);
List<Attribute> ptAttrs = new ArrayList<Attribute>();
ptAttrs.add(new Attribute("extendedClass", extensionPoint.getName()));
ptAttrs.add(new Attribute("arbitraryXml", manifest.arbitraryXml));
w.startElement(Namespaces.gdataConfigNs, "extensionPoint", ptAttrs, null);
// Create an ordered list of the descriptions in this profile
TreeSet<ExtensionDescription> descSet =
new TreeSet<ExtensionDescription>();