Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 73236 invoked from network); 3 Oct 2002 07:52:50 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 Oct 2002 07:52:50 -0000 Received: (qmail 24233 invoked by uid 97); 3 Oct 2002 07:53:40 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 24155 invoked by uid 97); 3 Oct 2002 07:53:38 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 24138 invoked by uid 97); 3 Oct 2002 07:53:38 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 3 Oct 2002 07:52:37 -0000 Message-ID: <20021003075237.69950.qmail@icarus.apache.org> From: jstrachan@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jstrachan 2002/10/03 00:52:37 Modified: jelly/src/test/org/apache/commons/jelly suite.jelly jelly/src/java/org/apache/commons/jelly/tags/core CoreTagLibrary.java jelly/src/java/org/apache/commons/jelly JellyContext.java Added: jelly/src/java/org/apache/commons/jelly/tags/core ScopeTag.java RemoveTag.java Log: Added a tag to remove variables as well as a tag which creates a new variable scope for its body. So the following can be performed... Many thanks to Jason Horman for the idea. Revision Changes Path 1.6 +77 -51 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/suite.jelly Index: suite.jelly =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/suite.jelly,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- suite.jelly 2 Oct 2002 16:55:04 -0000 1.5 +++ suite.jelly 3 Oct 2002 07:52:37 -0000 1.6 @@ -4,65 +4,91 @@ xmlns:test="jelly:junit" xmlns:log="jelly:log"> - + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - this should always work - - - This should never fail - - - This should never fail - - - - - - This should never fail - - - this should always work - - - This should never fail - - - - - - - This should never fail - - - This should never fail - - - this should always work - - + + + + + this should always work + + + This should never fail + + + This should never fail + + + + + + This should never fail + + + this should always work + + + This should never fail + + + + + + + This should never fail + + + This should never fail + + + this should always work + + - - - - - - - this should always work - - + - + + + + + this should always work + + + + - - This should never fail - + + This should never fail + 1.18 +9 -5 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java Index: CoreTagLibrary.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- CoreTagLibrary.java 30 Sep 2002 17:40:16 -0000 1.17 +++ CoreTagLibrary.java 3 Oct 2002 07:52:37 -0000 1.18 @@ -87,11 +87,14 @@ registerTag("catch", CatchTag.class); registerTag("forEach", ForEachTag.class); registerTag("set", SetTag.class); + registerTag("remove", RemoveTag.class); + // conditional tags registerTag("if", IfTag.class); registerTag("choose", ChooseTag.class); registerTag("when", WhenTag.class); registerTag("otherwise", OtherwiseTag.class); + // other tags registerTag("include", IncludeTag.class); registerTag("import", ImportTag.class); @@ -105,6 +108,7 @@ registerTag("whitespace", WhitespaceTag.class); registerTag("thread", ThreadTag.class); registerTag("file", FileTag.class); + registerTag("scope", ScopeTag.class); } } 1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ScopeTag.java Index: ScopeTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ScopeTag.java,v 1.5 2002/05/17 15:18:08 jstrachan Exp $ * $Revision: 1.5 $ * $Date: 2002/05/17 15:18:08 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * * $Id: ScopeTag.java,v 1.5 2002/05/17 15:18:08 jstrachan Exp $ */ package org.apache.commons.jelly.tags.core; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A tag which creates a new child variable scope for its body. * So any variables defined within its body will no longer be in scope * after this tag. * * @author James Strachan * @version $Revision: 1.5 $ */ public class ScopeTag extends TagSupport { // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws Exception { JellyContext newContext = context.newJellyContext(); getBody().run(newContext, output); } } 1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java Index: RemoveTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java,v 1.5 2002/05/17 15:18:08 jstrachan Exp $ * $Revision: 1.5 $ * $Date: 2002/05/17 15:18:08 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * * $Id: RemoveTag.java,v 1.5 2002/05/17 15:18:08 jstrachan Exp $ */ package org.apache.commons.jelly.tags.core; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A tag which removes the variable of the given name from the current variable scope. * * @author James Strachan * @version $Revision: 1.5 $ */ public class RemoveTag extends TagSupport { private String var; public RemoveTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws Exception { if (var != null) { context.removeVariable(var); } else { throw new MissingAttributeException("var"); } } // Properties //------------------------------------------------------------------------- /** * Sets the name of the variable which will be removed by this tag.. */ public void setVar(String var) { this.var = var; } } 1.29 +8 -0 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java Index: JellyContext.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- JellyContext.java 27 Sep 2002 14:20:13 -0000 1.28 +++ JellyContext.java 3 Oct 2002 07:52:37 -0000 1.29 @@ -325,6 +325,14 @@ return answer; } + /** + * A factory method to create a new child context of the + * current context. + */ + public JellyContext newJellyContext() { + return createChildContext(); + } + /** Registers the given tag library against the given namespace URI. * This should be called before the parser is used. */ -- To unsubscribe, e-mail: For additional commands, e-mail: