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            @Override
020            public void release()   {
021                    super.release();
022                    time=0;
023            }
024    
025            /** set the value interval
026            *  Expressed in milli seconds.
027            * @param time value to set
028            **/
029            public void setTime(double time)        {
030                    this.time=(long)time;
031            }
032    
033    
034            @Override
035            public int doStartTag() throws PageException    {
036                    if(time>=0) {
037                            SystemUtil.sleep(time);
038                    }
039                    else throw new ExpressionException("attribute interval must be greater or equal to 0, now ["+(time)+"]");
040                    return SKIP_BODY;
041            }
042    
043            @Override
044            public int doEndTag()   {
045                    return EVAL_PAGE;
046            }
047    }