vgritsenko 02/01/11 17:14:34 Modified: src/java/org/apache/cocoon/matching RegexpHostMatcher.java RegexpTargetHostMatcher.java RegexpTargetHostMatcherFactory.java RegexpURIMatcher.java RegexpURIMatcherFactory.java RequestParamMatcher.java RequestParameterMatcher.java WildcardHeaderMatcher.java WildcardHeaderMatcherFactory.java WildcardParameterValueMatcher.java WildcardParameterValueMatcherFactory.java WildcardRequestParameterMatcher.java WildcardSessionAttributeMatcher.java WildcardSessionAttributeMatcherFactory.java WildcardURIMatcher.java WildcardURIMatcherFactory.java src/java/org/apache/cocoon/selection BrowserSelectorFactory.java HeaderSelectorFactory.java HostSelectorFactory.java ParameterSelectorFactory.java RequestAttributeSelector.java SessionAttributeSelector.java SessionAttributeSelectorFactory.java src/webapp sitemap.xmap Added: src/java/org/apache/cocoon/matching RegexpHeaderMatcher.java RegexpRequestAttributeMatcher.java RegexpRequestParameterMatcher.java RegexpSessionAttributeMatcher.java RequestAttributeMatcher.java SessionAttributeMatcher.java WildcardHostMatcher.java WildcardRequestAttributeMatcher.java Log: - tidy up matcher's and selector's javadoc and implementation (no more (String) casts) - add some matchers/selectors Revision Changes Path 1.2 +3 -3 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpHostMatcher.java Index: RegexpHostMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpHostMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RegexpHostMatcher.java 11 Jan 2002 17:07:05 -0000 1.1 +++ RegexpHostMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -18,10 +18,10 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/11 17:07:05 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ -public class RegexpHostMatcher extends AbstractRegexpMatcher { - +public class RegexpHostMatcher extends AbstractRegexpMatcher +{ protected String getMatchString(Map objectModel, Parameters parameters) { return ObjectModelHelper.getRequest(objectModel).getHeader("Host"); } 1.3 +4 -3 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcher.java Index: RegexpTargetHostMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RegexpTargetHostMatcher.java 11 Jan 2002 17:07:05 -0000 1.2 +++ RegexpTargetHostMatcher.java 12 Jan 2002 01:14:33 -0000 1.3 @@ -10,12 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:05 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/01/12 01:14:33 $ * @deprecated Renamed to RegexpHostMatcher */ -public class RegexpTargetHostMatcher extends RegexpHostMatcher implements Initializable { +public class RegexpTargetHostMatcher extends RegexpHostMatcher + implements Initializable +{ public void initialize() { getLogger().warn("RegexpTargetHostMatcher is deprecated. Please use RegexpHostMatcher"); 1.3 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java Index: RegexpTargetHostMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RegexpTargetHostMatcherFactory.java 11 Jan 2002 17:07:05 -0000 1.2 +++ RegexpTargetHostMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.3 @@ -10,12 +10,12 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:05 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by RegexpHostMatcher - code factories should no longer be used */ - -public class RegexpTargetHostMatcherFactory extends RegexpTargetHostMatcher implements Initializable { - +public class RegexpTargetHostMatcherFactory extends RegexpTargetHostMatcher + implements Initializable +{ public void initialize() { getLogger().warn("RegexpTargetHostMatcherFactory is deprecated. Please use RegexpHostMatcher"); } 1.2 +3 -4 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpURIMatcher.java Index: RegexpURIMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpURIMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RegexpURIMatcher.java 3 Jan 2002 12:31:17 -0000 1.1 +++ RegexpURIMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -26,11 +26,10 @@ * Matches the request URIs against a regular expression pattern. * * @authos <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ - -public class RegexpURIMatcher extends AbstractRegexpMatcher { - +public class RegexpURIMatcher extends AbstractRegexpMatcher +{ /** * Return the request URI. */ 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpURIMatcherFactory.java Index: RegexpURIMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpURIMatcherFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RegexpURIMatcherFactory.java 3 Jan 2002 12:31:17 -0000 1.1 +++ RegexpURIMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by RegexpURIMatcher - code factories should no longer be used */ - -public class RegexpURIMatcherFactory extends RegexpURIMatcher implements Initializable { - +public class RegexpURIMatcherFactory extends RegexpURIMatcher + implements Initializable +{ public void initialize() { getLogger().warn("RegexpURIMatcherFactory is deprecated. Please use RegexpURIMatcher"); } - } 1.3 +4 -3 xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParamMatcher.java Index: RequestParamMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParamMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RequestParamMatcher.java 11 Jan 2002 17:07:05 -0000 1.2 +++ RequestParamMatcher.java 12 Jan 2002 01:14:33 -0000 1.3 @@ -13,10 +13,11 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @deprecated Renamed to RequestParameterMatcher - * @version CVS $Revision: 1.2 $ + * @version CVS $Revision: 1.3 $ */ -public class RequestParamMatcher extends RequestParameterMatcher implements Loggable { - +public class RequestParamMatcher extends RequestParameterMatcher + implements Loggable +{ public void setLogger(Logger logger) { logger.warn("RequestParamMatcher is deprecated. Please use RequestParameterMatcher"); } 1.2 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParameterMatcher.java Index: RequestParameterMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/RequestParameterMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RequestParameterMatcher.java 11 Jan 2002 17:07:05 -0000 1.1 +++ RequestParameterMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -30,10 +30,10 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Revision: 1.1 $ + * @version CVS $Revision: 1.2 $ */ -public class RequestParameterMatcher implements Matcher, ThreadSafe { - +public class RequestParameterMatcher implements Matcher, ThreadSafe +{ /** * Match method to see if the request parameter exists. If it does * have a value the parameter is added to the array list for later 1.2 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java Index: WildcardHeaderMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardHeaderMatcher.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardHeaderMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -27,11 +27,11 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ - -public class WildcardHeaderMatcher extends AbstractWildcardMatcher implements Configurable { - +public class WildcardHeaderMatcher extends AbstractWildcardMatcher + implements Configurable +{ private String defaultParam; public void configure(Configuration config) throws ConfigurationException { 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java Index: WildcardHeaderMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardHeaderMatcherFactory.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardHeaderMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by WildcardHeaderMatcher - code factories should no longer be used */ - -public class WildcardHeaderMatcherFactory extends WildcardHeaderMatcher implements Initializable { - +public class WildcardHeaderMatcherFactory extends WildcardHeaderMatcher + implements Initializable +{ public void initialize() { getLogger().warn("WildcardHeaderMatcherFactory is deprecated. Please use WildcardHeaderMatcher"); } - } 1.3 +4 -3 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcher.java Index: WildcardParameterValueMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WildcardParameterValueMatcher.java 11 Jan 2002 17:07:06 -0000 1.2 +++ WildcardParameterValueMatcher.java 12 Jan 2002 01:14:33 -0000 1.3 @@ -12,10 +12,11 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @deprecated Renamed to WildcardRequestParameterMatcher - * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/01/12 01:14:33 $ */ -public class WildcardParameterValueMatcher extends WildcardRequestParameterMatcher implements Initializable { - +public class WildcardParameterValueMatcher extends WildcardRequestParameterMatcher + implements Initializable +{ public void initialize() { getLogger().warn("WildcardParameterValueMatcher is deprecated. Please use WildcardRequestParameterMatcher"); } 1.3 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java Index: WildcardParameterValueMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WildcardParameterValueMatcherFactory.java 11 Jan 2002 17:07:06 -0000 1.2 +++ WildcardParameterValueMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.3 @@ -10,12 +10,12 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.2 $ $Date: 2002/01/11 17:07:06 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by WildcardRequestParameterMatcher - code factories should no longer be used */ - -public class WildcardParameterValueMatcherFactory extends WildcardParameterValueMatcher implements Initializable { - +public class WildcardParameterValueMatcherFactory extends WildcardParameterValueMatcher + implements Initializable +{ public void initialize() { getLogger().warn("WildcardParameterValueMatcherFactory is deprecated. Please use WildcardRequestParameterMatcher"); } 1.2 +4 -3 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java Index: WildcardRequestParameterMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardRequestParameterMatcher.java 11 Jan 2002 17:07:06 -0000 1.1 +++ WildcardRequestParameterMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -28,10 +28,11 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/11 17:07:06 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ -public class WildcardRequestParameterMatcher extends AbstractWildcardMatcher implements Configurable { - +public class WildcardRequestParameterMatcher extends AbstractWildcardMatcher + implements Configurable +{ private String defaultParam; public void configure(Configuration config) throws ConfigurationException { 1.2 +7 -8 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java Index: WildcardSessionAttributeMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardSessionAttributeMatcher.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardSessionAttributeMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -26,19 +26,18 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ - -public class WildcardSessionAttributeMatcher - extends WildcardURIMatcher +public class WildcardSessionAttributeMatcher extends AbstractWildcardMatcher implements Configurable { - private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("attribute-name").getValue(null); - getLogger().debug("attribute-name is = '"+this.defaultParam+"'"); + if (getLogger().isDebugEnabled()) { + getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); + } } protected String getMatchString(Map objectModel, Parameters parameters) { @@ -49,11 +48,11 @@ return null; } - String result = (String)ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName); + Object result = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName); if (result == null) { getLogger().debug("Session attribute '" + paramName + "' not set."); } - return result; + return result.toString(); } } 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcherFactory.java Index: WildcardSessionAttributeMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcherFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardSessionAttributeMatcherFactory.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardSessionAttributeMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by WildcardSessionAttributeMatcher - code factories should no longer be used */ - -public class WildcardSessionAttributeMatcherFactory extends WildcardSessionAttributeMatcher implements Initializable { - +public class WildcardSessionAttributeMatcherFactory extends WildcardSessionAttributeMatcher + implements Initializable +{ public void initialize() { getLogger().warn("WildcardSessionAttributeMatcherFactory is deprecated. Please use WildcardSessionAttributeMatcher"); } - } 1.2 +4 -6 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardURIMatcher.java Index: WildcardURIMatcher.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardURIMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardURIMatcher.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardURIMatcher.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -17,16 +17,14 @@ import java.util.HashMap; import java.util.Map; - /** - * Match the request URI against a regular expression. + * Match the request URI against a wildcard expression. * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ */ - -public class WildcardURIMatcher extends AbstractWildcardMatcher { - +public class WildcardURIMatcher extends AbstractWildcardMatcher +{ /** * Return the request URI. */ 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardURIMatcherFactory.java Index: WildcardURIMatcherFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardURIMatcherFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardURIMatcherFactory.java 3 Jan 2002 12:31:17 -0000 1.1 +++ WildcardURIMatcherFactory.java 12 Jan 2002 01:14:33 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:17 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:33 $ * @deprecated replaced by WildcardURIMatcher - code factories should no longer be used */ - -public class WildcardURIMatcherFactory extends WildcardURIMatcher implements Initializable { - +public class WildcardURIMatcherFactory extends WildcardURIMatcher + implements Initializable +{ public void initialize() { getLogger().warn("WildcardURIMatcherFactory is deprecated. Please use WildcardURIMatcher"); } - } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java Index: RegexpHeaderMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches a request header (e.g. "referer") against a regular expression. * * <p><b>Global and local configuration</b></p> * <table border="1"> * <tr><td><code>header-name</code></td><td>Name of the request header to * match against</td></tr> * </table> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class RegexpHeaderMatcher extends AbstractRegexpMatcher implements Configurable { private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("header-name").getValue(null); } protected String getMatchString(Map objectModel, Parameters parameters) { String paramName = parameters.getParameter("header-name", this.defaultParam); if (paramName == null) { getLogger().warn("No header name given. FAILING"); return null; } String result = ObjectModelHelper.getRequest(objectModel).getHeader(paramName); if (result == null) { if (getLogger().isDebugEnabled()) { getLogger().debug("Header '" + paramName + "' not set."); } } return result; } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java Index: RegexpRequestAttributeMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches a request attribute against a regular expression. * * <p><b>Global and local configuration</b></p> * <tableborder="1"> * <tr><td><code>attribute-name</code></td><td>String identifying the request attribute</td></tr> * </table> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class RegexpRequestAttributeMatcher extends AbstractRegexpMatcher implements Configurable { private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("attribute-name").getValue(null); if (getLogger().isDebugEnabled()) { getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); } } protected String getMatchString(Map objectModel, Parameters parameters) { String paramName = parameters.getParameter("attribute-name", this.defaultParam); if (paramName == null) { getLogger().warn("No attribute name given. FAILING"); return null; } Object result = ObjectModelHelper.getRequest(objectModel).getAttribute(paramName); if (result == null) { getLogger().debug("Request attribute '" + paramName + "' not set."); } return result.toString(); } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java Index: RegexpRequestParameterMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches a request parameter against a regular expression. * * <p><b>Global and local configuration</b></p> * <table border="1"> * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to * match against</td></tr> * </table> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class RegexpRequestParameterMatcher extends AbstractRegexpMatcher implements Configurable { private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("parameter-name").getValue(null); } protected String getMatchString(Map objectModel, Parameters parameters) { String paramName = parameters.getParameter("parameter-name", this.defaultParam); if (paramName == null) { getLogger().warn("No parameter name given. FAILING"); return null; } String result = ObjectModelHelper.getRequest(objectModel).getParameter(paramName); if (result == null) { getLogger().debug("Parameter '" + paramName + "' not set."); } return result; } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java Index: RegexpSessionAttributeMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches a session attribute against a regular expression. * * <p><b>Global and local configuration</b></p> * <tableborder="1"> * <tr><td><code>attribute-name</code></td><td>String identifying the session attribute</td></tr> * </table> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class RegexpSessionAttributeMatcher extends AbstractRegexpMatcher implements Configurable { private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("attribute-name").getValue(null); if (getLogger().isDebugEnabled()) { getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); } } protected String getMatchString(Map objectModel, Parameters parameters) { String paramName = parameters.getParameter("attribute-name", this.defaultParam); if (paramName == null) { getLogger().warn("No attribute name given. FAILING"); return null; } Object result = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName); if (result == null) { getLogger().debug("Session attribute '" + paramName + "' not set."); } return result.toString(); } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/RequestAttributeMatcher.java Index: RequestAttributeMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.HashMap; import java.util.Map; /** * This class allows for matching based on a request attribute. * If the specified request attribute exists, its string representation * is retrieved for later xpath substitution. * * <p><b>Example:</b></p> * <pre> * <map:match type="request-attribute" pattern="next"> * <map:redirect-to src="{1}"/> * </map:match> * </pre> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ */ public class RequestAttributeMatcher implements Matcher, ThreadSafe { /** * Match method to see if the request attribute exists. If it does * have a value the string represenation of attribute is added to * the array list for later substitution with a xpath attribute. * * @param pattern name of request attribute to find * @param objectModel environment passed through via cocoon * @returns null or map containing value of request attribute 'pattern' */ public Map match(String pattern, Map objectModel, Parameters parameters) { Object attribute = ObjectModelHelper.getRequest(objectModel).getAttribute(pattern); if (attribute == null) { return null; } else { Map map = new HashMap(); map.put("1", attribute.toString()); return map; } } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/SessionAttributeMatcher.java Index: SessionAttributeMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.HashMap; import java.util.Map; /** * This class allows for matching based on a session attribute. * If the specified session attribute exists, its string representation * is retrieved for later xpath substitution. * * <p><b>Example:</b></p> * <pre> * <map:match type="session-attribute" pattern="style"> * <map:read src="{1}"/> * </map:match> * </pre> * * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ */ public class SessionAttributeMatcher implements Matcher, ThreadSafe { /** * Match method to see if the request attribute exists. If it does * have a value the string represenation of attribute is added to * the array list for later substitution with a xpath attribute. * * @param pattern name of session attribute to find * @param objectModel environment passed through via cocoon * @returns null or map containing value of session attribute 'pattern' */ public Map match(String pattern, Map objectModel, Parameters parameters) { Object attribute = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(pattern); if (attribute == null) { return null; } else { Map map = new HashMap(); map.put("1", attribute.toString()); return map; } } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardHostMatcher.java Index: WildcardHostMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches the target host ("Host" request header) against a wildcard expression. * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class WildcardHostMatcher extends AbstractWildcardMatcher { protected String getMatchString(Map objectModel, Parameters parameters) { return ObjectModelHelper.getRequest(objectModel).getHeader("Host"); } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java Index: WildcardRequestAttributeMatcher.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.matching; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.environment.ObjectModelHelper; import java.util.Map; /** * Matches a request attribute against a wildcard expression. * * <p><b>Global and local configuration</b></p> * <tableborder="1"> * <tr><td><code>attribute-name</code></td><td>String identifying the request attribute</td></tr> * </table> * * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/01/12 01:14:33 $ */ public class WildcardRequestAttributeMatcher extends AbstractWildcardMatcher implements Configurable { private String defaultParam; public void configure(Configuration config) throws ConfigurationException { this.defaultParam = config.getChild("attribute-name").getValue(null); if (getLogger().isDebugEnabled()) { getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); } } protected String getMatchString(Map objectModel, Parameters parameters) { String paramName = parameters.getParameter("attribute-name", this.defaultParam); if (paramName == null) { getLogger().warn("No attribute name given. FAILING"); return null; } Object result = ObjectModelHelper.getRequest(objectModel).getAttribute(paramName); if (result == null) { getLogger().debug("Request attribute '" + paramName + "' not set."); } return result.toString(); } } 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/selection/BrowserSelectorFactory.java Index: BrowserSelectorFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/BrowserSelectorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- BrowserSelectorFactory.java 3 Jan 2002 12:31:19 -0000 1.1 +++ BrowserSelectorFactory.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ * @deprecated replaced by BrowserSelector - code factories should no longer be used */ - -public class BrowserSelectorFactory extends BrowserSelector implements Initializable { - +public class BrowserSelectorFactory extends BrowserSelector + implements Initializable +{ public void initialize() { getLogger().warn("BrowserSelectorFactory is deprecated. Please use BrowserSelector"); } - } 1.2 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/selection/HeaderSelectorFactory.java Index: HeaderSelectorFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/HeaderSelectorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HeaderSelectorFactory.java 3 Jan 2002 12:31:19 -0000 1.1 +++ HeaderSelectorFactory.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -10,14 +10,14 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ * @deprecated replaced by HeaderSelector - code factories should no longer be used */ -public class HeaderSelectorFactory extends HeaderSelector implements Initializable { - +public class HeaderSelectorFactory extends HeaderSelector + implements Initializable +{ public void initialize() { getLogger().warn("HeaderSelectorFactory is deprecated. Please use HeaderSelector"); } - } 1.2 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/selection/HostSelectorFactory.java Index: HostSelectorFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/HostSelectorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HostSelectorFactory.java 3 Jan 2002 12:31:19 -0000 1.1 +++ HostSelectorFactory.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -10,7 +10,7 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ * @deprecated replaced by HostSelector - code factories should no longer be used */ @@ -19,5 +19,4 @@ public void initialize() { getLogger().warn("HostSelectorFactory is deprecated. Please use HostSelector"); } - } 1.2 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/selection/ParameterSelectorFactory.java Index: ParameterSelectorFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/ParameterSelectorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ParameterSelectorFactory.java 3 Jan 2002 12:31:19 -0000 1.1 +++ ParameterSelectorFactory.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -11,7 +11,7 @@ import org.apache.log.Logger; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ * @deprecated replaced by ParameterSelector - code factories should no longer be used */ @@ -20,5 +20,4 @@ public void setLogger(Logger logger) { logger.warn("ParameterSelectorFactory is deprecated. Please use ParameterSelector"); } - } 1.2 +3 -3 xml-cocoon2/src/java/org/apache/cocoon/selection/RequestAttributeSelector.java Index: RequestAttributeSelector.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/RequestAttributeSelector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RequestAttributeSelector.java 10 Jan 2002 16:11:10 -0000 1.1 +++ RequestAttributeSelector.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -20,8 +20,8 @@ import java.util.Map; /** - * This class generates source code to implement a selector that - * matches a string against an arbitrary request attribute. + * A <code>Selector</code> that matches a string against a configurable request + * attribute's string represenation. * * <p><b>Global and local configuration</b></p> * <table border="1"> @@ -31,7 +31,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/10 16:11:10 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ */ public class RequestAttributeSelector extends AbstractLoggable implements Configurable, ThreadSafe, Selector { 1.3 +3 -3 xml-cocoon2/src/java/org/apache/cocoon/selection/SessionAttributeSelector.java Index: SessionAttributeSelector.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/SessionAttributeSelector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SessionAttributeSelector.java 10 Jan 2002 16:08:52 -0000 1.2 +++ SessionAttributeSelector.java 12 Jan 2002 01:14:34 -0000 1.3 @@ -20,8 +20,8 @@ import java.util.Map; /** - * This class generates source code to implement a selector that - * matches a string against an arbitrary session attribute. + * A <code>Selector</code> that matches a string against a configurable session + * attribute's string represenation. * * <p><b>Global and local configuration</b></p> * <table border="1"> @@ -30,7 +30,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 16:08:52 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/01/12 01:14:34 $ */ public class SessionAttributeSelector extends AbstractLoggable implements Configurable, ThreadSafe, Selector { 1.2 +4 -5 xml-cocoon2/src/java/org/apache/cocoon/selection/SessionAttributeSelectorFactory.java Index: SessionAttributeSelectorFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/selection/SessionAttributeSelectorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SessionAttributeSelectorFactory.java 3 Jan 2002 12:31:19 -0000 1.1 +++ SessionAttributeSelectorFactory.java 12 Jan 2002 01:14:34 -0000 1.2 @@ -10,14 +10,13 @@ import org.apache.avalon.framework.activity.Initializable; /** - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:19 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/12 01:14:34 $ * @deprecated replaced by SessionAttributeSelector - code factories should no longer be used */ - -public class SessionAttributeSelectorFactory extends SessionAttributeSelector implements Initializable { - +public class SessionAttributeSelectorFactory extends SessionAttributeSelector + implements Initializable +{ public void initialize() { getLogger().warn("SessionAttributeSelectorFactory is deprecated. Please use SessionAttributeSelector"); } - } 1.10 +22 -4 xml-cocoon2/src/webapp/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/sitemap.xmap,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- sitemap.xmap 11 Jan 2002 17:07:06 -0000 1.9 +++ sitemap.xmap 12 Jan 2002 01:14:34 -0000 1.10 @@ -280,16 +280,34 @@ <browser name="netscape" useragent="Mozilla"/> </map:selector> - <map:selector name="parameter" logger="sitemap.selector.parameter" - src="org.apache.cocoon.selection.ParameterSelector"/> - <map:selector name="request-parameter" logger="sitemap.selector.request-parameter" src="org.apache.cocoon.selection.RequestParameterSelector"> <!-- Define now which request parameter to use; or do it later, when using this selector, via "parameter-name" parameter. <parameter-name>myparam</parameter-name> --> - <map:selector> + </map:selector> + + <map:selector name="request-attribute" logger="sitemap.selector.request-attribute" + src="org.apache.cocoon.selection.RequestAttributeSelector"> + <!-- <attribute-name>myparam</attribute-name> --> + </map:selector> + + <map:selector name="session-attribute" logger="sitemap.selector.session-attribute" + src="org.apache.cocoon.selection.SessionAttributeSelector"> + <!-- <attribute-name>myparam</attribute-name> --> + </map:selector> + + <map:selector name="parameter" logger="sitemap.selector.parameter" + src="org.apache.cocoon.selection.ParameterSelector"/> + + <map:selector name="header" logger="sitemap.selector.header" + src="org.apache.cocoon.selection.HeaderSelector"> + <!-- <header-name>myparam</header-name> --> + </map:selector> + + <map:selector name="host" logger="sitemap.selector.host" + src="org.apache.cocoon.selection.HostSelector"/> </map:selectors> <!--
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]