List of usage examples for javax.xml.stream XMLStreamWriter writeCharacters
public void writeCharacters(String text) throws XMLStreamException;
From source file:org.xmlsh.commands.internal.json2xml.java
private void write(Number v, XMLStreamWriter writer) throws XMLStreamException, JSONException { writer.writeStartElement("", "number", kJXML_URI); // writer.writeAttribute("value", JSONObject.numberToString(v)); writer.writeCharacters(JSONObject.numberToString(v)); writer.writeEndElement();/* w ww . j a va 2 s . c o m*/ }
From source file:org.xmlsh.commands.internal.json2xml.java
private void write(String s, XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("", "string", kJXML_URI); // writer.writeAttribute("value", s); writer.writeCharacters(s); writer.writeEndElement();// w w w . j a v a 2 s . c o m }
From source file:org.xwiki.xar.internal.property.DateXarObjectPropertySerializer.java
@Override public void write(XMLStreamWriter writer, Object value) throws XMLStreamException { // FIXME: The value of a date property should be serialized using the date timestamp or the date format // specified in the XClass the date property belongs to. writer.writeCharacters(value == null ? "" : DEFAULT_FORMAT.format(value)); }
From source file:org.xwiki.xar.XarPackage.java
/** * Write the package descriptor to the passed XML stream. * //from ww w . j ava 2s. c om * @param writer the XML stream where to write * @throws XMLStreamException when failing to write the file */ public void write(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement(XarModel.ELEMENT_PACKAGE); writer.writeStartElement(XarModel.ELEMENT_INFOS); writeElement(writer, XarModel.ELEMENT_INFOS_NAME, getPackageName(), true); writeElement(writer, XarModel.ELEMENT_INFOS_DESCRIPTION, getPackageDescription(), true); writeElement(writer, XarModel.ELEMENT_INFOS_LICENSE, getPackageLicense(), true); writeElement(writer, XarModel.ELEMENT_INFOS_AUTHOR, getPackageAuthor(), true); writeElement(writer, XarModel.ELEMENT_INFOS_VERSION, getPackageVersion(), true); writeElement(writer, XarModel.ELEMENT_INFOS_ISBACKUPPACK, String.valueOf(isPackageBackupPack()), true); writeElement(writer, XarModel.ELEMENT_INFOS_ISPRESERVEVERSION, String.valueOf(isPackagePreserveVersion()), true); writeElement(writer, XarModel.ELEMENT_INFOS_EXTENSIONID, getPackageExtensionId(), false); writer.writeEndElement(); writer.writeStartElement(XarModel.ELEMENT_FILES); for (XarEntry entry : this.entries.values()) { writer.writeStartElement(XarModel.ELEMENT_FILES_FILE); writer.writeAttribute(XarModel.ATTRIBUTE_DEFAULTACTION, String.valueOf(entry.getDefaultAction())); writer.writeAttribute(XarModel.ATTRIBUTE_LOCALE, Objects.toString(entry.getLocale(), "")); writer.writeCharacters(TOSTRING_SERIALIZER.serialize(entry)); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.xwiki.xar.XarPackage.java
private void writeElement(XMLStreamWriter streamWriter, String localName, String value, boolean emptyIfNull) throws XMLStreamException { if (value != null) { if (value.isEmpty()) { streamWriter.writeEmptyElement(localName); } else {/* ww w. ja va2 s .co m*/ streamWriter.writeStartElement(localName); streamWriter.writeCharacters(value); streamWriter.writeEndElement(); } } else if (emptyIfNull) { streamWriter.writeEmptyElement(localName); } }
From source file:solidbase.core.DBVersion.java
/** * Dumps the current log in XML format to the given output stream, with the given character set. * * @param out The outputstream to which the xml will be written. * @param charSet The requested character set. *///from w w w .j a v a2 s . co m protected void logToXML(OutputStream out, Charset charSet) { // This method does not care about staleness boolean spec11 = SPEC11.equals(this.effectiveSpec); try { Connection connection = this.database.getDefaultConnection(); Statement stat = connection.createStatement(); try { ResultSet result = stat.executeQuery("SELECT " + (spec11 ? "TYPE, " : "") + "SOURCE, TARGET, STATEMENT, STAMP, COMMAND, RESULT FROM " + this.logTableName + " ORDER BY STAMP"); XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter xml = xof.createXMLStreamWriter(new OutputStreamWriter(out, charSet)); xml.writeStartDocument("UTF-8", SPEC10); xml.writeStartElement("log"); while (result.next()) { int i = 1; xml.writeStartElement("record"); if (spec11) xml.writeAttribute("type", result.getString(i++)); xml.writeAttribute("source", StringUtils.defaultString(result.getString(i++))); xml.writeAttribute("target", result.getString(i++)); xml.writeAttribute("statement", String.valueOf(result.getInt(i++))); xml.writeAttribute("stamp", String.valueOf(result.getTimestamp(i++))); String sql = result.getString(i++); if (sql != null) { xml.writeStartElement("command"); xml.writeCharacters(sql); xml.writeEndElement(); } String res = result.getString(i++); if (res != null) { xml.writeStartElement("result"); xml.writeCharacters(res); xml.writeEndElement(); } xml.writeEndElement(); } xml.writeEndElement(); xml.writeEndDocument(); xml.close(); } finally { stat.close(); connection.commit(); } } catch (XMLStreamException e) { throw new SystemException(e); } catch (SQLException e) { throw new SystemException(e); } }
From source file:spypunk.tailthis.configuration.xml.ConfigurationXMLWriter.java
public void save(final Configuration configuration) throws Exception { FileUtils.forceMkdir(configurationFile.getParentFile()); final XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = null; try {//from w w w. j a v a 2s . co m xtw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(new FileWriter(configurationFile))); xtw.writeStartElement(ConfigurationXMLConstants.TAILTHIS_ELEMENT_NAME); xtw.writeStartElement(ConfigurationXMLConstants.REMEMBER_LAST_OPENED_FILES_ELEMENT_NAME); xtw.writeCharacters(configuration.getRememberLastOpenedFiles().toString()); xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.LAST_FOLDER_ELEMENT_NAME); xtw.writeCharacters(configuration.getLastFolder().getAbsolutePath()); xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.LAST_OPENED_FILES_ELEMENT_NAME); for (final File lastOpenedFile : configuration.getLastOpenedFiles()) { xtw.writeStartElement(ConfigurationXMLConstants.LAST_OPENED_FILE_ELEMENT_NAME); xtw.writeCharacters(lastOpenedFile.getAbsolutePath()); xtw.writeEndElement(); } xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.UPDATE_PERIOD_ELEMENT_NAME); xtw.writeCharacters(configuration.getUpdatePeriod().toString()); xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.ALWAYS_ON_TOP_ELEMENT_NAME); xtw.writeCharacters(configuration.getAlwaysOnTop().toString()); xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.LOCALE_ELEMENT_NAME); xtw.writeCharacters(configuration.getLocale().getKey()); xtw.writeEndElement(); xtw.writeStartElement(ConfigurationXMLConstants.HIGHLIGHTINGS_ELEMENT_NAME); for (final Highlighting highlighting : configuration.getHighlightings()) { xtw.writeStartElement(ConfigurationXMLConstants.HIGHLIGHTING_ELEMENT_NAME); xtw.writeAttribute(ConfigurationXMLConstants.BACKGROUND_COLOR_ATTRIBUTE_NAME, highlighting.getBackgroundColor().getKey()); xtw.writeAttribute(ConfigurationXMLConstants.FOREGROUND_COLOR_ATTRIBUTE_NAME, highlighting.getForegroundColor().getKey()); xtw.writeCharacters(highlighting.getPattern().pattern()); xtw.writeEndElement(); } xtw.writeEndElement(); xtw.writeEndElement(); xtw.flush(); } finally { if (xtw != null) { try { xtw.close(); } catch (final XMLStreamException e) { LOGGER.warn(e.getMessage(), e); } } } }
From source file:uk.ac.babraham.FastQC.Modules.KmerContent.java
public void makeReport(HTMLReportArchive report) throws IOException, XMLStreamException { if (!calculated) calculateEnrichment();//from ww w. j a va2s .co m if (enrichedKmers.length > 0) { writeSpecificImage(report, new LineGraph(enrichments, minGraphValue, maxGraphValue, "Position in read (bp)", xLabels, xCategories, "Log2 Obs/Exp"), "kmer_profiles.png", "Kmer graph", Math.max(800, groups.length * 15), 600); } ResultsTable table = new ResultsTable(enrichedKmers); XMLStreamWriter xhtml = report.xhtmlStream(); if (enrichedKmers.length == 0) { xhtml.writeStartElement("p"); xhtml.writeCharacters("No overrepresented Kmers"); xhtml.writeEndElement(); } else { super.writeTable(report, table); } }