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 35 public class RequestURIModule extends AbstractInputModule implements ThreadSafe { 36 37 final static Vector returnNames; 38 static { 39 Vector tmp = new Vector (); 40 tmp.add("requestURI"); 41 returnNames = tmp; 42 } 43 44 public Object getAttribute( String name, Configuration modeConf, Map objectModel ) throws ConfigurationException { 45 46 String uri = ObjectModelHelper.getRequest(objectModel).getSitemapURI(); 47 48 if (uri.startsWith("/")) { 49 uri = uri.substring(1); 50 } 51 52 return uri; 53 } 54 55 56 public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws ConfigurationException { 57 58 return RequestURIModule.returnNames.iterator(); 59 } 60 61 62 public Object [] getAttributeValues( String name, Configuration modeConf, Map objectModel ) 63 throws ConfigurationException { 64 65 Object values = new Object [1]; 66 values = this.getAttribute(name, modeConf, objectModel); 67 68 return (values == null? null : new Object []{values}); 69 } 70 71 } 72 | Popular Tags |