1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.wml; |
16 |
| |
17 |
| import org.apache.tapestry.util.text.AsciiCharacterMatcher; |
18 |
| import org.apache.tapestry.util.text.AsciiCharacterTranslator; |
19 |
| import org.apache.tapestry.util.text.ICharacterMatcher; |
20 |
| import org.apache.tapestry.util.text.ICharacterTranslator; |
21 |
| import org.apache.tapestry.util.text.ICharacterTranslatorSource; |
22 |
| import org.apache.tapestry.util.text.MarkupCharacterTranslator; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class WMLCharacterTranslatorSource implements ICharacterTranslatorSource |
34 |
| { |
35 |
| private static final String SAFE_CHARACTERS = |
36 |
| "01234567890" |
37 |
| + "abcdefghijklmnopqrstuvwxyz" |
38 |
| + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
39 |
| + "\t\n\r !\"#%'()*+,-./:;=?@[\\]^_`{|}~"; |
40 |
| |
41 |
| private static final String[][] ENTITIES = { |
42 |
| { "\"", """ }, |
43 |
| { "<", "<" }, |
44 |
| { ">", ">" }, |
45 |
| { "&", "&" }, |
46 |
| { "$", "$$" } |
47 |
| }; |
48 |
| |
49 |
| private static final ICharacterMatcher SAFE_MATCHER = new AsciiCharacterMatcher(SAFE_CHARACTERS); |
50 |
| private static final ICharacterTranslator ENTITY_TRANSLATOR = new AsciiCharacterTranslator(ENTITIES); |
51 |
| |
52 |
| private static final ICharacterTranslator WML_TRANSLATOR = new MarkupCharacterTranslator(true, SAFE_MATCHER, ENTITY_TRANSLATOR); |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
39
| public ICharacterTranslator getDefaultTranslator() {
|
58 |
39
| return WML_TRANSLATOR;
|
59 |
| } |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
0
| public ICharacterTranslator getTranslator(String encoding) {
|
65 |
0
| return getDefaultTranslator();
|
66 |
| } |
67 |
| } |