001 package railo.runtime.tag; 002 003 import railo.commons.io.SystemUtil; 004 import railo.runtime.exp.ExpressionException; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.ext.tag.TagImpl; 007 008 /** 009 * Pauses the execution of the page for a given interval 010 * 011 * 012 * 013 **/ 014 public final class Sleep extends TagImpl { 015 016 /** Expressed in milli seconds. */ 017 private long time; 018 019 /** 020 * @see javax.servlet.jsp.tagext.Tag#release() 021 */ 022 public void release() { 023 super.release(); 024 time=0; 025 } 026 027 /** set the value interval 028 * Expressed in milli seconds. 029 * @param time value to set 030 **/ 031 public void setTime(double time) { 032 this.time=(long)time; 033 } 034 035 036 /** 037 * @throws PageException 038 * @see javax.servlet.jsp.tagext.Tag#doStartTag() 039 */ 040 public int doStartTag() throws PageException { 041 if(time>=0) { 042 SystemUtil.sleep(time); 043 } 044 else throw new ExpressionException("attribute interval must be greater or equal to 0, now ["+(time)+"]"); 045 return SKIP_BODY; 046 } 047 048 /** 049 * @see javax.servlet.jsp.tagext.Tag#doEndTag() 050 */ 051 public int doEndTag() { 052 return EVAL_PAGE; 053 } 054 }