Coverage Report - org.webmacro.engine.StringMacro
 
Classes in this File Line Coverage Branch Coverage Complexity
StringMacro
100%
8/8
N/A
1
 
 1  
 /*
 2  
  * Created on Mar 29, 2005
 3  
  *
 4  
  */
 5  
 package org.webmacro.engine;
 6  
 
 7  
 import java.io.IOException;
 8  
 
 9  
 import org.webmacro.Context;
 10  
 import org.webmacro.Macro;
 11  
 
 12  
 /**
 13  
  * @author Keats Kirsch
 14  
  *
 15  
  */
 16  
 public class StringMacro implements Macro
 17  
 {
 18  
 
 19  
    /**
 20  
     * 
 21  
     */
 22  
    //** Convenience class to evaluate a string template as a Macro *//
 23  14
    private String s = "";
 24  
 
 25  
    public StringMacro(String text)
 26  14
    {
 27  14
       s = text;
 28  14
    }
 29  
 
 30  
    /* (non-Javadoc)
 31  
     * @see org.webmacro.Macro#evaluate(org.webmacro.Context)
 32  
     */
 33  
    public Object evaluate(Context context)
 34  
       throws org.webmacro.PropertyException
 35  
    {
 36  11
       org.webmacro.engine.StringTemplate t =
 37  
          new org.webmacro.engine.StringTemplate(context.getBroker(), s);
 38  11
       return t.evaluateAsString(context);
 39  
    }
 40  
 
 41  
    /* (non-Javadoc)
 42  
     * @see org.webmacro.Macro#write(org.webmacro.FastWriter, org.webmacro.Context)
 43  
     */
 44  
    public void write(org.webmacro.FastWriter fw, Context context)
 45  
       throws org.webmacro.PropertyException, IOException
 46  
    {
 47  11
       fw.write((String) evaluate(context));
 48  11
    }
 49  
 }