当前位置: 首页>>代码示例>>Java>>正文


Java ExtensionElement类代码示例

本文整理汇总了Java中org.jivesoftware.smack.packet.ExtensionElement的典型用法代码示例。如果您正苦于以下问题:Java ExtensionElement类的具体用法?Java ExtensionElement怎么用?Java ExtensionElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExtensionElement类属于org.jivesoftware.smack.packet包,在下文中一共展示了ExtensionElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processMessage

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
public void processMessage(Chat chat, Message message) {
    ExtensionElement extension = message.getExtension(NAMESPACE);
    if (extension == null) {
        return;
    }

    ChatState state;
    try {
        state = ChatState.valueOf(extension.getElementName());
    }
    catch (Exception ex) {
        return;
    }

    fireNewChatState(chat, state);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:ChatStateManager.java

示例2: isNonLatsChunkParsedCorrectly

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
@Test
public void isNonLatsChunkParsedCorrectly() throws Exception {
    String base64Text = "iVBORw0KGgoAAAANSUhEUgAAASwAAAGQCAYAA";
    String string = "<chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='0'>" + base64Text + "</chunk>";

    Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);

    ExtensionElement extension = provider.parse(parser);
    assertTrue(extension instanceof Base64BinaryChunk);

    Base64BinaryChunk chunk = (Base64BinaryChunk) extension;
    assertEquals("Stream0001", chunk.getStreamId());
    assertFalse(chunk.isLast());
    assertEquals(base64Text, chunk.getText());
    assertEquals(0, chunk.getNr());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:Base64BinaryChunkProviderTest.java

示例3: isLatsChunkParsedCorrectly

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
@Test
public void isLatsChunkParsedCorrectly() throws Exception {
    String base64Text = "2uPzi9u+tVWJd+e+y1AAAAABJRU5ErkJggg==";
    String string = "<chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='1' last='true'>" + base64Text + "</chunk>";

    Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);

    ExtensionElement extension = provider.parse(parser);
    assertTrue(extension instanceof Base64BinaryChunk);

    Base64BinaryChunk chunk = (Base64BinaryChunk) extension;
    assertEquals("Stream0001", chunk.getStreamId());
    assertTrue(chunk.isLast());
    assertEquals(base64Text, chunk.getText());
    assertEquals(1, chunk.getNr());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:Base64BinaryChunkProviderTest.java

示例4: parse

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
@Override
public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
                SmackException {
    final String namespace = parser.getNamespace();
    final String name = parser.getName();
    final int attributeCount = parser.getAttributeCount();
    Map<String, String> attMap = new HashMap<>(attributeCount);

    for (int i = 0; i < attributeCount; i++) {
        attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
    }

    List<ExtensionElement> extensions = new ArrayList<>();
    int event;
    do {
        event = parser.next();

        if (event == XmlPullParser.START_TAG)
            PacketParserUtils.addExtensionElement(extensions, parser);
    }
    while (!(event == XmlPullParser.END_TAG && parser.getDepth() == initialDepth));

    return createReturnExtension(name, namespace, attMap, extensions);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:EmbeddedExtensionProvider.java

示例5: continuePage

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
Collection<ExtensionElement> continuePage(int max,
                Collection<ExtensionElement> returnedExtensions,
                Collection<ExtensionElement> additionalExtensions) {
    if (returnedExtensions == null) {
        throw new IllegalArgumentException("returnedExtensions must no be null");
    }
    if (additionalExtensions == null) {
        additionalExtensions = new LinkedList<ExtensionElement>();
    }
    RSMSet resultRsmSet = PacketUtil.extensionElementFrom(returnedExtensions, RSMSet.ELEMENT, RSMSet.NAMESPACE);
    if (resultRsmSet == null) {
        throw new IllegalArgumentException("returnedExtensions did not contain a RSMset");
    }
    RSMSet continePageRsmSet = new RSMSet(max, resultRsmSet.getLast(), PageDirection.after);
    additionalExtensions.add(continePageRsmSet);
    return additionalExtensions;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:RSMManager.java

示例6: getSubscriptions

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的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

示例7: getAffiliations

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的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();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:31,代码来源:Node.java

示例8: processPacket

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的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

示例9: verifyPacketExtensions

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
/**
 * 
 * @param info
 * @return true if the stanza(/packet) extensions is ill-formed
 */
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
    List<FormField> foundFormTypes = new LinkedList<FormField>();
    for (ExtensionElement pe : info.getExtensions()) {
        if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
            DataForm df = (DataForm) pe;
            for (FormField f : df.getFields()) {
                if (f.getVariable().equals("FORM_TYPE")) {
                    for (FormField fft : foundFormTypes) {
                        if (f.equals(fft))
                            return true;
                    }
                    foundFormTypes.add(f);
                }
            }
        }
    }
    return false;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:EntityCapsManager.java

示例10: parseBasicItem

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的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

示例11: isCorrectFromXmlErrorHandling

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
@Test
public void isCorrectFromXmlErrorHandling() throws Exception {
    AMPExtensionProvider ampProvider = new AMPExtensionProvider();
    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(INCORRECT_RECEIVING_STANZA_STREAM, "UTF-8");

    assertEquals(XmlPullParser.START_TAG, parser.next());
    assertEquals(AMPExtension.ELEMENT, parser.getName());

    ExtensionElement extension = ampProvider.parse(parser);
    assertTrue(extension instanceof AMPExtension);
    AMPExtension amp = (AMPExtension) extension;

    assertEquals(0, amp.getRulesCount());
    assertEquals(AMPExtension.Status.alert, amp.getStatus());
    assertEquals("[email protected]/elsinore", amp.getFrom());
    assertEquals("[email protected]", amp.getTo());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:20,代码来源:AMPExtensionTest.java

示例12: parse

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
/**
 * Parse a JingleDescription.Audio extension.
 */
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth) {
    ExtensionElement result = null;

    if (audioInfo != null) {
        result = audioInfo;
    } else {
        String elementName = parser.getName();

        // Try to get an Audio content info
        ContentInfo mi = ContentInfo.Audio.fromString(elementName);
        if (mi != null) {
            result = new JingleContentInfo.Audio(mi);
        }
    }
    return result;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:JingleContentInfoProvider.java

示例13: processWakefulStanza

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
@Override
protected void processWakefulStanza(Stanza packet) throws SmackException.NotConnectedException {
    org.jivesoftware.smack.packet.Message m = (org.jivesoftware.smack.packet.Message) packet;

    if (m.getType() == org.jivesoftware.smack.packet.Message.Type.chat) {
        ExtensionElement chatstate = processChatState(m);

        // non-active chat states are not to be processed as messages
        if (chatstate == null || chatstate.getElementName().equals(ChatState.active.name())) {
            processChatMessage(m);
        }
    }

    // error message
    else if (m.getType() == org.jivesoftware.smack.packet.Message.Type.error) {
        processErrorMessage(m);
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:19,代码来源:MessageListener.java

示例14: getDelay

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
private static Date getDelay(Message m) {
    // first: new XEP-0203 specification
    ExtensionElement delay = DelayInformation.from(m);

    // fallback: obsolete XEP-0091 specification
    if (delay == null) {
        delay = m.getExtension("x", "jabber:x:delay");
    }

    if (delay instanceof DelayInformation) {
        Date date = ((DelayInformation) delay).getStamp();
        if (date.after(new Date()))
            LOGGER.warning("delay time is in future: "+date);
        return date;
    }

    return null;
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:19,代码来源:KonMessageListener.java

示例15: getSignCryptElement

import org.jivesoftware.smack.packet.ExtensionElement; //导入依赖的package包/类
/** Get XEP-0373 signcrypt plaintext as XML string. */
public static String getSignCryptElement(OutMessage message) {
    List<String> tos = message.getTransmissions().stream()
            .map(t -> t.getJID().string())
            .collect(Collectors.toList());
    int rpadLength = new SecureRandom().nextInt(RPAD_LENGTH_RANGE);

    List<ExtensionElement> contentElements = new ArrayList<>();
    MessageContent content = message.getContent();
    String text = content.getPlainText();
    if (!text.isEmpty())
        contentElements.add(new BodyElement(text));
    contentElements.addAll(extensionsForContent(content, message.getChat(), true));

    return new SignCryptElement(tos, new Date(), rpadLength, contentElements)
            .toXML().toString();
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:18,代码来源:KonMessageSender.java


注:本文中的org.jivesoftware.smack.packet.ExtensionElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。