- /*
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-
- package javax.mail.search;
-
- import javax.mail.Message;
-
- /**
- * This class implements comparisons for the Message Subject header.
- * The comparison is case-insensitive.
- *
- * @author Bill Shannon
- * @author John Mani
- */
- public final class SubjectTerm extends StringTerm {
-
- /**
- * Constructor.
- *
- * @param pattern the pattern to search for
- */
- public SubjectTerm(String pattern) {
- // Note: comparison is case-insensitive
- super(pattern);
- }
-
- /**
- * The match method.
- *
- * @param msg the pattern match is applied to this Message's
- * subject header
- * @return true if the pattern match succeeds, otherwise false
- */
- public boolean match(Message msg) {
- String subj;
-
- try {
- subj = msg.getSubject();
- } catch (Exception e) {
- return false;
- }
-
- if (subj == null)
- return false;
-
- return super.match(subj);
- }
-
- /**
- * Equality comparison.
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof SubjectTerm))
- return false;
- return super.equals(obj);
- }
- }