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.request;
017    
018    import javax.mail.Flags;
019    
020    import com.hs.mail.imap.ImapSession;
021    import com.hs.mail.imap.ImapSession.State;
022    import com.hs.mail.imap.message.SequenceRange;
023    
024    /**
025     * 
026     * @author Won Chul Doh
027     * @since Jan 28, 2010
028     *
029     */
030    public class StoreRequest extends ImapRequest {
031    
032            private final SequenceRange[] sequenceSet;
033        private final boolean minus;
034        private final boolean plus;
035        private final boolean silent;
036        private final Flags flags;
037            private final boolean useUID;
038    
039            public StoreRequest(String tag, String command,
040                            SequenceRange[] sequenceSet, Boolean sign, final boolean silent,
041                            final Flags flags, boolean useUID) {
042                    super(tag, command);
043                    this.sequenceSet = sequenceSet;
044                    this.minus = (sign != null && !sign.booleanValue());
045                    this.plus = (sign != null && sign.booleanValue());
046                    this.silent = silent;
047                    this.flags = flags;
048                    this.useUID = useUID;
049            }
050    
051            public SequenceRange[] getSequenceSet() {
052                    return sequenceSet;
053            }
054    
055            public boolean isMinus() {
056                    return minus;
057            }
058    
059            public boolean isPlus() {
060                    return plus;
061            }
062            
063            public boolean isReplace() {
064                    return !plus && !minus;
065            }
066    
067            public boolean isSilent() {
068                    return silent;
069            }
070    
071            public Flags getFlags() {
072                    return flags;
073            }
074    
075            public boolean isUseUID() {
076                    return useUID;
077            }
078    
079            @Override
080            public boolean validForState(State state) {
081                    return state == ImapSession.State.SELECTED;
082            }
083    
084    }