/**
 * @(#)file    HTMLCvt.java
 * @(#)author  chj
 * @(#)version 1.0
 * @(#)date    May 16, 2007
 * @(#)since   JDK 1.4.2
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 */
package com.udapsoft.waf.common.ui;

/**
 */
public class HTMLCvt {

	/**
	 * 
	 */
	public HTMLCvt() {

		super();
	}

    public static String cvtHTML(String str) {

        StringBuffer sb = new StringBuffer();

        int len = (str != null) ? str.length() : 0;
        for (int i = 0; i < len; i++) {
            char ch = str.charAt(i);
            switch (ch) {
            case ' ':
                    sb.append("&nbsp;");
                    break;
            case '<':
                    sb.append("&lt;");
                    break;
            case '>':
                    sb.append("&gt;");
                    break;
            case '&':
                    sb.append("&amp;");
                    break;
            case '"':
                    sb.append("&quot;");
                    break;
            case '\t':
                    sb.append("&nbsp;&nbsp;&nbsp;&nbsp;");
                    break;
            case '\n':
                    sb.append("<br>");
                    break;
            default:
                    sb.append(ch);
            }
        }
        return sb.toString();
    }
}