List of usage examples for javax.xml.stream XMLStreamWriter writeCharacters
public void writeCharacters(String text) throws XMLStreamException;
From source file:com.fiorano.openesb.application.common.Param.java
public void toJXMLString(XMLStreamWriter writer) throws XMLStreamException { //Start Param writer.writeStartElement("Param"); writer.writeAttribute("name", m_paramName); writer.writeCharacters(m_paramValue); //End Param// w w w. j a v a2s . c om writer.writeEndElement(); }
From source file:com.norconex.jef4.status.FileJobStatusStore.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/* w w w .j av a 2 s.c o m*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("statusStore"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("statusDir"); writer.writeCharacters(new File(statusDir).getAbsolutePath()); writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.collector.http.client.impl.DefaultHttpClientInitializer.java
private void writeSimpleElement(XMLStreamWriter writer, String name, String value) throws XMLStreamException { writer.writeStartElement(name);/*from w w w . ja v a 2 s .com*/ writer.writeCharacters(value); writer.writeEndElement(); }
From source file:com.norconex.collector.core.filter.impl.RegexMetadataFilter.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/*ww w . j a v a 2 s. co m*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("filter"); writer.writeAttribute("class", getClass().getCanonicalName()); super.saveToXML(writer); writer.writeAttribute("caseSensitive", Boolean.toString(caseSensitive)); writer.writeAttribute("field", field); writer.writeCharacters(regex == null ? "" : regex); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.collector.http.url.impl.GenericURLNormalizer.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {// w w w.j a v a 2s. c om XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("urlNormalizer"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("normalizations"); writer.writeCharacters(StringUtils.join(normalizations, ",")); writer.writeEndElement(); writer.writeStartElement("replacements"); for (Replace replace : replaces) { writer.writeStartElement("replace"); writer.writeStartElement("match"); writer.writeCharacters(replace.getMatch()); writer.writeEndElement(); writer.writeStartElement("replacement"); writer.writeCharacters(replace.getReplacement()); writer.writeEndElement(); writer.writeEndElement(); } writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:DDTReporter.java
private void writeEndElement(XMLStreamWriter writer) throws XMLStreamException { writer.writeEndElement();/* w ww . java 2 s. c om*/ writer.writeCharacters("\n"); }
From source file:com.norconex.collector.http.sitemap.impl.StandardSitemapResolverFactory.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/* w ww . j av a2s .c o m*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("sitemapResolverFactory"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeAttribute("lenient", Boolean.toString(lenient)); if (sitemapLocations != null) { for (String location : sitemapLocations) { writer.writeStartElement("location"); writer.writeCharacters(location); writer.writeEndElement(); } } writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:DDTReporter.java
private void writeStartElement(XMLStreamWriter writer, String name) throws XMLStreamException { writer.writeStartElement(name);//from w w w . j a v a2 s . c o m writer.writeCharacters("\n"); }
From source file:net.landora.video.info.file.FileInfoManager.java
private synchronized void writeCacheFile(File file, Map<String, FileInfo> infoMap) { OutputStream os = null;// w w w .j a va2 s .c om try { os = new BufferedOutputStream(new FileOutputStream(file)); if (COMPRESS_INFO_FILE) { os = new GZIPOutputStream(os); } XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(os); writer.writeStartDocument(); writer.writeStartElement("files"); writer.writeCharacters("\n"); for (Map.Entry<String, FileInfo> entry : infoMap.entrySet()) { FileInfo info = entry.getValue(); writer.writeStartElement("file"); writer.writeAttribute("filename", entry.getKey()); writer.writeAttribute("ed2k", info.getE2dkHash()); writer.writeAttribute("length", String.valueOf(info.getFileSize())); writer.writeAttribute("lastmodified", String.valueOf(info.getLastModified())); if (info.getMetadataSource() != null) { writer.writeAttribute("metadatasource", info.getMetadataSource()); } if (info.getMetadataId() != null) { writer.writeAttribute("metadataid", info.getMetadataId()); } if (info.getVideoId() != null) { writer.writeAttribute("videoid", info.getVideoId()); } writer.writeEndElement(); writer.writeCharacters("\n"); } writer.writeEndElement(); writer.writeEndDocument(); writer.close(); } catch (Exception e) { log.error("Error writing file cache.", e); } finally { if (os != null) { IOUtils.closeQuietly(os); } } }
From source file:com.marklogic.client.impl.CombinedQueryBuilderImpl.java
private String makeXMLCombinedQuery(CombinedQueryDefinitionImpl qdef) { try {/*ww w. ja va 2 s. c o m*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); String qtext = qdef.qtext; StructuredQueryDefinition structuredQuery = qdef.structuredQuery; RawQueryDefinition rawQuery = qdef.rawQuery; QueryOptionsWriteHandle options = qdef.options; String sparql = qdef.sparql; if (rawQuery != null && rawQuery instanceof RawCombinedQueryDefinition) { CombinedQueryDefinitionImpl combinedQdef = parseCombinedQuery( (RawCombinedQueryDefinition) rawQuery); rawQuery = combinedQdef.rawQuery; if (qtext == null) qtext = combinedQdef.qtext; if (options == null) options = combinedQdef.options; if (sparql == null) sparql = combinedQdef.sparql; } XMLStreamWriter serializer = makeXMLSerializer(out); serializer.writeStartDocument(); serializer.writeStartElement("search"); if (qtext != null) { serializer.writeStartElement("qtext"); serializer.writeCharacters(qtext); serializer.writeEndElement(); } else { serializer.writeCharacters(""); } if (sparql != null) { serializer.writeStartElement("sparql"); serializer.writeCharacters(sparql); serializer.writeEndElement(); } serializer.flush(); String structure = ""; if (structuredQuery != null) structure = structuredQuery.serialize(); if (rawQuery != null) structure = HandleAccessor.contentAsString(rawQuery.getHandle()); out.write(structure.getBytes("UTF-8")); out.flush(); if (options != null) { HandleImplementation handleBase = HandleAccessor.as(options); Object value = handleBase.sendContent(); if (value instanceof OutputStreamSender) { ((OutputStreamSender) value).write(out); } else { out.write(HandleAccessor.contentAsString(options).getBytes("UTF-8")); } out.flush(); } serializer.writeEndElement(); serializer.writeEndDocument(); serializer.flush(); serializer.close(); return out.toString("UTF-8"); } catch (Exception e) { throw new MarkLogicIOException(e); } }