1 21 22 package org.armedbear.j; 23 24 import java.util.Vector ; 25 26 public final class WebHistory 27 { 28 private Vector v = new Vector (); 29 private int index = -1; 30 31 public WebHistory() 32 { 33 } 34 35 public boolean atEnd() 36 { 37 return index == -1; 38 } 39 40 public void truncate() 41 { 42 if (index >= 0) 43 v.setSize(index); 44 } 45 46 public void append(File file, int offset, String contentType) 47 { 48 v.add(new WebHistoryEntry(file, offset, contentType)); 49 } 50 51 public WebHistoryEntry getPrevious() 52 { 53 if (v.size() == 0) 54 return null; 55 if (index < 0) 56 index = v.size(); 57 if (index > 0) 58 return (WebHistoryEntry) v.get(--index); 59 return null; 60 } 61 62 public WebHistoryEntry getNext() 63 { 64 if (v.size() == 0) 65 return null; 66 if (index < 0) 67 return null; 68 if (index < v.size()-1) 69 return (WebHistoryEntry) v.get(++index); 70 return null; 71 } 72 73 public WebHistoryEntry getCurrent() 74 { 75 if (index >= 0 && index < v.size()) 76 return (WebHistoryEntry) v.get(index); 77 return null; 78 } 79 80 public void reset() 81 { 82 index = -1; 83 } 84 } 85 | Popular Tags |