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 import org.apache.commons.lang.ArrayUtils; 019 020 import com.hs.mail.imap.message.SequenceRange; 021 022 /** 023 * This class implements search-criteria for the message sequence numbers. 024 * 025 * @author Won Chul Doh 026 * @since Jan 30, 2010 027 * 028 */ 029 public final class SequenceKey extends SearchKey { 030 031 protected SequenceRange[] sequenceSet; 032 protected boolean useUid; 033 034 public SequenceKey(SequenceRange[] sequenceSet, boolean useUid) { 035 this.sequenceSet = sequenceSet; 036 this.useUid = useUid; 037 } 038 039 public SequenceKey(SequenceRange[] sequenceSet) { 040 this(sequenceSet, false); 041 } 042 043 public SequenceRange[] getSequenceSet() { 044 return sequenceSet; 045 } 046 047 public boolean isUseUid() { 048 return useUid; 049 } 050 051 public boolean equals(Object obj) { 052 if (!(obj instanceof SequenceKey)) 053 return false; 054 SequenceKey sk = (SequenceKey) obj; 055 return sk.useUid == this.useUid 056 && ArrayUtils.isEquals(sk.sequenceSet, this.sequenceSet); 057 } 058 059 @Override 060 public boolean isComposite() { 061 return true; 062 } 063 064 }