org.mbari.siam.core
Class MessageCache

java.lang.Object
  extended by org.mbari.siam.core.MessageCache

public class MessageCache
extends java.lang.Object

MessageCache contains a hashmap of message texts generated by an associated instrument service; each text has associated list of times at which the text occurred. As messages are added, the cache will be written to the service's device log when the cache limit is exceeded.

Author:
oreilly

Field Summary
protected  int _nOccurrences
          Total number of message occurrences
protected  BaseInstrumentService _service
          Associated instrument service.
 
Constructor Summary
MessageCache(BaseInstrumentService service, int cacheLimit)
           
 
Method Summary
 void add(java.lang.String msgText, long timestamp)
          Add a message.
 void clear()
          Clear message counts, but leave message objects in cache for possible later use.
 boolean flush()
          If cache not empty, write cache entries to service log, then clear cache.
 int nOccurrences()
          Return count of all message occurences currently in cache.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_service

protected BaseInstrumentService _service
Associated instrument service.


_nOccurrences

protected int _nOccurrences
Total number of message occurrences

Constructor Detail

MessageCache

public MessageCache(BaseInstrumentService service,
                    int cacheLimit)
Method Detail

add

public void add(java.lang.String msgText,
                long timestamp)
Add a message. If cache limit exceeded, write cache to log.


flush

public boolean flush()
If cache not empty, write cache entries to service log, then clear cache. Return true if cache wasn't empty, else return false.

Returns:
true if cache not empty

nOccurrences

public int nOccurrences()
Return count of all message occurences currently in cache.


clear

public void clear()
Clear message counts, but leave message objects in cache for possible later use.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.