use of org.jdom.output.XMLOutputter in project voldemort by voldemort.
the class RestUtils method constructSerializerInfoXml.
/**
* Given a storedefinition, constructs the xml string to be sent out in
* response to a "schemata" fetch request
*
* @param storeDefinition
* @return serialized store definition
*/
public static String constructSerializerInfoXml(StoreDefinition storeDefinition) {
Element store = new Element(StoreDefinitionsMapper.STORE_ELMT);
store.addContent(new Element(StoreDefinitionsMapper.STORE_NAME_ELMT).setText(storeDefinition.getName()));
Element keySerializer = new Element(StoreDefinitionsMapper.STORE_KEY_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(keySerializer, storeDefinition.getKeySerializer());
store.addContent(keySerializer);
Element valueSerializer = new Element(StoreDefinitionsMapper.STORE_VALUE_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(valueSerializer, storeDefinition.getValueSerializer());
store.addContent(valueSerializer);
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(store);
}
use of org.jdom.output.XMLOutputter in project voldemort by voldemort.
the class ClusterMapper method writeCluster.
public String writeCluster(Cluster cluster) {
Document doc = new Document(new Element(CLUSTER_ELMT));
doc.getRootElement().addContent(new Element(CLUSTER_NAME_ELMT).setText(cluster.getName()));
boolean displayZones = cluster.getZones().size() > 1;
if (displayZones) {
for (Zone n : cluster.getZones()) doc.getRootElement().addContent(mapZone(n));
}
for (Node n : cluster.getNodes()) doc.getRootElement().addContent(mapServer(n, displayZones));
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(doc.getRootElement());
}
use of org.jdom.output.XMLOutputter in project voldemort by voldemort.
the class StoreDefinitionsMapper method writeStoreList.
public String writeStoreList(List<StoreDefinition> stores) {
Element root = new Element(STORES_ELMT);
for (StoreDefinition def : stores) {
if (def.isView())
root.addContent(viewToElement(def));
else
root.addContent(storeToElement(def));
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(root);
}
use of org.jdom.output.XMLOutputter in project intellij-community by JetBrains.
the class XMLOutputterTest method printElement.
private String printElement(Element root) throws IOException {
XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n");
final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true);
xmlOutputter.setFormat(format);
CharArrayWriter writer = new CharArrayWriter();
xmlOutputter.output(root, writer);
String res = new String(writer.toCharArray());
return res;
}
use of org.jdom.output.XMLOutputter in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method assertXmlOutputEquals.
protected static void assertXmlOutputEquals(String expected, Element root) throws IOException {
StringWriter writer = new StringWriter();
Format format = Format.getPrettyFormat();
format.setLineSeparator("\n");
new XMLOutputter(format).output(root, writer);
String actual = writer.toString();
assertEquals(expected, actual);
}
Aggregations