blob: 9a78d736d409150111408aa4698d4cb65a821537 [file] [log] [blame]
Shuyi Chend7955ce2013-05-22 14:51:55 -07001/**
2 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14package org.jivesoftware.smackx.bytestreams.ibb.packet;
15
16import org.jivesoftware.smack.packet.IQ;
17import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
18
19/**
20 * Represents a request to close an In-Band Bytestream.
21 *
22 * @author Henning Staib
23 */
24public class Close extends IQ {
25
26 /* unique session ID identifying this In-Band Bytestream */
27 private final String sessionID;
28
29 /**
30 * Creates a new In-Band Bytestream close request packet.
31 *
32 * @param sessionID unique session ID identifying this In-Band Bytestream
33 */
34 public Close(String sessionID) {
35 if (sessionID == null || "".equals(sessionID)) {
36 throw new IllegalArgumentException("Session ID must not be null or empty");
37 }
38 this.sessionID = sessionID;
39 setType(Type.SET);
40 }
41
42 /**
43 * Returns the unique session ID identifying this In-Band Bytestream.
44 *
45 * @return the unique session ID identifying this In-Band Bytestream
46 */
47 public String getSessionID() {
48 return sessionID;
49 }
50
51 @Override
52 public String getChildElementXML() {
53 StringBuilder buf = new StringBuilder();
54 buf.append("<close ");
55 buf.append("xmlns=\"");
56 buf.append(InBandBytestreamManager.NAMESPACE);
57 buf.append("\" ");
58 buf.append("sid=\"");
59 buf.append(sessionID);
60 buf.append("\"");
61 buf.append("/>");
62 return buf.toString();
63 }
64
65}