List of usage examples for org.jdom2.output XMLOutputter outputString
public final String outputString(EntityRef entity)
From source file:org.graphwalker.StatisticsManager.java
License:Open Source License
public String getFullProgressXml() { XMLOutputter outputter = new XMLOutputter(); return outputter.outputString(this.progress); }
From source file:org.helm.notation2.MonomerFactory.java
License:Open Source License
private static String buildMonomerDbXMLFromCache(MonomerCache cache) throws MonomerException { XMLOutputter outputer = new XMLOutputter(Format.getPrettyFormat()); StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + System.getProperty("line.separator") + "<MonomerDB xmlns=\"lmr\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + System.getProperty("line.separator")); Map<String, Map<String, Monomer>> mDB = cache.getMonomerDB(); Element polymerListElement = new Element(POLYMER_LIST_ELEMENT); Set<String> polymerTypeSet = mDB.keySet(); for (Iterator i = polymerTypeSet.iterator(); i.hasNext();) { String polymerType = (String) i.next(); Element polymerElement = new Element(POLYMER_ELEMENT); Attribute att = new Attribute(POLYMER_TYPE_ATTRIBUTE, polymerType); polymerElement.setAttribute(att); polymerListElement.getChildren().add(polymerElement); Map<String, Monomer> monomerMap = mDB.get(polymerType); Set<String> monomerSet = monomerMap.keySet(); for (Iterator it = monomerSet.iterator(); it.hasNext();) { String monomerID = (String) it.next(); Monomer m = monomerMap.get(monomerID); Element monomerElement = MonomerParser.getMonomerElement(m); polymerElement.getChildren().add(monomerElement); }/*from w w w.j av a 2s . co m*/ } String polymerListString = outputer.outputString(polymerListElement); sb.append(polymerListString + System.getProperty("line.separator")); Map<String, Attachment> aDB = cache.getAttachmentDB(); Element attachmentListElement = new Element(ATTACHMENT_LIST_ELEMENT); Set<String> attachmentSet = aDB.keySet(); for (Iterator itr = attachmentSet.iterator(); itr.hasNext();) { String attachmentID = (String) itr.next(); Attachment attachment = aDB.get(attachmentID); Element attachmentElement = MonomerParser.getAttachementElement(attachment); attachmentListElement.getChildren().add(attachmentElement); } String attachmentListString = outputer.outputString(attachmentListElement); sb.append(attachmentListString); sb.append(System.getProperty("line.separator") + "</MonomerDB>" + System.getProperty("line.separator")); return sb.toString(); }
From source file:org.helm.notation2.tools.NucleotideParser.java
License:Open Source License
public static String getNucleotideTemplatesXML(Map<String, Map<String, String>> templates) { XMLOutputter outputer = new XMLOutputter(Format.getPrettyFormat()); StringBuilder sb = new StringBuilder(); sb.append(/*from www .jav a2 s.c om*/ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<NUCLEOTIDE_TEMPLATES xsi:schemaLocation=\"lmr NucleotideTemplateSchema.xsd\" xmlns=\"lmr\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"); Set<String> templateSet = templates.keySet(); for (Iterator i = templateSet.iterator(); i.hasNext();) { String template = (String) i.next(); Element templateElement = new Element(TEMPLATE_ELEMENT); Attribute att = new Attribute(TEMPLATE_NOTATION_SOURCE_ATTRIBUTE, template); templateElement.setAttribute(att); Map<String, String> nucMap = templates.get(template); Set<String> nucleotideSet = nucMap.keySet(); for (Iterator it = nucleotideSet.iterator(); it.hasNext();) { Element nucleotideElement = new Element(NUCLEOTIDE_ELEMENT); templateElement.getChildren().add(nucleotideElement); String symbol = (String) it.next(); Element symbolElement = new Element(NUCLEOTIDE_SYMBOL_ELEMENT); symbolElement.setText(symbol); nucleotideElement.getChildren().add(symbolElement); String notation = nucMap.get(symbol); Element notationElement = new Element(NUCLEOTIDE_MONOMER_NOTATION_ELEMENT); notationElement.setText(notation); nucleotideElement.getChildren().add(notationElement); } String templateString = outputer.outputString(templateElement); sb.append(templateString); } sb.append("\n</NUCLEOTIDE_TEMPLATES>"); return sb.toString(); }
From source file:org.helm.notation2.tools.xHelmNotationExporter.java
License:Open Source License
/** * method to get xhelm for the helm2 notation with the new functionality * * @param helm2notation, HELM2Notation object * @return xhelm/* w w w . j ava 2 s .c o m*/ * @throws MonomerException * @throws JDOMException * @throws IOException * @throws ChemistryException */ public static String getXHELM2(HELM2Notation helm2notation) throws MonomerException, IOException, JDOMException, ChemistryException { set = new HashSet<Monomer>(); Element root = new Element(xHelmNotationExporter.XHELM_ELEMENT); Document doc = new Document(root); Element helmElement = new Element(xHelmNotationExporter.HELM_NOTATION_ELEMENT); helmElement.setText(helm2notation.toHELM2()); root.addContent(helmElement); Element monomerListElement = new Element(xHelmNotationExporter.MONOMER_LIST_ELEMENT); /* save all adhocMonomers */ for (MonomerNotation monomernotation : MethodsMonomerUtils .getListOfMonomerNotation(helm2notation.getListOfPolymers())) { /* get all elements of an rna */ if (monomernotation instanceof MonomerNotationUnitRNA) { for (MonomerNotationUnit unit : ((MonomerNotationUnitRNA) monomernotation).getContents()) { addAdHocMonomer(unit); } } else { addAdHocMonomer(monomernotation); } } /* give the adhocMonomer's information */ for (Monomer distinctmonomer : set) { Element monomerElement = MonomerParser.getMonomerElement(distinctmonomer); monomerListElement.getChildren().add(monomerElement); } root.addContent(monomerListElement); XMLOutputter xmlOutput = new XMLOutputter(); // display nice xmlOutput.setFormat(Format.getPrettyFormat()); return xmlOutput.outputString(doc); }
From source file:org.helm.notation2.tools.xHelmNotationExporter.java
License:Open Source License
/** * method to get xhelm for the helm notation, only if it was possible to * convert the helm in the old format//from w w w . java 2s . c om * * @param helm2notation, HELM2Notation object * @return xhelm * @throws MonomerException * @throws HELM1FormatException * @throws JDOMException * @throws IOException * @throws NotationException * @throws CTKException * @throws ValidationException * @throws ChemistryException if the Chemistry Engine can not be initialized */ public static String getXHELM(HELM2Notation helm2notation) throws MonomerException, HELM1FormatException, IOException, JDOMException, NotationException, CTKException, ValidationException, ChemistryException { set = new HashSet<Monomer>(); Element root = new Element(xHelmNotationExporter.XHELM_ELEMENT); Document doc = new Document(root); Element helmElement = new Element(xHelmNotationExporter.HELM_NOTATION_ELEMENT); helmElement.setText(HELM1Utils.getStandard(helm2notation)); root.addContent(helmElement); Element monomerListElement = new Element(xHelmNotationExporter.MONOMER_LIST_ELEMENT); /* save all adhocMonomers in the set */ for (MonomerNotation monomernotation : MethodsMonomerUtils .getListOfMonomerNotation(helm2notation.getListOfPolymers())) { /* get all elements of an rna */ if (monomernotation instanceof MonomerNotationUnitRNA) { for (MonomerNotationUnit unit : ((MonomerNotationUnitRNA) monomernotation).getContents()) { addAdHocMonomer(unit); } } else { addAdHocMonomer(monomernotation); } } /* give adhoc monomer's information */ for (Monomer distinctmonomer : set) { Element monomerElement = MonomerParser.getMonomerElement(distinctmonomer); monomerListElement.getChildren().add(monomerElement); } root.addContent(monomerListElement); XMLOutputter xmlOutput = new XMLOutputter(); // display nice xmlOutput.setFormat(Format.getPrettyFormat()); return xmlOutput.outputString(doc); }
From source file:org.isisaddons.module.docx.fixture.dom.templates.CustomerConfirmation.java
License:Apache License
@Action(semantics = SemanticsOf.SAFE, restrictTo = RestrictTo.PROTOTYPING) @ActionLayout(contributed = Contributed.AS_ACTION) @MemberOrder(sequence = "11") public Clob downloadCustomerConfirmationInputHtml(final Order order) throws IOException, JDOMException, MergeException { final Document orderAsHtmlJdomDoc = asInputDocument(order); final XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); final String html = xmlOutput.outputString(orderAsHtmlJdomDoc); final String clobName = "customerConfirmation-" + order.getNumber() + ".html"; final String clobMimeType = "text/html"; final String clobBytes = html; return new Clob(clobName, clobMimeType, clobBytes); }
From source file:org.jls.toolbox.util.xml.XMLParser.java
License:Open Source License
/** * Permet partir d'un document XML gnr par JDom de rcuprer la chane * formate en XML.//from w w w. j a v a 2s.c o m * * @param xmlDocument * Fichier XML gnr avec JDom. * @return Chane formate en XML. */ public static String getStream(Document xmlDocument) { Format format = Format.getPrettyFormat(); format.setIndent("\t"); XMLOutputter output = new XMLOutputter(format); return output.outputString(xmlDocument); }
From source file:org.jumpmind.metl.core.runtime.component.AbstractXMLComponentRuntime.java
License:Open Source License
protected String toXML(Element element) { XMLOutputter xmlOutputter = new XMLOutputter(); return xmlOutputter.outputString(element); }
From source file:org.jumpmind.metl.core.runtime.component.XmlFormatter.java
License:Open Source License
private void createXml(ISendMessageCallback callback) { Document generatedXml = new Document(); Stack<DocElement> parentStack = new Stack<DocElement>(); ArrayList<String> outboundPayload = new ArrayList<String>(); for (Message msg : messagesToProcess) { processMsgEntities(parentStack, msg, generatedXml); }/*from ww w.j a va2s.c om*/ XMLOutputter xmlOutputter = new XMLOutputter(); Format format = null; if (xmlFormat.equals(COMPACT_FORMAT)) { format = Format.getCompactFormat(); } else if (xmlFormat.equals(RAW_FORMAT)) { format = Format.getRawFormat(); } else { format = Format.getPrettyFormat(); } xmlOutputter.setFormat(format); outboundPayload.add(xmlOutputter.outputString(generatedXml)); callback.sendTextMessage(null, outboundPayload); }
From source file:org.kisst.cordys.caas.util.XmlNode.java
License:Open Source License
public String compact() { XMLOutputter out = new XMLOutputter(Format.getCompactFormat()); return out.outputString(element); }