1 2 23 24 package net.fenyo.gnetwatch.data; 25 26 import net.fenyo.gnetwatch.*; 27 import net.fenyo.gnetwatch.targets.*; 28 29 import java.util.*; 30 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 34 40 41 public class EventHTTPPages extends EventGeneric { 42 private static Log log = LogFactory.getLog(EventHTTPPages.class); 43 44 private final long pages_received; 45 46 private long cache_operand_1 = 0; 47 private long cache_operand_2 = 0; 48 private int cache_result = 0; 49 50 54 public EventHTTPPages(final long pages_received) { 56 this.pages_received = pages_received; 57 } 58 59 65 public int getIntValue(final java.util.List <EventGeneric> events, final int idx) { 66 if (idx == 0) return 0; 67 68 final EventHTTPPages prev_event = (EventHTTPPages) events.get(idx - 1); 69 70 if (getDate().getTime() - prev_event.getDate().getTime() == 0) 71 return 0; 72 73 if (getPagesReceived() == cache_operand_1 && 74 getDate().getTime() - prev_event.getDate().getTime() == cache_operand_2) { 75 return cache_result; 76 } 77 78 final int ret = (int) (1000 * (double) getPagesReceived() / 80 (getDate().getTime() - prev_event.getDate().getTime())); 81 82 cache_operand_1 = getPagesReceived(); 83 cache_operand_2 = getDate().getTime() - prev_event.getDate().getTime(); 84 cache_result = ret; 85 86 return ret; 87 } 88 89 94 public long getPagesReceived() { 96 return pages_received; 97 } 98 } 99 | Popular Tags |