home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / util / History.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  1.1 KB  |  40 lines

  1. package com.extensibility.util;
  2.  
  3. import java.util.Vector;
  4.  
  5. public class History {
  6.    Vector history = new Vector();
  7.    int pos = -1;
  8.  
  9.    public void add(Object var1) {
  10.       if (var1 != null && !var1.equals(this.peekThis())) {
  11.          ++this.pos;
  12.          if (this.peekNext() == null || !this.peekNext().equals(var1)) {
  13.             this.history.setSize(this.pos);
  14.             this.history.insertElementAt(var1, this.pos);
  15.          }
  16.  
  17.       }
  18.    }
  19.  
  20.    public Object getPrev() {
  21.       return this.pos < 1 ? null : this.history.elementAt(--this.pos);
  22.    }
  23.  
  24.    public Object getNext() {
  25.       return this.pos >= this.history.size() - 1 ? null : this.history.elementAt(++this.pos);
  26.    }
  27.  
  28.    public Object peekThis() {
  29.       return this.pos < 0 ? null : this.history.elementAt(this.pos);
  30.    }
  31.  
  32.    public Object peekPrev() {
  33.       return this.pos < 1 ? null : this.history.elementAt(this.pos - 1);
  34.    }
  35.  
  36.    public Object peekNext() {
  37.       return this.pos >= this.history.size() - 1 ? null : this.history.elementAt(this.pos + 1);
  38.    }
  39. }
  40.