Java HTML Escape escapeHTMLLine(String line)

Here you can find the source of escapeHTMLLine(String line)

Description

escape HTML Line

License

Open Source License

Declaration

public static String escapeHTMLLine(String line) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;
import java.util.Iterator;

public class Main {
    static HashMap escapeList = null;

    public static String escapeHTMLLine(String line) {
        if (escapeList == null) {
            init();/*from ww  w  . ja v a  2 s.  com*/
        }

        String key;
        for (Iterator var2 = escapeList.keySet().iterator(); var2
                .hasNext(); line = line.replace(key, (String) escapeList.get(key))) {
            key = (String) var2.next();
        }

        return line;
    }

    static void init() {
        escapeList = new HashMap();
        escapeList.put(" ", " ");
        escapeList.put(""", "\"");
        escapeList.put("&", "&");
        escapeList.put("&lt;", "<");
        escapeList.put("&gt;", ">");
        escapeList.put("&iexcl;", "!");
        escapeList.put("&copy;", "(c)");
        escapeList.put("&reg;", "(R)");
    }
}

Related

  1. escapeHTML(String s)
  2. escapeHTML(String s)
  3. escapeHtml(String s)
  4. escapeHTML(String text)
  5. escapeHTML(String text)
  6. escapeHTMLSpecialChars(String aText)
  7. escapeHTMLTagCopy(String text)
  8. htmlEscape(final String text)
  9. htmlEscape(Object obj)