Java String Unescape unescapeText(String s)

Here you can find the source of unescapeText(String s)

Description

Unescapes character sequences such as '<', '&' etc.

License

Open Source License

Declaration

public static String unescapeText(String s) 

Method Source Code

//package com.java2s;
/*//from  w  w  w .  j  av  a  2 s .c  om
 * GWT Portlets Framework (http://code.google.com/p/gwtportlets/)
 * Copyright 2009 Business Systems Group (Africa)
 *
 * This file is part of GWT Portlets.
 *
 * GWT Portlets is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GWT Portlets is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with GWT Portlets.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static final String quote = "&quot;";
    public static final String amp = "&amp;";
    public static final String gt = "&gt;";
    public static final String lt = "&lt;";

    /**
     * Unescapes character sequences such as '&amp;lt;', '&amp;amp;' etc. to '<', '&' etc
     * Note: An argument such as '&amp;amp;lt;' will result in '&amp;lt;'
     */
    public static String unescapeText(String s) {
        if (s == null) {
            return null;
        }
        return s.replace(lt, "<").replace(gt, ">").replace(quote, "\"")
                .replace(amp, "&");
    }
}

Related

  1. unescapeString(String text)
  2. unescapeString(String txt)
  3. unescapeText(String s)
  4. unescapeText(String s)
  5. unescapeText(String s)