1 18 package net.sf.drftpd.master; 19 20 24 public class GroupPosition implements Comparable { 25 long bytes; 26 int files; 27 String groupname; 28 long xfertime; 29 30 public GroupPosition( 31 String groupname, 32 long bytes, 33 int files, 34 long xfertime) { 35 this.groupname = groupname; 36 this.bytes = bytes; 37 this.files = files; 38 this.xfertime = xfertime; 39 } 40 41 public int compareTo(Object o) { 42 return compareTo((GroupPosition) o); 43 } 44 45 48 public int compareTo(GroupPosition o) { 49 long thisVal = getBytes(); 50 long anotherVal = o.getBytes(); 51 return (thisVal < anotherVal ? 1 : (thisVal == anotherVal ? 0 : -1)); 52 } 53 54 57 public boolean equals(Object obj) { 58 if (!(obj instanceof GroupPosition)) 60 return false; 61 GroupPosition other = (GroupPosition) obj; 62 return getGroupname().equals(other.getGroupname()); 63 } 64 public long getBytes() { 65 return this.bytes; 66 } 67 public int getFiles() { 68 return this.files; 69 } 70 71 public String getGroupname() { 72 return groupname; 73 } 74 public long getXferspeed() { 75 if (getXfertime() == 0) 76 return 0; 77 return (long) ((long) getBytes() / ((long) getXfertime() / 1000.0)); 78 } 79 80 public long getXfertime() { 81 return xfertime; 82 } 83 84 public int hashCode() { 85 return getGroupname().hashCode(); 86 } 87 public void updateBytes(long bytes) { 88 this.bytes += bytes; 89 } 90 public void updateFiles(int files) { 91 this.files += files; 92 } 93 public void updateXfertime(long xfertime) { 94 this.xfertime += xfertime; 95 } 96 } 97 | Popular Tags |