PageletEditor { public String toXml() { StringBuffer buf = new StringBuffer(); buf.append("<pageleteditor "); buf.append("name=\"").append(renderer.getName()).append("\" "); buf.append("module=\"").append(renderer.getModule().getName()).append("\" "); buf.append("uri=\"").append(uri.getIdentifier()).append("\" "); buf.append("composer=\"").append(composerId).append("\" "); buf.append("index=\"").append(pageletIndex).append("\">"); buf.append("<data flavor=\"").append(dataFlavor.toString().toLowerCase()).append("\">"); String data = null; switch (dataFlavor) { case Json: try { data = "<![CDATA[" + XML.toJSONObject(pagelet.toXml()).toString() + "]]>"; } catch (JSONException e) { throw new IllegalStateException("Pagelet xml can't be converted to json: " + e.getMessage(), e); } break; case Xml: data = pagelet.toXml(); break; default: throw new IllegalStateException("An unhandled flavor was found: " + dataFlavor); } buf.append(data); buf.append("</data>"); if (editorContents != null) { buf.append("<editor type=\"xhtml\"><![CDATA["); buf.append(editorContents); buf.append("]]></editor>"); } Module m = renderer.getModule(); for (HTMLHeadElement headElement : renderer.getHTMLHeaders()) { buf.append(ConfigurationUtils.processTemplate(headElement.toXml(), m, environment)); } buf.append("</pageleteditor>"); return buf.toString(); } PageletEditor(Pagelet pagelet, ResourceURI uri, String composer,
      int pageletIndex, Environment environment); Pagelet getPagelet(); ResourceURI getURI(); String getComposer(); int getPageletIndex(); void setDataFlavor(DataFlavor flavor); DataFlavor getDataFlavor(); boolean hasRenderer(); URL getRenderer(); boolean hasEditor(); URL getEditorURL(); void setEditor(String contents); String toXml();  }
@Test public void testToXml() { fail("Not yet implemented"); }