001 /** 002 * 003 */ 004 package biz.hammurapi.metrics.persistent; 005 006 import java.util.Calendar; 007 008 import org.jfree.data.time.RegularTimePeriod; 009 010 public class SliceTimePeriod extends RegularTimePeriod { 011 012 private Slice slice; 013 private SliceTimePeriod previous; 014 private SliceTimePeriod next; 015 int idx; 016 017 /** 018 * @param slice 019 */ 020 public SliceTimePeriod(Slice slice, SliceTimePeriod previous) { 021 this.slice=slice; 022 this.previous=previous; 023 if (previous!=null) { 024 previous.next=this; 025 idx=previous.idx+1; 026 } 027 } 028 029 public RegularTimePeriod previous() { 030 return previous; 031 } 032 033 public RegularTimePeriod next() { 034 return next; 035 } 036 037 public long getSerialIndex() { 038 return idx; 039 } 040 041 public long getFirstMillisecond(Calendar calendar) { 042 return slice.getTimeFrom(); 043 } 044 045 public long getLastMillisecond(Calendar calendar) { 046 return slice.getTimeTo(); 047 } 048 049 public int compareTo(Object o) { 050 if (o instanceof SliceTimePeriod) { 051 return idx-((SliceTimePeriod) o).idx; 052 } 053 054 return hashCode()-o.hashCode(); 055 } 056 057 public long getFirstMillisecond() { 058 return slice.getTimeFrom(); 059 } 060 061 public long getLastMillisecond() { 062 return slice.getTimeTo(); 063 } 064 065 public void peg(Calendar calendar) { 066 // Not implemented. 067 } 068 069 }