Here you can find the source of replaceEntities(final Map
Parameter | Description |
---|---|
replacements | The Map generated by the calculateEntityReplacements function |
xml | The XML string to modify |
private static String replaceEntities(final Map<String, String> replacements, final String xml)
//package com.java2s; import java.util.Map; public class Main { /**/* ww w . ja v a2 s .c om*/ * This function takes the Map generated by the calculateEntityReplacements function, and uses those values to replace any entities in the XML string with * their unique random integer replacements. The end results is an XML string that contains no entities, but contains identifiable strings that can be used * to replace those entities at a later point. * * @param replacements * The Map generated by the calculateEntityReplacements function * @param xml * The XML string to modify * @return The modified XML */ private static String replaceEntities(final Map<String, String> replacements, final String xml) { String retValue = xml; for (final String entity : replacements.keySet()) retValue = retValue.replaceAll("\\&" + entity + ";", replacements.get(entity)); return retValue; } }