001 package railo.runtime.tag; 002 003 import java.io.IOException; 004 005 import railo.runtime.exp.ApplicationException; 006 import railo.runtime.exp.PageException; 007 import railo.runtime.ext.tag.BodyTagImpl; 008 009 public final class Timer extends BodyTagImpl { 010 011 private static final int TYPE_DEBUG = 0; 012 private static final int TYPE_INLINE = 1; 013 private static final int TYPE_OUTLINE = 2; 014 private static final int TYPE_COMMENT = 3; 015 016 private String label=""; 017 private int type=TYPE_DEBUG; 018 private long time; 019 /** 020 * 021 * @see railo.runtime.ext.tag.BodyTagImpl#release() 022 */ 023 public void release() { 024 super.release(); 025 type=TYPE_DEBUG; 026 label=""; 027 } 028 029 /** 030 * @param label the label to set 031 */ 032 public void setLabel(String label) { 033 this.label = label; 034 } 035 036 /** 037 * @param type the type to set 038 * @throws ApplicationException 039 */ 040 public void setType(String strType) throws ApplicationException { 041 strType = strType.toLowerCase().trim(); 042 if("comment".equals(strType)) type=TYPE_COMMENT; 043 else if("debug".equals(strType)) type=TYPE_DEBUG; 044 else if("inline".equals(strType)) type=TYPE_INLINE; 045 else if("outline".equals(strType)) type=TYPE_OUTLINE; 046 else throw new ApplicationException("invalid value ["+strType+"] for attribute [type], valid values are [comment,debug,inline,outline]"); 047 } 048 049 /** 050 * 051 * @see railo.runtime.ext.tag.TagImpl#doStartTag() 052 */ 053 public int doStartTag() { 054 time=System.currentTimeMillis(); 055 if(TYPE_OUTLINE==type) { 056 try { 057 pageContext.write("<fieldset class=\"cftimer\">