Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/MapUtils.java @ 6384:2987d81ea719
Further fix encoding handling in the print service
- Strings are now html escaped additionaly to java encoding
- Escaping / encoding moved into maputils
- The legend url is urlencoded
- Properties are no longer stored in an encoded manner but
rather encoded on demand
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 21 Jun 2013 12:15:30 +0200 |
parents | ea9eef426962 |
children | 890f708b18d6 |
comparison
equal
deleted
inserted
replaced
6383:e26655a8f98d | 6384:2987d81ea719 |
---|---|
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.shared; | 9 package org.dive4elements.river.client.shared; |
10 | 10 |
11 import java.util.Date; | 11 import java.util.Date; |
12 | |
13 import com.google.gwt.safehtml.shared.SafeHtmlUtils; | |
12 | 14 |
13 | 15 |
14 public class MapUtils { | 16 public class MapUtils { |
15 | 17 |
16 public static final String GET_LEGEND_GRAPHIC_TEMPLATE = | 18 public static final String GET_LEGEND_GRAPHIC_TEMPLATE = |
45 url+="&legend_options=dpi:" + dpi; | 47 url+="&legend_options=dpi:" + dpi; |
46 } | 48 } |
47 | 49 |
48 return url; | 50 return url; |
49 } | 51 } |
52 | |
53 public static String toSaveHTMLJavaString(String str) { | |
54 return str == null ? null : SafeHtmlUtils.htmlEscape(toJavaEncodedString(str)); | |
55 } | |
56 | |
57 public static String toJavaEncodedString(String str) { | |
58 if (str == null) { | |
59 return null; | |
60 } | |
61 StringBuilder sb = new StringBuilder(); | |
62 for (int i = 0, len = str.length(); i < len; i++) { | |
63 int unipoint = Character.codePointAt(str, i); | |
64 if ((unipoint < 32) || (unipoint > 127)) { | |
65 sb.append("\\u"); | |
66 sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf)); | |
67 sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf)); | |
68 sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf)); | |
69 sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf)); | |
70 } else { | |
71 sb.append(str.charAt(i)); | |
72 } | |
73 } | |
74 return sb.toString(); | |
75 } | |
50 } | 76 } |
51 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |