Clover coverage report -
Coverage timestamp: Fri Nov 19 2004 13:41:51 PST
file stats: LOC: 108   Methods: 14
NCLOC: 88   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
History.java 0% 0% 0% 0%
coverage
 1    package photospace.web;
 2   
 3    import java.util.*;
 4    import javax.servlet.http.*;
 5    import photospace.meta.*;
 6   
 7    public class History
 8    implements java.io.Serializable
 9    {
 10    private List entries = new ArrayList();
 11    private int length;
 12   
 13  0 public History()
 14    {
 15  0 this(4);
 16    }
 17   
 18  0 public History(int length)
 19    {
 20  0 this.length = length;
 21    }
 22   
 23  0 public List getEntries()
 24    {
 25  0 return entries;
 26    }
 27   
 28  0 public void add(HttpServletRequest request, Meta meta)
 29    {
 30  0 Entry entry = new Entry(request, meta);
 31  0 if (entries.isEmpty())
 32    {
 33  0 entries.add(entry);
 34  0 return;
 35    }
 36  0 if (entry.equals(entries.get(getEnd()))) return;
 37   
 38  0 entries.add(entry);
 39    }
 40   
 41  0 public int getStart()
 42    {
 43  0 if (entries.size() <= length) return 0;
 44  0 return entries.size() - length;
 45    }
 46   
 47  0 public int getEnd()
 48    {
 49  0 return entries.size() - 1;
 50    }
 51   
 52  0 public Entry getLast()
 53    {
 54  0 if (entries.isEmpty()) return null;
 55  0 return (Entry) entries.get(entries.size() - 1);
 56    }
 57   
 58  0 public Entry goTo(int index)
 59    {
 60  0 if (entries.isEmpty()) return null;
 61  0 if (entries.size() <= index) return goTo(getEnd());
 62   
 63  0 Entry entry = (Entry) entries.get(index);
 64  0 entries = new ArrayList(entries.subList(0, index + 1));
 65  0 return entry;
 66    }
 67   
 68    public class Entry
 69    implements java.io.Serializable
 70    {
 71    private String url;
 72    private String label;
 73   
 74  0 public Entry(HttpServletRequest request, Meta meta)
 75    {
 76  0 this.url = request.getRequestURL().toString();
 77  0 this.label = meta.getLabel();
 78  0 if (request.getQueryString() != null) this.url += "?" + request.getQueryString();
 79    }
 80   
 81  0 public String getLabel()
 82    {
 83  0 return label;
 84    }
 85   
 86  0 public String getUrl()
 87    {
 88  0 return url;
 89    }
 90   
 91  0 public String toString()
 92    {
 93  0 return "Entry[" + label + "=" + url + "]";
 94    }
 95   
 96  0 public boolean equals(Object obj)
 97    {
 98  0 if (!(obj instanceof Entry)) return false;
 99  0 return url.equals(((Entry) obj).getUrl());
 100    }
 101   
 102  0 public int hashCode()
 103    {
 104  0 return url.hashCode();
 105    }
 106    }
 107   
 108    }