1 16 package org.apache.cocoon.matching; 17 18 import org.apache.avalon.framework.configuration.Configurable; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.parameters.Parameters; 22 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 25 import java.util.Map ; 26 27 40 public class WildcardRequestAttributeMatcher extends AbstractWildcardMatcher 41 implements Configurable 42 { 43 private String defaultParam; 44 45 public void configure(Configuration config) throws ConfigurationException { 46 this.defaultParam = config.getChild("attribute-name").getValue(null); 47 if (getLogger().isDebugEnabled()) { 48 getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); 49 } 50 } 51 52 protected String getMatchString(Map objectModel, Parameters parameters) { 53 54 String paramName = parameters.getParameter("attribute-name", this.defaultParam); 55 if (paramName == null) { 56 getLogger().warn("No attribute name given. FAILING"); 57 return null; 58 } 59 60 Object result = ObjectModelHelper.getRequest(objectModel).getAttribute(paramName); 61 if (result == null) { 62 getLogger().debug("Request attribute '" + paramName + "' not set."); 63 return null; 64 } 65 66 return result.toString(); 67 } 68 } 69 | Popular Tags |