package bluej.debugmgr;
import java.util.List;
import java.util.ArrayList;
import threadchecker.OnThread;
import threadchecker.Tag;
| History objects maintain a history of text strings. This serves as a
| superclass for various histories (see, for example, ClassHistory,
| FreeCallHistory).
|
| @author Michael Kolling
|
@OnThread(Tag.Any)
public class History
{
protected List<String> history = null;
protected int maxLength;
private boolean blankAtStart;
| Create a empty history limited to a given maximum
| number of entries.
|
| @param maxLength The maximum length of the hostory list. The
| list truncates its tail when growing longer.
| @param blankDefault If true, maintains an empty string as the
| first (most recent) entry.
|
protected History(int maxLength, boolean blankDefault)
{
this.maxLength = maxLength;
history = new ArrayList<String>(maxLength+1);
history.add("");
blankAtStart = blankDefault;
}
| Put an entry into the history list. This method is only for
| initialisation through subclasses. It does not check for
| duplicates or maxlength.
|
protected void put(String value)
{
history.add(value);
}
| Return the history of used classes.
|
public List getHistory()
{
return history;
}
| Add a string to the history of used strings.
|
| @param newString the new string to add
|
public void add(String newString)
{
if (newString != null && (newString.length() != 0)) {
history.remove(newString);
if (blankAtStart) {
history.add(1, newString);
}
else {
if (((String)history.get(0)).length() == 0)
history.remove(0);
history.add(0, newString);
}
if (history.size() > maxLength)
history.remove(maxLength);
}
}
}
top,
use,
map,
class History
. History
. put
. getHistory
. add
73 neLoCode
+ 16 LoComm