Coverage Report - net.fckeditor.FCKeditorConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
FCKeditorConfig
18%
3/16
0%
0/6
5
 
 1  
 /*
 2  
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 3  
  * Copyright (C) 2004-2010 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  
 package net.fckeditor;
 22  
 
 23  
 import java.io.UnsupportedEncodingException;
 24  
 import java.net.URLEncoder;
 25  
 import java.util.HashMap;
 26  
 import java.util.Map;
 27  
 
 28  
 import net.fckeditor.tool.Utils;
 29  
 
 30  
 import org.slf4j.Logger;
 31  
 import org.slf4j.LoggerFactory;
 32  
 
 33  
 /**
 34  
  * Java representation of the <a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options"
 35  
  * target="_blank">FCKConfig</a> object from the editor. Every FCKeditor
 36  
  * instance will load the <code>config.js</code> by default, if you assign a
 37  
  * FCKConfig instance to an editor, it will automatically override these
 38  
  * system-wide settings for the current instance only.
 39  
  * 
 40  
  * @version $Id: FCKeditorConfig.java 4785 2009-12-21 20:10:28Z mosipov $
 41  
  */
 42  6
 public class FCKeditorConfig extends HashMap<String, String> {
 43  
 
 44  
         private static final long serialVersionUID = -4831190504944866644L;
 45  1
         private static final Logger logger = LoggerFactory
 46  1
                         .getLogger(FCKeditorConfig.class);
 47  
 
 48  
         /**
 49  
          * Generates the URL parameter sequence for this configuration.
 50  
          * 
 51  
          * @return HTML-encoded sequence of configuration parameters
 52  
          */
 53  
         public String getUrlParams() {
 54  0
                 StringBuffer osParams = new StringBuffer();
 55  
                 try {
 56  0
                         for (Map.Entry<String, String> entry : this.entrySet()) {
 57  0
                                 if (Utils.isNotEmpty(entry.getValue())) {
 58  0
                                         osParams.append("&amp;");
 59  0
                                         osParams.append(entry.getKey());
 60  0
                                         osParams.append("=");
 61  0
                                         osParams.append(URLEncoder
 62  
                                                         .encode(entry.getValue(), "UTF-8"));
 63  
                                 }
 64  
                         }
 65  
 
 66  0
                 } catch (UnsupportedEncodingException e) {
 67  0
                         logger.error("Configuration parameters could not be encoded", e);
 68  0
                 }
 69  
 
 70  0
                 if (osParams.length() > 0)
 71  0
                         osParams.delete(0, 5);
 72  0
                 return osParams.toString();
 73  
         }
 74  
 }