Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 95   Methods: 8
NCLOC: 50   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ScriptWriter.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 /*
 6   
  * Created on 2004/01/08
 7   
  */
 8   
 package org.asyrinx.brownie.tapestry.script;
 9   
 
 10   
 import java.util.HashMap;
 11   
 import java.util.Map;
 12   
 
 13   
 import org.apache.tapestry.ApplicationRuntimeException;
 14   
 import org.apache.tapestry.IComponent;
 15   
 import org.apache.tapestry.IRequestCycle;
 16   
 import org.apache.tapestry.IScript;
 17   
 import org.apache.tapestry.html.Body;
 18   
 
 19   
 /**
 20   
  * @author akima
 21   
  */
 22   
 public class ScriptWriter {
 23   
 
 24   
     /**
 25   
      *  
 26   
      */
 27  0
     public ScriptWriter(IScriptUser user, String scriptName) {
 28  0
         super();
 29  0
         this.user = user;
 30  0
         this.scriptName = scriptName;
 31   
     }
 32   
 
 33   
     private final IScriptUser user;
 34   
 
 35   
     private final String scriptName;
 36   
 
 37   
     private ScriptUsage usage = ScriptUsage.EVERYTIME;
 38   
 
 39  0
     public void checkBeforeWrite(IRequestCycle cycle) {
 40  0
         final Body body = Body.get(cycle);
 41  0
         if (body == null)
 42  0
             throw new ApplicationRuntimeException("must-be-contained-by-body",
 43   
                     this, null, null);
 44   
     }
 45   
 
 46  0
     public void execute(IRequestCycle cycle) {
 47  0
         checkBeforeWrite(cycle);
 48  0
         if (!this.usage.canWrite(this.user, cycle))
 49  0
             return;
 50  0
         final Map symbols = new HashMap();
 51  0
         user.prepareScriptSymbols(symbols, cycle);
 52  0
         final Body body = Body.get(cycle);
 53  0
         loadScript(this.user).execute(cycle, body, symbols);
 54   
     }
 55   
 
 56   
     private IScript script = null;
 57   
 
 58   
     /**
 59   
      * @return
 60   
      */
 61  0
     protected IScript loadScript(IComponent component) {
 62  0
         if (script == null)
 63  0
             script = ScriptUtils.loadScript(component, this.scriptName);
 64  0
         return script;
 65   
     }
 66   
 
 67   
     /**
 68   
      * @return
 69   
      */
 70  0
     public String getScriptName() {
 71  0
         return scriptName;
 72   
     }
 73   
 
 74   
     /**
 75   
      * @return
 76   
      */
 77  0
     public IScriptUser getUser() {
 78  0
         return user;
 79   
     }
 80   
 
 81   
     /**
 82   
      * @return
 83   
      */
 84  0
     public ScriptUsage getUsage() {
 85  0
         return usage;
 86   
     }
 87   
 
 88   
     /**
 89   
      * @param usage
 90   
      */
 91  0
     public void setUsage(ScriptUsage usage) {
 92  0
         this.usage = usage;
 93   
     }
 94   
 
 95   
 }