001    /**
002     *   GRANITE DATA SERVICES
003     *   Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S.
004     *
005     *   This file is part of Granite Data Services.
006     *
007     *   Granite Data Services is free software; you can redistribute it and/or modify
008     *   it under the terms of the GNU Library General Public License as published by
009     *   the Free Software Foundation; either version 2 of the License, or (at your
010     *   option) any later version.
011     *
012     *   Granite Data Services is distributed in the hope that it will be useful, but
013     *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014     *   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015     *   for more details.
016     *
017     *   You should have received a copy of the GNU Library General Public License
018     *   along with this library; if not, see <http://www.gnu.org/licenses/>.
019     */
020    package org.granite.client.messaging.messages.requests;
021    
022    import java.util.Map;
023    
024    import org.granite.client.messaging.messages.Message;
025    
026    /**
027     * @author Franck WOLFF
028     */
029    public final class UnsubscribeMessage extends AbstractTopicRequestMessage {
030    
031            private String subscriptionId = null;
032            
033            public UnsubscribeMessage() {
034            }
035    
036            public UnsubscribeMessage(String destination, String topic, String subscriptionId) {
037                    this(null, destination, topic, subscriptionId);
038            }
039    
040            public UnsubscribeMessage(String clientId, String destination, String topic, String subscriptionId) {
041                    super(clientId, destination, topic);
042                    
043                    this.subscriptionId = subscriptionId;
044            }
045    
046            public UnsubscribeMessage(
047                    String id,
048                    String clientId,
049                    long timestamp,
050                    long timeToLive,
051                    Map<String, Object> headers,
052                    String destination,
053                    String topic,
054                    String subscriptionId) {
055                    
056                    super(id, clientId, timestamp, timeToLive, headers, destination, topic);
057                    
058                    this.subscriptionId = subscriptionId;
059            }
060    
061            public String getSubscriptionId() {
062                    return subscriptionId;
063            }
064    
065            public void setSubscriptionId(String subscriptionId) {
066                    this.subscriptionId = subscriptionId;
067            }
068    
069            @Override
070            public Type getType() {
071                    return Type.UNSUBSCRIBE;
072            }
073    
074            @Override
075            public Message copy() {
076                    UnsubscribeMessage message = new UnsubscribeMessage();
077                    
078                    copy(message);
079                    
080                    message.subscriptionId = subscriptionId;
081                    
082                    return message;
083            }
084    }