Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 93542 invoked by uid 500); 10 Jan 2002 16:11:10 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 93533 invoked by uid 500); 10 Jan 2002 16:11:10 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 10 Jan 2002 16:11:10 -0000 Message-ID: <20020110161110.52833.qmail@icarus.apache.org> From: vgritsenko@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/selection RequestAttributeSelector.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vgritsenko 02/01/10 08:11:10 Added: src/java/org/apache/cocoon/selection RequestAttributeSelector.java Log: Same as SessionAttrbuteSelector, but for request attributes Revision Changes Path 1.1 xml-cocoon2/src/java/org/apache/cocoon/selection/RequestAttributeSelector.java Index: RequestAttributeSelector.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.selection; 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.logger.AbstractLoggable; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; import java.util.Map; /** * This class generates source code to implement a selector that * matches a string against an arbitrary request attribute. * *

Global and local configuration

* * *
attribute-nameString identifying the request attribute.
* * @author Christian Haul * @author Sylvain Wallez * @author Vadim Gritsenko * @version CVS $Revision: 1.1 $ $Date: 2002/01/10 16:11:10 $ */ public class RequestAttributeSelector extends AbstractLoggable implements Configurable, ThreadSafe, Selector { protected String defaultName; public void configure(Configuration config) throws ConfigurationException { this.defaultName = config.getChild("attribute-name").getValue(null); } public boolean select(String expression, Map objectModel, Parameters parameters) { String name = parameters.getParameter("attribute-name", this.defaultName); if (name == null) { getLogger().warn("No attribute name given -- failing."); return false; } Object value = ObjectModelHelper.getRequest(objectModel).getAttribute(name); if (value == null) { getLogger().debug("Request attribute '" + name + "' not set -- failing."); return false; } return value.equals(expression); } } ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org