Example usage for org.apache.solr.common.util XML writeUnescapedXML

List of usage examples for org.apache.solr.common.util XML writeUnescapedXML

Introduction

In this page you can find the example usage for org.apache.solr.common.util XML writeUnescapedXML.

Prototype

public final static void writeUnescapedXML(Writer out, String tag, String val, Object... attrs)
        throws IOException 

Source Link

Document

does NOT escape character data in val; it must already be valid XML.

Usage

From source file:org.alfresco.solr.AlfrescoSolrUtils.java

License:Open Source License

/**
 * Generates an <add><doc>... XML String with options
 * on the add.//  ww w .j av  a  2s  .  co  m
 *
 * @param doc the Document to add
 * @param args 0th and Even numbered args are param names, Odds are param values.
 * @see #add
 */
public static String add(XmlDoc doc, String... args) {
    try {
        StringWriter r = new StringWriter();
        // this is annoying
        if (null == args || 0 == args.length) {
            r.write("<add>");
            r.write(doc.xml);
            r.write("</add>");
        } else {
            XML.writeUnescapedXML(r, "add", doc.xml, (Object[]) args);
        }
        return r.getBuffer().toString();
    } catch (IOException e) {
        throw new RuntimeException("this should never happen with a StringWriter", e);
    }
}