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 @Override 020 public void release() { 021 super.release(); 022 type=TYPE_DEBUG; 023 label=""; 024 } 025 026 /** 027 * @param label the label to set 028 */ 029 public void setLabel(String label) { 030 this.label = label; 031 } 032 033 /** 034 * @param type the type to set 035 * @throws ApplicationException 036 */ 037 public void setType(String strType) throws ApplicationException { 038 strType = strType.toLowerCase().trim(); 039 if("comment".equals(strType)) type=TYPE_COMMENT; 040 else if("debug".equals(strType)) type=TYPE_DEBUG; 041 else if("inline".equals(strType)) type=TYPE_INLINE; 042 else if("outline".equals(strType)) type=TYPE_OUTLINE; 043 else throw new ApplicationException("invalid value ["+strType+"] for attribute [type], valid values are [comment,debug,inline,outline]"); 044 } 045 046 @Override 047 public int doStartTag() { 048 time=System.currentTimeMillis(); 049 if(TYPE_OUTLINE==type) { 050 try { 051 pageContext.write("<fieldset class=\"cftimer\">