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 EventBytesExchanged extends EventGeneric { 42 private static Log log = LogFactory.getLog(EventBytesExchanged.class); 43 44 private final long bytes_exchanged; 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 EventBytesExchanged(final long bytes_exchanged) { 56 this.bytes_exchanged = bytes_exchanged; 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 EventBytesExchanged prev_event = (EventBytesExchanged) events.get(idx - 1); 69 70 if (getDate().getTime() - prev_event.getDate().getTime() == 0) return 0; 71 72 if (getBytesExchanged() == cache_operand_1 && 73 getDate().getTime() - prev_event.getDate().getTime() == cache_operand_2) { 74 return cache_result; 75 } 76 77 final int ret = (int) (8 * 1000 * (double) getBytesExchanged() / 79 (getDate().getTime() - prev_event.getDate().getTime())); 80 81 cache_operand_1 = getBytesExchanged(); 82 cache_operand_2 = getDate().getTime() - prev_event.getDate().getTime(); 83 cache_result = ret; 84 85 return ret; 86 } 87 88 93 public long getBytesExchanged() { 95 return bytes_exchanged; 96 } 97 } 98 | Popular Tags |