1 16 17 package org.apache.cocoon.components.modules.input; 18 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.thread.ThreadSafe; 22 import org.apache.cocoon.environment.ObjectModelHelper; 23 24 import java.util.Iterator ; 25 import java.util.Map ; 26 import java.util.Vector ; 27 28 44 public class RawRequestParameterModule extends AbstractInputModule implements ThreadSafe { 45 46 public Object getAttribute( String name, Configuration modeConf, Map objectModel ) throws ConfigurationException { 47 48 String pname = (String ) this.settings.get("parameter",name); 49 if ( modeConf != null ) { 50 pname = modeConf.getAttribute( "parameter", pname ); 51 pname = modeConf.getChild("parameter").getValue(pname); 53 } 54 Object obj = ObjectModelHelper.getRequest(objectModel).get( pname ); 55 if (obj instanceof Vector ) { 56 return ((Vector ) obj).firstElement(); 57 } else { 58 return obj; 59 } 60 61 } 62 63 64 public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws ConfigurationException { 65 66 return new IteratorHelper(ObjectModelHelper.getRequest(objectModel).getParameterNames()); 67 } 68 69 70 public Object [] getAttributeValues( String name, Configuration modeConf, Map objectModel ) 71 throws ConfigurationException { 72 73 Object obj = getAttribute(name, modeConf, objectModel); 74 if (obj instanceof Vector ) { 75 return ((Vector )obj).toArray(); 76 } else if (obj.getClass().isArray()) { 77 return (Object []) obj; 78 } else { 79 Object [] tmp = new Object [1]; 80 tmp[0] = obj; 81 return tmp; 82 } 83 } 84 85 } 86 | Popular Tags |