KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > util > HtmlUtils


1 package org.ashkelon.util;
2
3
4 import org.apache.oro.text.perl.Perl5Util;
5
6
7 /**
8  * @author Eitan Suez
9  */

10 public class HtmlUtils
11 {
12    /**
13     * makes text suitable for inclusion in a javascript string
14     * by escaping double quotes.
15     */

16    public static String JavaDoc cleanText(String JavaDoc text)
17    {
18       if (text == null) return "";
19       //return text.replaceAll("\"", "\\\\\"");
20
Perl5Util util = new Perl5Util();
21       String JavaDoc pattern = "s/\"/\\\"/g";
22       return util.substitute(pattern, text);
23    }
24
25    /**
26     * for tag attributes, double quotes are replaced with single quotes
27     */

28    public static String JavaDoc cleanAttributeText(String JavaDoc text)
29    {
30       if (text == null) return "";
31       //return text.replaceAll("\"","'");
32
Perl5Util util = new Perl5Util();
33       String JavaDoc pattern = "s/\"/'/g";
34       return util.substitute(pattern, text);
35    }
36    
37    /**
38     * removes html tags for tooltips as currently do not interpret them
39     */

40    public static String JavaDoc getBareText(String JavaDoc text)
41    {
42       //Perl5Util util = new Perl5Util();
43
//String pattern = "s/???/???/g";
44
//return util.substitute(pattern, text);
45
return text;
46    }
47    
48 }
49
Popular Tags