Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.history
Class HistoryQueryImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.history.HistoryQueryImpl
All Implemented Interfaces:
HistoryQuery

public class HistoryQueryImpl
extends Object
implements HistoryQuery

The HistoryQueryImpl is an implementation of the HistoryQuery interface. It corresponds to a query made through the InteractiveHistoryReader. It allows to be canceled, to listen for changes in the results and to obtain initial results if available.

Author:
Yana Stamcheva

Constructor Summary
HistoryQueryImpl(String queryString)
          Creates an instance of HistoryQueryImpl by specifying the query string it was created for.
 
Method Summary
(package private)  void addHistoryRecord(HistoryRecord record)
          Adds the given HistoryRecord to the result list of this query and notifies all interested listeners that a new record is received.
 void addHistoryRecordsListener(HistoryQueryListener l)
          Adds the given HistoryQueryListener to the list of listeners interested in query result changes.
 void cancel()
          Cancels this query.
 Collection<HistoryRecord> getHistoryRecords()
          Returns a collection of the results for this query.
 String getQueryString()
          Returns the query string, this query was created for.
(package private)  boolean isCanceled()
          Indicates if this query has been canceled.
 void removeHistoryRecordsListener(HistoryQueryListener l)
          Removes the given HistoryQueryListener from the list of listeners interested in query result changes.
(package private)  void setStatus(int queryStatus)
          Sets this query status to the given queryStatus and notifies all interested listeners of the change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistoryQueryImpl

public HistoryQueryImpl(String queryString)
Creates an instance of HistoryQueryImpl by specifying the query string it was created for.

Parameters:
queryString - the query string we're looking for in this query
Method Detail

cancel

public void cancel()
Cancels this query.

Specified by:
cancel in interface HistoryQuery

isCanceled

boolean isCanceled()
Indicates if this query has been canceled.

Returns:
true if this query has been canceled, otherwise returns false

getHistoryRecords

public Collection<HistoryRecord> getHistoryRecords()
Returns a collection of the results for this query. It's up to the implementation to determine how and when to fill this list of results.

This method could be used in order to obtain first fast initial results and then obtain the additional results through the HistoryQueryListener, which should improve user experience when waiting for results.

Specified by:
getHistoryRecords in interface HistoryQuery
Returns:
a collection of the initial results for this query

addHistoryRecordsListener

public void addHistoryRecordsListener(HistoryQueryListener l)
Adds the given HistoryQueryListener to the list of listeners interested in query result changes.

Specified by:
addHistoryRecordsListener in interface HistoryQuery
Parameters:
l - the HistoryQueryListener to add

removeHistoryRecordsListener

public void removeHistoryRecordsListener(HistoryQueryListener l)
Removes the given HistoryQueryListener from the list of listeners interested in query result changes.

Specified by:
removeHistoryRecordsListener in interface HistoryQuery
Parameters:
l - the HistoryQueryListener to remove

addHistoryRecord

void addHistoryRecord(HistoryRecord record)
Adds the given HistoryRecord to the result list of this query and notifies all interested listeners that a new record is received.

Parameters:
record - the HistoryRecord to add

setStatus

void setStatus(int queryStatus)
Sets this query status to the given queryStatus and notifies all interested listeners of the change.

Parameters:
queryStatus - the new query status to set

getQueryString

public String getQueryString()
Returns the query string, this query was created for.

Specified by:
getQueryString in interface HistoryQuery
Returns:
the query string, this query was created for

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.