Home | History | Annotate | Download | only in pubsub
      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 /**
     17  * Represents a request to subscribe to a node.
     18  *
     19  * @author Robin Collier
     20  */
     21 public class SubscribeExtension extends NodeExtension
     22 {
     23 	protected String jid;
     24 
     25 	public SubscribeExtension(String subscribeJid)
     26 	{
     27 		super(PubSubElementType.SUBSCRIBE);
     28 		jid = subscribeJid;
     29 	}
     30 
     31 	public SubscribeExtension(String subscribeJid, String nodeId)
     32 	{
     33 		super(PubSubElementType.SUBSCRIBE, nodeId);
     34 		jid = subscribeJid;
     35 	}
     36 
     37 	public String getJid()
     38 	{
     39 		return jid;
     40 	}
     41 
     42 	@Override
     43 	public String toXML()
     44 	{
     45 		StringBuilder builder = new StringBuilder("<");
     46 		builder.append(getElementName());
     47 
     48 		if (getNode() != null)
     49 		{
     50 			builder.append(" node='");
     51 			builder.append(getNode());
     52 			builder.append("'");
     53 		}
     54 		builder.append(" jid='");
     55 		builder.append(getJid());
     56 		builder.append("'/>");
     57 
     58 		return builder.toString();
     59 	}
     60 }
     61