本文整理汇总了Java中org.jivesoftware.smackx.pubsub.packet.PubSub.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java PubSub.getExtension方法的具体用法?Java PubSub.getExtension怎么用?Java PubSub.getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.pubsub.packet.PubSub
的用法示例。
在下文中一共展示了PubSub.getExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubscriptions
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
private List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions, PubSubNamespace pubSubNamespace)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()), pubSubNamespace);
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
示例2: getAffiliations
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the affiliations of this node.
* <p>
* {@code additionalExtensions} can be used e.g. to add a "Result Set Management" extension.
* {@code returnedExtensions} will be filled with the stanza(/packet) extensions found in the answer.
* </p>
*
* @param additionalExtensions additional {@code PacketExtensions} add to the request
* @param returnedExtensions a collection that will be filled with the returned packet
* extensions
* @return List of {@link Affiliation}
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
*/
public List<Affiliation> getAffiliations(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
AffiliationsExtension affilElem = (AffiliationsExtension) reply.getExtension(PubSubElementType.AFFILIATIONS);
return affilElem.getAffiliations();
}
示例3: getItems
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the items specified from the node. This would typically be
* used when the server does not return the payload due to size
* constraints. The user would be required to retrieve the payload
* after the items have been retrieved via {@link #getItems()} or an
* event, that did not include the payload.
*
* @param ids Item ids of the items to retrieve
*
* @return The list of {@link Item} with payload
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems(Collection<String> ids)
throws XMPPException
{
List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids)
{
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.GET, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
PubSub result = (PubSub)SyncPacketSend.getReply(con, request);
ItemsExtension itemsElem = (ItemsExtension)result.getExtension(PubSubElementType.ITEMS);
return (List<T>)itemsElem.getItems();
}
示例4: getItems
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the items specified from the node. This would typically be used when
* the server does not return the payload due to size constraints. The user
* would be required to retrieve the payload after the items have been
* retrieved via {@link #getItems()} or an event, that did not include the
* payload.
*
* @param ids
* Item ids of the items to retrieve
*
* @return The list of {@link Item} with payload
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems(Collection<String> ids)
throws XMPPException {
List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids) {
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.GET, new ItemsExtension(
ItemsExtension.ItemsElementType.items, getId(), itemList));
PubSub result = (PubSub) SyncPacketSend.getReply(con, request);
ItemsExtension itemsElem = (ItemsExtension) result
.getExtension(PubSubElementType.ITEMS);
return (List<T>) itemsElem.getItems();
}
示例5: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates an instant node, if supported.
*
* @return The node that was created
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例6: getItems
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Item> List<T> getItems(PubSub request,
List<ExtensionElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException {
PubSub result = con.createPacketCollectorAndSend(request).nextResultOrThrow();
ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS);
if (returnedExtensions != null) {
returnedExtensions.addAll(result.getExtensions());
}
return (List<T>) itemsElem.getItems();
}
示例7: subscriptionsOwnerResultTest
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
@Test
public void subscriptionsOwnerResultTest() throws Exception {
// @formatter:off
final String resultStanza =
"<iq from='pubsub.example.org' to='[email protected]/Smack' id='HaT4m-13' type='result'>" +
"<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>" +
"<subscriptions node='test'>" +
"<subscription jid='[email protected]/Smack' subscription='subscribed' subid='58C1A6F99F2A7'/>" +
"<subscription jid='[email protected]/Smack' subscription='subscribed' subid='58C18F8917321'/>" +
"</subscriptions>" +
"</pubsub>" +
"</iq>";
// @formatter:on
XmlPullParser parser = TestUtils.getIQParser(resultStanza);
PubSub pubsubResult = (PubSub) PacketParserUtils.parseIQ(parser);
SubscriptionsExtension subElem = pubsubResult.getExtension(PubSubElementType.SUBSCRIPTIONS);
List<Subscription> subscriptions = subElem.getSubscriptions();
assertEquals(2, subscriptions.size());
Subscription sub1 = subscriptions.get(0);
assertEquals("[email protected]/Smack", sub1.getJid());
assertEquals(Subscription.State.subscribed, sub1.getState());
assertEquals("58C1A6F99F2A7", sub1.getId());
Subscription sub2 = subscriptions.get(1);
assertEquals("[email protected]/Smack", sub2.getJid());
assertEquals(Subscription.State.subscribed, sub2.getState());
assertEquals("58C18F8917321", sub2.getId());
}
示例8: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates an instant node, if supported.
*
* @return The node that was created
* @exception XMPPException
*/
public LeafNode createNode()
throws XMPPException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例9: getAffiliations
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Gets the affiliations on the root node.
*
* @return List of affiliations
*
* @throws XMPPException
*/
public List<Affiliation> getAffiliations()
throws XMPPException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS));
AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations();
}
示例10: getSubscriptions
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the subscriptions currently associated with this node.
*
* @return List of {@link Subscription}
*
* @throws XMPPException
*/
public List<Subscription> getSubscriptions()
throws XMPPException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
示例11: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates an instant node, if supported.
*
* @return The node that was created
* @exception XMPPException
*/
public LeafNode createNode() throws XMPPException {
PubSub reply = (PubSub) sendPubsubPacket(Type.SET, new NodeExtension(
PubSubElementType.CREATE));
NodeExtension elem = (NodeExtension) reply.getExtension("create",
PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例12: getAffiliations
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Gets the affiliations on the root node.
*
* @return List of affiliations
*
* @throws XMPPException
*/
public List<Affiliation> getAffiliations() throws XMPPException {
PubSub reply = (PubSub) sendPubsubPacket(Type.GET, new NodeExtension(
PubSubElementType.AFFILIATIONS));
AffiliationsExtension listElem = (AffiliationsExtension) reply
.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations();
}
示例13: getSubscriptions
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the subscriptions currently associated with this node.
*
* @return List of {@link Subscription}
*
* @throws XMPPException
*/
public List<Subscription> getSubscriptions() throws XMPPException {
PubSub reply = (PubSub) sendPubsubPacket(Type.GET, new NodeExtension(
PubSubElementType.SUBSCRIPTIONS, getId()));
SubscriptionsExtension subElem = (SubscriptionsExtension) reply
.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
示例14: getItems
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the current items stored in the node.
*
* @return List of {@link Item} in the node
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems()
throws XMPPException
{
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId()));
PubSub result = (PubSub)SyncPacketSend.getReply(con, request);
ItemsExtension itemsElem = (ItemsExtension)result.getExtension(PubSubElementType.ITEMS);
return (List<T>)itemsElem.getItems();
}
示例15: getAffiliations
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Gets the affiliations on the root node.
*
* @return List of affiliations
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations();
}