Here you can find the source of escape(final String value)
Parameter | Description |
---|---|
value | the value to escape |
public static String escape(final String value)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Main { public static final Map<String, String> ESCAPES = new HashMap<String, String>(); /**/*from w w w. j a va2 s . c o m*/ * Escape a value when writing XML. * * Replaces each character in the ESCAPES map with its escaped value. * * This method should only be used when generating xml manually, since most * xml writers escape automatically. * * @param value * the value to escape * @return the escaped value. */ public static String escape(final String value) { String escapedValue = value; // replace each escapeable character Iterator<String> iter = ESCAPES.keySet().iterator(); while (iter.hasNext()) { String raw = iter.next(); String escaped = ESCAPES.get(raw); escapedValue = escapedValue.replace(raw, escaped); } return escapedValue; } }