1 16 package org.apache.cocoon.components.modules.input; 17 18 import java.io.UnsupportedEncodingException ; 19 import java.util.Map ; 20 21 import org.apache.avalon.framework.configuration.Configuration; 22 import org.apache.avalon.framework.configuration.ConfigurationException; 23 import org.apache.avalon.framework.thread.ThreadSafe; 24 import org.apache.cocoon.util.NetUtils; 25 26 34 public final class URLEncodeModule extends AbstractInputModule 35 implements ThreadSafe { 36 37 public Object getAttribute(String name, 38 Configuration modeConf, 39 Map objectModel) throws ConfigurationException { 40 if (name == null) { 41 return null; 42 } 43 44 String encoding = (String ) this.settings.get("encoding", "utf-8"); 45 try { 46 return NetUtils.encode(name, encoding); 47 } catch (UnsupportedEncodingException e) { 48 throw new ConfigurationException("URLEncodeModule, invalid encoding: " + encoding); 49 } 50 } 51 } 52 | Popular Tags |