Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*     */ package org.jboss.util;
  /*     */ 
  /*     */ import java.io.Serializable;
  /*     */ 
  /*     */ public class StopWatch
  /*     */   implements SerializableCloneable
  /*     */ {
  /*  36 */   protected long total = 0L;
  /*     */ 
 /*  39 */   protected long start = -1L;
 /*     */ 
 /*  42 */   protected long stop = -1L;
 /*     */ 
 /*  45 */   protected int count = 0;
 /*     */ 
 /*  48 */   protected boolean running = false;
 /*     */ 
 /*     */   public StopWatch()
 /*     */   {
 /*     */   }
 /*     */ 
 /*     */   public StopWatch(boolean running)
 /*     */   {
 /*  62 */     if (runningstart();
 /*     */   }
 /*     */ 
 /*     */   public void start(boolean reset)
 /*     */   {
 /*  72 */     if (!this.) {
 /*  73 */       if (resetreset();
 /*  74 */       this. = System.currentTimeMillis();
 /*  75 */       this. = true;
 /*     */     }
 /*     */   }
 /*     */ 
 /*     */   public void start()
 /*     */   {
 /*  84 */     start(false);
 /*     */   }
 /*     */ 
 /*     */   public long stop()
 /*     */   {
 /*  94 */     long lap = 0L;
 /*     */ 
 /*  96 */     if (this.) {
 /*  97 */       this. += 1;
 /*  98 */       this. = System.currentTimeMillis();
 /*  99 */       lap = this. - this.;
 /* 100 */       this. += lap;
 /* 101 */       this. = false;
 /*     */     }
 /*     */ 
 /* 104 */     return lap;
 /*     */   }
 /*     */ 
 /*     */   public void reset()
 /*     */   {
 /* 112 */     this. = -1L;
 /* 113 */     this. = -1L;
 /* 114 */     this. = 0L;
 /* 115 */     this. = 0;
 /* 116 */     this. = false;
 /*     */   }
 /*     */ 
 /*     */   public int getLapCount()
 /*     */   {
 /* 126 */     return this.;
 /*     */   }
 /*     */ 
 /*     */   public long getLapTime()
 /*     */   {
 /* 136 */     if (this. == -1L) {
 /* 137 */       return 0L;
 /*     */     }
 /* 139 */     if (this.) {
 /* 140 */       return System.currentTimeMillis() - this.;
 /*     */     }
 /*     */ 
 /* 143 */     return this. - this.;
 /*     */   }
 /*     */ 
 /*     */   public long getAverageLapTime()
 /*     */   {
 /* 154 */     return this. == 0 ? 0L : getLapTime() / getLapCount();
 /*     */   }
 /*     */ 
 /*     */   public long getTime()
 /*     */   {
 /* 164 */     if (this. == -1L) {
 /* 165 */       return 0L;
 /*     */     }
 /* 167 */     if (this.) {
 /* 168 */       return this. + System.currentTimeMillis() - this.;
 /*     */     }
 /*     */ 
 /* 171 */     return this.;
 /*     */   }
 /*     */ 
 /*     */   public boolean isRunning()
/*     */   {
/* 182 */     return this.;
/*     */   }
/*     */ 
/*     */   public String toString()
/*     */   {
/* 190 */     StringBuffer buff = new StringBuffer();
/*     */ 
/* 192 */     if (this.)
/*     */     {
/* 194 */       formatElapsedTime(buffgetTime());
/*     */ 
/* 197 */       if (this. >= 1) {
/* 198 */         buff.append(", count=").append(this.);
/* 199 */         buff.append(", current=");
/* 200 */         formatElapsedTime(buffgetLapTime());
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/* 205 */       formatElapsedTime(buffgetTime());
/*     */ 
/* 208 */       if (this. > 1) {
/* 209 */         buff.append(", count=").append(this.);
/* 210 */         buff.append(", average=");
/* 211 */         formatElapsedTime(buffgetAverageLapTime());
/*     */       }
/*     */     }
/*     */ 
/* 215 */     return buff.toString();
/*     */   }
/*     */ 
/*     */   private void formatElapsedTime(StringBuffer bufflong lapsed)
/*     */   {
/* 220 */     long m = lapsed / 60000L;
/* 221 */     if (m != 0L) {
/* 222 */       buff.append(m).append("m:");
/*     */     }
/*     */ 
/* 225 */     long s = (lapsed - 60000L * m) / 1000L;
/* 226 */     if (s != 0L) {
/* 227 */       buff.append(s).append("s:");
/*     */     }
/*     */ 
/* 231 */     long ms = lapsed - 60000L * m - 1000L * s;
/* 232 */     buff.append(ms).append("ms");
/*     */   }
/*     */ 
/*     */   public Object clone()
/*     */   {
/*     */     try
/*     */     {
/* 243 */       return super.clone();
/*     */     } catch (CloneNotSupportedException e) {
/*     */     }
/* 246 */     throw new InternalError();
/*     */   }
/*     */ 
/*     */   public static StopWatch makeSynchronized(StopWatch watch)
/*     */   {
/* 316 */     return new Wrapper(watch)
/*     */     {
/*     */       public synchronized void start(boolean reset) {
/* 319 */         this..start(reset);
/*     */       }
/*     */ 
/*     */       public synchronized void start() {
/* 323 */         this..start();
/*     */       }
/*     */ 
/*     */       public synchronized long stop() {
/* 327 */         return this..stop();
/*     */       }
/*     */ 
/*     */       public synchronized void reset() {
/* 331 */         this..reset();
/*     */       }
/*     */ 
/*     */       public synchronized long getLapTime() {
/* 335 */         return this..getLapTime();
/*     */       }
/*     */ 
/*     */       public synchronized long getAverageLapTime() {
/* 339 */         return this..getAverageLapTime();
/*     */       }
/*     */ 
/*     */       public synchronized int getLapCount() {
/* 343 */         return this..getLapCount();
/*     */       }
/*     */ 
/*     */       public synchronized long getTime() {
/* 347 */         return this..getTime();
/*     */       }
/*     */ 
/*     */       public synchronized boolean isRunning() {
/* 351 */         return this..isRunning();
/*     */       }
/*     */ 
/*     */       public synchronized String toString() {
/* 355 */         return this..toString();
/*     */       }
/*     */     };
/*     */   }
/*     */ 
/*     */   private static class Wrapper extends StopWatch
/*     */   {
/*     */     protected StopWatch watch;
/*     */ 
/*     */     public Wrapper(StopWatch watch)
/*     */     {
/* 264 */       this. = watch;
/*     */     }
/*     */ 
/*     */     public void start(boolean reset) {
/* 268 */       this..start(reset);
/*     */     }
/*     */ 
/*     */     public void start() {
/* 272 */       this..start();
/*     */     }
/*     */ 
/*     */     public long stop() {
/* 276 */       return this..stop();
/*     */     }
/*     */ 
/*     */     public void reset() {
/* 280 */       this..reset();
/*     */     }
/*     */ 
/*     */     public long getLapTime() {
/* 284 */       return this..getLapTime();
/*     */     }
/*     */ 
/*     */     public long getAverageLapTime() {
/* 288 */       return this..getAverageLapTime();
/*     */     }
/*     */ 
/*     */     public int getLapCount() {
/* 292 */       return this..getLapCount();
/*     */     }
/*     */ 
/*     */     public long getTime() {
/* 296 */       return this..getTime();
/*     */     }
/*     */ 
/*     */     public boolean isRunning() {
/* 300 */       return this..isRunning();
/*     */     }
/*     */ 
/*     */     public String toString() {
/* 304 */       return this..toString();
/*     */     }
/*     */   }
/*     */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/jboss-embedded-all.jar
 * Qualified Name:     org.jboss.util.StopWatch
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X