• 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.smack.packet.PacketExtension;
17 
18 /**
19  * The default payload representation for {@link Item#getPayload()}.  It simply
20  * stores the XML payload as a string.
21  *
22  * @author Robin Collier
23  */
24 public class SimplePayload implements PacketExtension
25 {
26 	private String elemName;
27 	private String ns;
28 	private String payload;
29 
30 	/**
31 	 * Construct a <tt>SimplePayload</tt> object with the specified element name,
32 	 * namespace and content.  The content must be well formed XML.
33 	 *
34 	 * @param elementName The root element name (of the payload)
35 	 * @param namespace The namespace of the payload, null if there is none
36 	 * @param xmlPayload The payload data
37 	 */
SimplePayload(String elementName, String namespace, String xmlPayload)38 	public SimplePayload(String elementName, String namespace, String xmlPayload)
39 	{
40 		elemName = elementName;
41 		payload = xmlPayload;
42 		ns = namespace;
43 	}
44 
getElementName()45 	public String getElementName()
46 	{
47 		return elemName;
48 	}
49 
getNamespace()50 	public String getNamespace()
51 	{
52 		return ns;
53 	}
54 
toXML()55 	public String toXML()
56 	{
57 		return payload;
58 	}
59 
60 	@Override
toString()61 	public String toString()
62 	{
63 		return getClass().getName() + "payload [" + toXML() + "]";
64 	}
65 }
66