encode characters. {@literal "\n" -> "&nl;" "\r" -> "&cr;" "\f" -> "&lf;" ":" -> ":" "|" -> "&pipe;" "[" -> "&lbracket;" "]" -> "&rbracket;" "&" -> "&" } author: Thomas Behr 09-09-02 @param s the String to encode @return the encoded String
(String s)
| 142 | * @return the encoded String |
| 143 | */ |
| 144 | public static String encode(String s) |
| 145 | { |
| 146 | final StringBuilder buffer = new StringBuilder(); |
| 147 | if (s != null) |
| 148 | { |
| 149 | final StringTokenizer tokens = new StringTokenizer(s, ENCODE, true); |
| 150 | |
| 151 | while (tokens.hasMoreTokens()) |
| 152 | { |
| 153 | buffer.append(ENTITIES.get(tokens.nextToken())); |
| 154 | } |
| 155 | } |
| 156 | return buffer.toString(); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Encode the characters. |
no test coverage detected