01: /*
02: * WebHistory.java
03: *
04: * Copyright (C) 1998-2002 Peter Graves
05: * $Id: WebHistory.java,v 1.1.1.1 2002/09/24 16:08:48 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package org.armedbear.j;
23:
24: import java.util.Vector;
25:
26: public final class WebHistory {
27: private Vector v = new Vector();
28: private int index = -1;
29:
30: public WebHistory() {
31: }
32:
33: public boolean atEnd() {
34: return index == -1;
35: }
36:
37: public void truncate() {
38: if (index >= 0)
39: v.setSize(index);
40: }
41:
42: public void append(File file, int offset, String contentType) {
43: v.add(new WebHistoryEntry(file, offset, contentType));
44: }
45:
46: public WebHistoryEntry getPrevious() {
47: if (v.size() == 0)
48: return null;
49: if (index < 0)
50: index = v.size();
51: if (index > 0)
52: return (WebHistoryEntry) v.get(--index);
53: return null;
54: }
55:
56: public WebHistoryEntry getNext() {
57: if (v.size() == 0)
58: return null;
59: if (index < 0)
60: return null;
61: if (index < v.size() - 1)
62: return (WebHistoryEntry) v.get(++index);
63: return null;
64: }
65:
66: public WebHistoryEntry getCurrent() {
67: if (index >= 0 && index < v.size())
68: return (WebHistoryEntry) v.get(index);
69: return null;
70: }
71:
72: public void reset() {
73: index = -1;
74: }
75: }
|