Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FCKeditorConfig |
|
| 0.0;0 |
1 | /* | |
2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net | |
3 | * Copyright (C) 2003-2008 Frederico Caldeira Knabben | |
4 | * | |
5 | * == BEGIN LICENSE == | |
6 | * | |
7 | * Licensed under the terms of any of the following licenses at your | |
8 | * choice: | |
9 | * | |
10 | * - GNU General Public License Version 2 or later (the "GPL") | |
11 | * http://www.gnu.org/licenses/gpl.html | |
12 | * | |
13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") | |
14 | * http://www.gnu.org/licenses/lgpl.html | |
15 | * | |
16 | * - Mozilla Public License Version 1.1 or later (the "MPL") | |
17 | * http://www.mozilla.org/MPL/MPL-1.1.html | |
18 | * | |
19 | * == END LICENSE == | |
20 | */ | |
21 | ||
22 | package net.fckeditor; | |
23 | ||
24 | import java.io.UnsupportedEncodingException; | |
25 | import java.net.URLEncoder; | |
26 | import java.util.HashMap; | |
27 | import java.util.Map; | |
28 | ||
29 | import net.fckeditor.tool.Utils; | |
30 | ||
31 | import org.slf4j.Logger; | |
32 | import org.slf4j.LoggerFactory; | |
33 | ||
34 | /** | |
35 | * Contains the configuration settings for the FCKeditor.<br /> | |
36 | * By adding elements to this collection you can override the settings specified | |
37 | * in the config.js file. | |
38 | * | |
39 | * @version $Id: FCKeditorConfig.java 2151 2008-07-02 22:03:15Z mosipov $ | |
40 | */ | |
41 | public class FCKeditorConfig extends HashMap<String, String> { | |
42 | ||
43 | private static final long serialVersionUID = -4831190504944866644L; | |
44 | 0 | private final Logger logger = LoggerFactory.getLogger(FCKeditorConfig.class); |
45 | ||
46 | /** | |
47 | * Initialize the configuration collection | |
48 | */ | |
49 | public FCKeditorConfig( ) { | |
50 | 0 | super(); |
51 | 0 | } |
52 | ||
53 | /** | |
54 | * Generates the url parameter sequence from this configuration which is | |
55 | * passed to the editor. | |
56 | * | |
57 | * @return html encoded sequence of configuration parameters | |
58 | */ | |
59 | public String getUrlParams() { | |
60 | 0 | StringBuffer osParams = new StringBuffer(); |
61 | try { | |
62 | 0 | for (Map.Entry<String, String> entry : this.entrySet()) { |
63 | 0 | if (Utils.isNotEmpty(entry.getValue())) { |
64 | 0 | osParams.append("&"); |
65 | 0 | osParams.append(URLEncoder.encode(entry.getKey(),"UTF-8")); |
66 | 0 | osParams.append("="); |
67 | 0 | osParams.append(URLEncoder.encode(entry.getValue(),"UTF-8")); |
68 | } | |
69 | } | |
70 | ||
71 | 0 | } catch (UnsupportedEncodingException e) { |
72 | 0 | logger.error("Configuration parameters could not be encoded", e); |
73 | 0 | } |
74 | ||
75 | 0 | if (osParams.length() > 0) |
76 | 0 | osParams.deleteCharAt(0); |
77 | 0 | return osParams.toString(); |
78 | } | |
79 | } |