com.threerings.crowd.chat.client
Class HistoryList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<ChatMessage>
              extended by com.threerings.crowd.chat.client.HistoryList
All Implemented Interfaces:
ChatDisplay, Serializable, Cloneable, Iterable<ChatMessage>, Collection<ChatMessage>, List<ChatMessage>, RandomAccess

public class HistoryList
extends ArrayList<ChatMessage>
implements ChatDisplay

Stores chat history.

See Also:
Serialized Form

Nested Class Summary
protected static class HistoryList.HistoryUpdatedOp
           
static interface HistoryList.Observer
          An interface for chat history observers.
 
Field Summary
protected  HistoryList.HistoryUpdatedOp _historyUpdatedOp
          An operation used to notify observers of history updates.
protected  ObserverList<HistoryList.Observer> _obs
          A list of HistoryList.Observers interested in history changes.
protected static int MAX_HISTORY
          The maximum number of history entries we'll keep.
protected static int PRUNE_HISTORY
          The number of history entries we'll prune when we hit the max.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
HistoryList()
           
 
Method Summary
 void addObserver(HistoryList.Observer obs)
          Adds an HistoryList.Observer that wants to know about changes to the history.
 void clear()
          Called to clear the chat display.
 boolean displayMessage(ChatMessage msg, boolean alreadyDisplayed)
          Called to display a chat message.
protected  void notify(int adjustment)
          Notifies listening HistoryList.Observers that there has been a change to this history.
 void removeObserver(HistoryList.Observer obs)
          Removes a HistoryList.Observer from hearing about changes to the history.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

_obs

protected ObserverList<HistoryList.Observer> _obs
A list of HistoryList.Observers interested in history changes.


_historyUpdatedOp

protected HistoryList.HistoryUpdatedOp _historyUpdatedOp
An operation used to notify observers of history updates.


MAX_HISTORY

protected static final int MAX_HISTORY
The maximum number of history entries we'll keep.

See Also:
Constant Field Values

PRUNE_HISTORY

protected static final int PRUNE_HISTORY
The number of history entries we'll prune when we hit the max.

See Also:
Constant Field Values
Constructor Detail

HistoryList

public HistoryList()
Method Detail

displayMessage

public boolean displayMessage(ChatMessage msg,
                              boolean alreadyDisplayed)
Description copied from interface: ChatDisplay
Called to display a chat message.

Specified by:
displayMessage in interface ChatDisplay
alreadyDisplayed - true if a previous chat display in the list has already displayed this message, false otherwise.
Returns:
true if the message was displayed, false if not.

clear

public void clear()
Description copied from interface: ChatDisplay
Called to clear the chat display.

Specified by:
clear in interface ChatDisplay
Specified by:
clear in interface Collection<ChatMessage>
Specified by:
clear in interface List<ChatMessage>
Overrides:
clear in class ArrayList<ChatMessage>

addObserver

public void addObserver(HistoryList.Observer obs)
Adds an HistoryList.Observer that wants to know about changes to the history.


removeObserver

public void removeObserver(HistoryList.Observer obs)
Removes a HistoryList.Observer from hearing about changes to the history.


notify

protected void notify(int adjustment)
Notifies listening HistoryList.Observers that there has been a change to this history.