• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
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  */
14 package org.jivesoftware.smackx.pubsub;
15 
16 import org.jivesoftware.smackx.pubsub.util.XmlUtils;
17 
18 /**
19  * A packet extension representing the <b>options</b> element.
20  *
21  * @author Robin Collier
22  */
23 public class OptionsExtension extends NodeExtension
24 {
25 	protected String jid;
26 	protected String id;
27 
OptionsExtension(String subscriptionJid)28 	public OptionsExtension(String subscriptionJid)
29 	{
30 		this(subscriptionJid, null, null);
31 	}
32 
OptionsExtension(String subscriptionJid, String nodeId)33 	public OptionsExtension(String subscriptionJid, String nodeId)
34 	{
35 		this(subscriptionJid, nodeId, null);
36 	}
37 
OptionsExtension(String jid, String nodeId, String subscriptionId)38 	public OptionsExtension(String jid, String nodeId, String subscriptionId)
39 	{
40 		super(PubSubElementType.OPTIONS, nodeId);
41 		this.jid = jid;
42 		id = subscriptionId;
43 	}
44 
getJid()45 	public String getJid()
46 	{
47 		return jid;
48 	}
49 
getId()50 	public String getId()
51 	{
52 		return id;
53 	}
54 
55 	@Override
toXML()56 	public String toXML()
57 	{
58 		StringBuilder builder = new StringBuilder("<");
59 		builder.append(getElementName());
60 		XmlUtils.appendAttribute(builder, "jid", jid);
61 
62 		if (getNode() != null)
63 			XmlUtils.appendAttribute(builder, "node", getNode());
64 
65 		if (id != null)
66 			XmlUtils.appendAttribute(builder, "subid", id);
67 
68 		builder.append("/>");
69 		return builder.toString();
70 	}
71 
72 }
73