Apache Solr open-source search software
Adding a convenience method which passes attributes in a Map
Shalin Shekhar Mangar1ffed882a96f
diff --git a/src/common/org/apache/solr/common/util/XML.java b/src/common/org/apache/solr/common/util/XML.javaindex 36fef9468a7..2183311be0f 100644--- a/src/common/org/apache/solr/common/util/XML.java+++ b/src/common/org/apache/solr/common/util/XML.java@@ -19,6 +19,7 @@ package org.apache.solr.common.util;import java.io.Writer;import java.io.IOException;+import java.util.Map;/*** @version $Id$@@ -153,6 +154,31 @@ public class XML {}}+ /** escapes character data in val */+ public static void writeXML(Writer out, String tag, String val, Map<String, String> attrs) throws IOException {+ out.write('<');+ out.write(tag);+ for (Map.Entry<String, String> entry : attrs.entrySet()) {+ out.write(' ');+ out.write(entry.getKey());+ out.write('=');+ out.write('"');+ escapeAttributeValue(entry.getValue(), out);+ out.write('"');+ }+ if (val == null) {+ out.write('/');+ out.write('>');+ } else {+ out.write('>');+ escapeCharData(val,out);+ out.write('<');+ out.write('/');+ out.write(tag);+ out.write('>');+ }+ }+private static void escape(char [] chars, int offset, int length, Writer out, String [] escapes) throws IOException{for (int i=offset; i<length; i++) {char ch = chars[i];