SK.gnome.dwarf.mail.store.search
Class SearchKey

java.lang.Object
  extended bySK.gnome.dwarf.mail.store.search.SearchKey
Direct Known Subclasses:
AllKey, DateKey, FlagKey, HeaderKey, NoneKey, NotKey, SearchKeyList, SequenceKey, SizeKey, TextKey

public abstract class SearchKey
extends java.lang.Object

Provides a generic search key.

A search key may have its type specified via the SearchKey(int) constructor. The abstract match(MailMessage) method must be implemented by the derived classes. This method matches the given message according to any internal criteria defined for the particular search key.

If a search key encounters a malformed message, it should not throw an exception since it would probably interrupt the whole searching process, which might not be always desirable. Instead, the exception may be added to the internal list of errors via the addError(Exception) method. When the whole searching process finishes, all processing errors may be then accessed via the hasError(), getErrors() and clearErrors() methods.


Field Summary
protected  int type
          The key type.
 
Constructor Summary
protected SearchKey()
          Creates a new SearchKey.
protected SearchKey(int type)
          Creates a new SearchKey with the given type.
 
Method Summary
 void addError(java.lang.Exception e)
          Adds the searching error to the list.
 void clearErrors()
          Clears the list of searching errors.
 java.util.Iterator getErrors()
          Returns the errors occured during the search process.
 int getType()
          Returns the key type.
 boolean hasError()
          Whether an error occured during the search process.
abstract  boolean match(MailMessage message)
          Matches the given message.
 java.lang.String toString()
          Returns the string represenation of the key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected int type
The key type.

See Also:
getType()
Constructor Detail

SearchKey

protected SearchKey()
Creates a new SearchKey.


SearchKey

protected SearchKey(int type)
Creates a new SearchKey with the given type.

Parameters:
type - the key type
See Also:
type
Method Detail

getType

public int getType()
Returns the key type.

Returns:
the type of the key
See Also:
type

hasError

public boolean hasError()
Whether an error occured during the search process.

Returns:
true if an error occured during the search process

addError

public void addError(java.lang.Exception e)
Adds the searching error to the list.

Parameters:
e - the exception occured while matching a message

getErrors

public java.util.Iterator getErrors()
Returns the errors occured during the search process.

Returns:
the iteration of errors

clearErrors

public void clearErrors()
Clears the list of searching errors.


match

public abstract boolean match(MailMessage message)
                       throws MailException
Matches the given message.

Parameters:
message - the searched message
Returns:
true if the given key criteria and message matches, false otherwise
Throws:
MailException - if an error occurs

toString

public java.lang.String toString()
Returns the string represenation of the key.

Returns:
the key string


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.