mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-12 10:39:38 +02:00
SMACK-330 Added missing node attribute in the item element for pubsub.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@12303 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
f90b43a87c
commit
1df6aaadf3
5 changed files with 87 additions and 13 deletions
|
@ -13,9 +13,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
||||
|
||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
|
||||
|
||||
/**
|
||||
* This class represents an item that has been, or will be published to a
|
||||
* pubsub node. An <tt>Item</tt> has several properties that are dependent
|
||||
|
@ -39,7 +40,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class Item implements PacketExtension
|
||||
public class Item extends NodeExtension
|
||||
{
|
||||
private String id;
|
||||
|
||||
|
@ -52,6 +53,7 @@ public class Item implements PacketExtension
|
|||
*/
|
||||
public Item()
|
||||
{
|
||||
super(PubSubElementType.ITEM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +65,27 @@ public class Item implements PacketExtension
|
|||
*/
|
||||
public Item(String itemId)
|
||||
{
|
||||
// The element type is actually irrelevant since we override getNamespace() to return null
|
||||
super(PubSubElementType.ITEM);
|
||||
id = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <tt>Item</tt> with an id and a node id.
|
||||
* <p>
|
||||
* <b>Note:</b> This is not valid for publishing an item to a node, only receiving from
|
||||
* one as part of {@link Message}. If used to create an Item to publish
|
||||
* (via {@link LeafNode#publish(Item)}, the server <i>may</i> return an
|
||||
* error for an invalid packet.
|
||||
*
|
||||
* @param itemId The id of the item.
|
||||
* @param nodeId The id of the node which the item was published to.
|
||||
*/
|
||||
public Item(String itemId, String nodeId)
|
||||
{
|
||||
super(PubSubElementType.ITEM_EVENT, nodeId);
|
||||
id = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item id. Unique to the node it is associated with.
|
||||
|
@ -76,16 +97,13 @@ public class Item implements PacketExtension
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getElementName()
|
||||
{
|
||||
return "item";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder("<item");
|
||||
|
@ -96,6 +114,12 @@ public class Item implements PacketExtension
|
|||
builder.append(id);
|
||||
builder.append("'");
|
||||
}
|
||||
|
||||
if (getNode() != null) {
|
||||
builder.append(" node='");
|
||||
builder.append(getNode());
|
||||
builder.append("'");
|
||||
}
|
||||
builder.append("/>");
|
||||
|
||||
return builder.toString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue