1 8 9 package mx4j.tools.stats; 10 11 import java.util.Date ; 12 13 22 public class PointTime implements Comparable 23 { 24 private Date date; 25 private long index; 26 27 public PointTime(Date date, long index) 28 { 29 this.date = date; 30 this.index = index; 31 } 32 33 public Date getDate() 34 { 35 return date; 36 } 37 38 public long getIndex() 39 { 40 return index; 41 } 42 43 public int compareTo(Object o) 44 { 45 PointTime p = (PointTime)o; 46 if (date.equals(p.date)) 47 { 48 return (int)(index - p.index); 49 } 50 else 51 { 52 return date.compareTo(p.date); 53 } 54 } 55 56 public boolean equals(Object o) 57 { 58 if (o == null) 59 { 60 throw new NullPointerException (); 61 } 62 if (!(o instanceof PointTime)) 63 { 64 return false; 65 } 66 PointTime p = (PointTime)o; 67 return p.date.equals(date) && (p.index == index); 68 } 69 } 70 | Popular Tags |