Inspector | Message | Severity | Location |
---|---|---|---|
Java Inspector 031 | Switch statement case without 'break' | 1 | 69:25 |
Java Inspector 048 | Copyrights information should be present in each file. | 1 | |
Java Inspector 062 | Unnecessary cast or instanceof. | 2 | 70:50 |
Java Inspector 073 [java.lang.StringBuffer] | In Java 5 use StringBuilder instead of StringBuffer if access is single-threaded, e.g. StringBuffer is used as a local variable . | 2 | 43:17 |
Java Inspector 082 | Parenthesis are redundant. | 2 | 70:49 |
Java Inspector 089 | Method documentation is too short. It is only 2 words. Should be at least 3 words. | 2 | 38:9 |
Java Inspector 089 | Undocumented parameter txt | 2 | 38:9 |
Java Inspector 089 | Javadoc contains tag for non-existent parameter tkn | 2 | 38:9 |
Java Inspector 089 | Method return value is not properly documented | 2 | 38:9 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 47:30 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 50:30 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 53:30 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 54:57 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 60:30 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 63:30 |
Java Inspector 024 | Avoid hardwired character literals | 3 | 66:30 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 48:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 51:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 57:52 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 61:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 64:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 67:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 70:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 70:66 |
1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.util;
24
25
26/**
27 * Helper class to render ${...} sequence in Velocity and
28 * encode URL's.
29 * @author Pavel
30 */
31public class Escaper {
32
33 /**
34 * Escapes HTML
35 * @param tkn
36 * @return
37 */
38 public static String escapeHtml(String txt) {
39 if (txt==null) {
40 return null;
41 }
42
43 StringBuffer ret = new StringBuffer();
44 char[] chars=txt.toCharArray();
45 for (int i=0; i<chars.length; ++i) {
46 switch (chars[i]) {
47 case '<':
48 ret.append("<");
49 break;
50 case '>':
51 ret.append(">");
52 break;
53 case '&':
54 if (i<chars.length-1 && '#'==chars[i+1]) { // Do not double-escape (&#...;)
55 ret.append(chars[i]);
56 } else {
57 ret.append("&");
58 }
59 break;
60 case '\'':
61 ret.append("'");
62 break;
63 case '\\':
64 ret.append("\");
65 break;
66 case '\"':
67 ret.append(""");
68 break;
69 default:
70 ret.append("&#"+((int) chars[i])+";");
71 }
72 }
73 return ret.toString();
74 }
75
76}
77