001 package jp.osdl.jbento2.analyzer; 002 003 import java.util.ArrayList; 004 import java.util.Collections; 005 import java.util.Comparator; 006 import java.util.Iterator; 007 import java.util.List; 008 009 010 public class SampleList { 011 012 private List samples = new ArrayList(); 013 014 public SampleList() { } 015 016 public SampleList(SampleList src) { 017 samples.addAll(src.samples); 018 } 019 020 public void add(Sample sample) { 021 samples.add(sample); 022 } 023 024 public Sample get(int i) { 025 return (Sample)samples.get(i); 026 } 027 028 public void remove(Sample sample) { 029 samples.remove(sample); 030 } 031 032 public Iterator iterator() { 033 return samples.iterator(); 034 } 035 036 public boolean isEmpty() { 037 return samples.isEmpty(); 038 } 039 040 public int size() { 041 return samples.size(); 042 } 043 044 public void sortByStartTime() { 045 Collections.sort(samples, new Comparator() { 046 public int compare(Object obj1, Object obj2) { 047 Sample sample1 = (Sample) obj1; 048 Sample sample2 = (Sample) obj2; 049 return sample1.getStartTime().compareTo(sample2.getStartTime()); 050 } 051 }); 052 } 053 054 public void sortByEndTime() { 055 Collections.sort(samples, new Comparator() { 056 public int compare(Object obj1, Object obj2) { 057 Sample sample1 = (Sample) obj1; 058 Sample sample2 = (Sample) obj2; 059 return sample1.getEndTime().compareTo(sample2.getEndTime()); 060 } 061 }); 062 } 063 064 }