本文整理汇总了Java中org.jivesoftware.smackx.pubsub.packet.PubSubNamespace类的典型用法代码示例。如果您正苦于以下问题:Java PubSubNamespace类的具体用法?Java PubSubNamespace怎么用?Java PubSubNamespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PubSubNamespace类属于org.jivesoftware.smackx.pubsub.packet包,在下文中一共展示了PubSubNamespace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:Node.java
示例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);
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:Node.java
示例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;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:PubSubProvider.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:ItemValidationTest.java
示例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;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:25,代码来源:PubSubProvider.java
示例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();
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:EventElement.java
示例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;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:20,代码来源:PubSubManager.java
示例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);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:PubSubManager.java
示例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;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:34,代码来源:Node.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:33,代码来源:ItemValidationTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:36,代码来源:ItemValidationTest.java
示例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;
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:19,代码来源:PubSubManager.java
示例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;
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:PubSubManager.java
示例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);
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:13,代码来源:Node.java
示例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);
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:Node.java
示例16: processPacket
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public void processPacket(Packet packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<PacketExtension> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
{
listener.handlePurge();
}
else
{
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
Collection<? extends PacketExtension> pubItems = itemsElem.getItems();
Iterator<RetractItem> it = (Iterator<RetractItem>)pubItems.iterator();
List<String> items = new ArrayList<String>(pubItems.size());
while (it.hasNext())
{
RetractItem item = it.next();
items.add(item.getId());
}
ItemDeleteEvent eventItems = new ItemDeleteEvent(itemsElem.getNode(), items, getSubscriptionIds(packet));
listener.handleDeletedItems(eventItems);
}
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:28,代码来源:Node.java
示例17: accept
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; //导入依赖的package包/类
public boolean accept(Packet 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<PacketExtension> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
return true;
}
}
return false;
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:Node.java
示例18: 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;
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:31,代码来源:PubSubProvider.java
示例19: 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();
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:9,代码来源:EventElement.java
示例20: 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;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:19,代码来源:PubSubManager.java
注:本文中的org.jivesoftware.smackx.pubsub.packet.PubSubNamespace类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论