Search in sources :

Example 11 with XMLOutputter

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);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Element(org.jdom.Element)

Example 12 with XMLOutputter

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());
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Zone(voldemort.cluster.Zone) Element(org.jdom.Element) Node(voldemort.cluster.Node) Document(org.jdom.Document)

Example 13 with XMLOutputter

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);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Element(org.jdom.Element) StoreDefinition(voldemort.store.StoreDefinition)

Example 14 with XMLOutputter

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;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) CharArrayWriter(java.io.CharArrayWriter)

Example 15 with XMLOutputter

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);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) StringWriter(java.io.StringWriter)

Aggregations

XMLOutputter (org.jdom.output.XMLOutputter)48 Element (org.jdom.Element)27 Document (org.jdom.Document)16 Format (org.jdom.output.Format)16 IOException (java.io.IOException)15 StringWriter (java.io.StringWriter)13 SAXBuilder (org.jdom.input.SAXBuilder)6 Writer (java.io.Writer)5 ArrayList (java.util.ArrayList)5 StringReader (java.io.StringReader)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 JDOMException (org.jdom.JDOMException)3 ElementFilter (org.jdom.filter.ElementFilter)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2