001 /* 002 * Copyright 2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package com.hs.mail.imap.message.search; 017 018 /** 019 * This class implements search-criteria for the Message Header or Contents 020 * text. 021 * 022 * @author Won Chul Doh 023 * @since Jan 30, 2010 024 * 025 */ 026 public final class TextKey extends StringKey { 027 028 /** 029 * True if search for header of the message, otherwise false (search for 030 * body of the message) 031 */ 032 protected boolean header; 033 034 public TextKey(String pattern, boolean header) { 035 super(pattern); 036 this.header = header; 037 } 038 039 public TextKey(String pattern) { 040 this(pattern, true); 041 } 042 043 public boolean getSearchHeader() { 044 return header; 045 } 046 047 public boolean equals(Object obj) { 048 if (!(obj instanceof TextKey)) 049 return false; 050 TextKey tk = (TextKey) obj; 051 return tk.header == this.header && super.equals(obj); 052 } 053 054 @Override 055 public boolean isComposite() { 056 return false; 057 } 058 059 }