本文整理汇总了Java中org.jivesoftware.smackx.pubsub.packet.PubSubNamespace类的典型用法代码示例。如果您正苦于以下问题:Java PubSubNamespace类的具体用法?Java PubSubNamespace怎么用?Java PubSubNamespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PubSubNamespace类属于org.jivesoftware.smackx.pubsub.packet包,在下文中一共展示了PubSubNamespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubscriptions
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的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: processPacket
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
{
listener.handlePurge();
}
else
{
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
@SuppressWarnings("unchecked")
Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
List<String> items = new ArrayList<String>(pubItems.size());
for (RetractItem item : pubItems)
{
items.add(item.getId());
}
ItemDeleteEvent eventItems = new ItemDeleteEvent(itemsElem.getNode(), items, getSubscriptionIds(packet));
listener.handleDeletedItems(eventItems);
}
}
示例3: parse
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
@Override
public PubSub parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, SmackException {
String namespace = parser.getNamespace();
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
PubSub pubsub = new PubSub(pubSubNamespace);
outerloop: while (true)
{
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
PacketParserUtils.addExtensionElement(pubsub, parser);
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return pubsub;
}
示例4: parseBasicItem
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
@Test
public void parseBasicItem() throws Exception
{
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='[email protected]' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
"<items node='testNode'>" +
"<item id='testid1' />" +
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
assertTrue(eventExt instanceof EventElement);
EventElement event = (EventElement) eventExt;
assertEquals(EventElementType.items, event.getEventType());
assertEquals(1, event.getExtensions().size());
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
assertTrue(itemExt instanceof Item);
assertEquals("testid1", ((Item)itemExt).getId());
}
示例5: parseIQ
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
PubSub pubsub = new PubSub();
String namespace = parser.getNamespace();
pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace));
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
PacketExtension ext = PacketParserUtils.parsePacketExtension(
parser.getName(), namespace, parser);
if (ext != null) {
pubsub.addExtension(ext);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("pubsub")) {
done = true;
}
}
}
return pubsub;
}
示例6: toXML
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public String toXML()
{
StringBuilder builder = new StringBuilder("<event xmlns='" + PubSubNamespace.EVENT.getXmlns() + "'>");
builder.append(ext.toXML());
builder.append("</event>");
return builder.toString();
}
示例7: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的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;
}
示例8: sendPubsubPacket
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
static PubSub sendPubsubPacket(XMPPConnection con, String to, Type type, List<ExtensionElement> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub pubSub = new PubSub(to, type, ns);
for (ExtensionElement pe : extList) {
pubSub.addExtension(pe);
}
return sendPubsubPacket(con ,pubSub);
}
示例9: accept
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public boolean accept(Stanza packet)
{
if (!(packet instanceof Message))
return false;
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
if (event == null)
return false;
NodeExtension embedEvent = event.getEvent();
if (embedEvent == null)
return false;
if (embedEvent.getElementName().equals(firstElement))
{
if (!embedEvent.getNode().equals(getId()))
return false;
if (secondElement == null)
return true;
if (embedEvent instanceof EmbeddedPacketExtension)
{
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
return true;
}
}
return false;
}
示例10: parseSimplePayloadItem
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
@Test
public void parseSimplePayloadItem() throws Exception
{
String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='[email protected]' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
"<items node='testNode'>" +
"<item id='testid1' >" +
itemContent +
"</item>" +
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
EventElement event = (EventElement) eventExt;
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
assertTrue(itemExt instanceof PayloadItem<?>);
PayloadItem<?> item = (PayloadItem<?>)itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
SimplePayload payload = (SimplePayload) item.getPayload();
assertEquals("foo", payload.getElementName());
assertEquals("smack:test", payload.getNamespace());
assertXMLEqual(itemContent, payload.toXML().toString());
}
示例11: parseEmptyTag
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
@Test
public void parseEmptyTag() throws Exception
{
String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='[email protected]' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
"<items node='testNode'>" +
"<item id='testid1' >" +
itemContent +
"</item>" +
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
assertTrue(eventExt instanceof EventElement);
EventElement event = (EventElement) eventExt;
assertEquals(EventElementType.items, event.getEventType());
assertEquals(1, event.getExtensions().size());
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
assertTrue(itemExt instanceof PayloadItem<?>);
PayloadItem<?> item = (PayloadItem<?>)itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
assertXMLEqual(itemContent, ((SimplePayload)item.getPayload()).toXML().toString());
}
示例12: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的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;
}
示例13: createPubsubPacket
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
static PubSub createPubsubPacket(String to, Type type, PacketExtension ext, PubSubNamespace ns)
{
PubSub request = new PubSub();
request.setTo(to);
request.setType(type);
if (ns != null)
{
request.setPubSubNamespace(ns);
}
request.addExtension(ext);
return request;
}
示例14: getNodeConfiguration
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
/**
* Returns a configuration form, from which you can create an answer form to be submitted
* via the {@link #sendConfigurationForm(Form)}.
*
* @return the configuration form
*/
public ConfigureForm getNodeConfiguration()
throws XMPPException
{
Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
}
示例15: sendConfigurationForm
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
/**
* Update the configuration with the contents of the new {@link Form}
*
* @param submitForm
*/
public void sendConfigurationForm(Form submitForm)
throws XMPPException
{
PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER);
SyncPacketSend.getReply(con, packet);
}