Here you can find the source of htmlEncoded(String text)
text
with html masked expressions.
Parameter | Description |
---|---|
text | a parameter |
public static String htmlEncoded(String text)
//package com.java2s; /*//w ww .ja v a 2 s .c o m * Util in org.jpws.front.util * file: Util.java * * Project Jpws-Front * @author Wolfgang Keller * Created 28.09.2004 * Version * * Copyright (c) 2005 by Wolfgang Keller, Munich, Germany * This program is not freeware software but copyright protected to the author(s) stated above. However, you can use, redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/gpl.html. */ public class Main { /** Substitutes conflicting characters in <code>text</code> with html * masked expressions. The returned string is displayable in html interpreting * components. * * @param text * @return */ public static String htmlEncoded(String text) { StringBuffer b; int i, len; char c; len = text.length(); b = new StringBuffer(len * 3); for (i = 0; i < len; i++) { c = text.charAt(i); switch (c) { case '<': b.append("<"); break; case '>': b.append(">"); break; case '&': b.append("&"); break; case '"': b.append("""); break; default: b.append(c); } } return b.toString(); } }