Clover coverage report -
Coverage timestamp: Sa Jul 7 2007 09:11:40 CEST
file stats: LOC: 60   Methods: 2
NCLOC: 17   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UseCachedTag.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Copyright (c) 2002-2003 by OpenSymphony
 3    * All rights reserved.
 4    */
 5    package com.opensymphony.oscache.web.tag;
 6   
 7    import javax.servlet.jsp.JspTagException;
 8    import javax.servlet.jsp.tagext.TagSupport;
 9   
 10    /**
 11    * UseCachedTag is a tag that tells a &lt;cache&gt; tag to reuse the cached body.<p>
 12    *
 13    * Usage Example:
 14    * <pre><code>
 15    * &lt;%@ taglib uri="oscache" prefix="cache" %&gt;
 16    * &lt;cache:cache key="mycache" scope="application"&gt;
 17    * if (reuse cached)
 18    * &lt;cache:usecached /&gt;
 19    * else
 20    * some other logic
 21    * &lt;/cache:cache&gt;
 22    * </code></pre>
 23    *
 24    * Note this is very useful with try / catch blocks
 25    * so that you can still produce old cached data if an
 26    * exception occurs, eg your database goes down.<p>
 27    *
 28    * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
 29    * @version $Revision: 254 $
 30    */
 31    public class UseCachedTag extends TagSupport {
 32    boolean use = true;
 33   
 34    /**
 35    * Set the decision to use the body content of the ancestor &lt;cache&gt; or not.
 36    *
 37    * @param value Whether or not to use the body content. Default is true.
 38    */
 39  0 public void setUse(boolean value) {
 40  0 this.use = value;
 41    }
 42   
 43    /**
 44    * The start tag.
 45    *
 46    * @throws JspTagException The standard tag exception thrown.
 47    * @return The standard Tag return.
 48    */
 49  0 public int doStartTag() throws JspTagException {
 50  0 CacheTag cacheTag = (CacheTag) TagSupport.findAncestorWithClass(this, CacheTag.class);
 51   
 52  0 if (cacheTag == null) {
 53  0 throw new JspTagException("A UseCached tag must be nested within a Cache tag");
 54    }
 55   
 56  0 cacheTag.setUseBody(!use);
 57   
 58  0 return SKIP_BODY;
 59    }
 60    }