congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ItemsExtension
Code IndexAdd Tabnine to your IDE (free)

How to use
ItemsExtension
in
org.jivesoftware.smackx.pubsub

Best Java code snippets using org.jivesoftware.smackx.pubsub.ItemsExtension (Showing top 20 results out of 315)

origin: igniterealtime/Smack

@Override
protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
  return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content);
}
origin: igniterealtime/Smack

@Override
public CharSequence toXML(String enclosingNamespace) {
  if ((items == null) || (items.size() == 0)) {
    return super.toXML(enclosingNamespace);
  }
  else {
    StringBuilder builder = new StringBuilder("<");
    builder.append(getElementName());
    builder.append(" node='");
    builder.append(getNode());
    if (notify != null) {
      builder.append("' ");
      builder.append(type.getElementAttribute());
      builder.append("='");
      builder.append(notify.equals(Boolean.TRUE) ? 1 : 0);
      builder.append("'>");
    }
    else {
      builder.append("'>");
      for (NamedElement item : items) {
        builder.append(item.toXML(null));
      }
    }
    builder.append("</");
    builder.append(getElementName());
    builder.append('>');
    return builder.toString();
  }
}
origin: igniterealtime/Smack

  @Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public void processStanza(Stanza packet) {
    EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
    ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
    ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
    // TODO: Use AsyncButOrdered (with Node as Key?)
    listener.handlePublishedItems(eventItems);
  }
}
origin: igniterealtime/Smack

@Override
@SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions() {
  return (List<ExtensionElement>) getItems();
}
origin: org.igniterealtime.smack/smackx

/**
 * 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();
}
origin: igniterealtime/Smack

@Override
public String toString() {
  return getClass().getName() + "Content [" + toXML(null) + "]";
}
origin: igniterealtime/Smack

for (ExtensionElement item : ((ItemsExtension) items).getExtensions()) {
  if (!(item instanceof PayloadItem<?>)) {
    continue;
origin: igniterealtime/Smack

@SuppressWarnings("unchecked")
private <T extends Item> List<T> getItems(PubSub request,
        List<ExtensionElement> returnedExtensions) throws NoResponseException,
        XMPPErrorException, NotConnectedException, InterruptedException {
  PubSub result = pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
  ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS);
  if (returnedExtensions != null) {
    returnedExtensions.addAll(result.getExtensions());
  }
  return (List<T>) itemsElem.getItems();
}
origin: org.littleshoot/smack-xmpp-3-2-2

/**
 * 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();
}
origin: tiandawu/IotXmpp

@Override
public String toString()
{
  return getClass().getName() + "Content [" + toXML() + "]";
}
origin: igniterealtime/Smack

    @Override
    public void processStanza(Stanza packet) {
// CHECKSTYLE:OFF
      EventElement event = 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<>(pubItems.size());

        for (RetractItem item : pubItems) {
          items.add(item.getId());
        }

        ItemDeleteEvent eventItems = new ItemDeleteEvent(itemsElem.getNode(), items, getSubscriptionIds(packet));
        listener.handleDeletedItems(eventItems);
      }
// CHECKSTYLE:ON
    }
  }
origin: tiandawu/IotXmpp

public List<PacketExtension> getExtensions()
{
  return (List<PacketExtension>)getItems();
}

origin: tiandawu/IotXmpp

builder.append(getElementName());
builder.append(" node='");
builder.append(getNode());
builder.append(getElementName());
builder.append(">");
return builder.toString();
origin: tiandawu/IotXmpp

/**
 * 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();
}
origin: igniterealtime/Smack

/**
 * 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
 * @param <T> type of the items.
 *
 * @return The list of {@link Item} with payload
 * @throws XMPPErrorException
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException
 * @throws InterruptedException
 */
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  List<Item> itemList = new ArrayList<>(ids.size());
  for (String id : ids) {
    itemList.add(new Item(id));
  }
  PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
  return getItems(request);
}
origin: org.igniterealtime.smack/smackx

@Override
public String toString()
{
  return getClass().getName() + "Content [" + toXML() + "]";
}
origin: org.littleshoot/smack-xmpp-3-2-2

  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);
    }
  }
}
origin: org.igniterealtime.smack/smackx

public List<PacketExtension> getExtensions()
{
  return (List<PacketExtension>)getItems();
}
 
origin: org.littleshoot/smack-xmpp-3-2-2

builder.append(getElementName());
builder.append(" node='");
builder.append(getNode());
builder.append(getElementName());
builder.append(">");
return builder.toString();
origin: igniterealtime/Smack

  /**
   * Delete the items with the specified id's from the node.
   *
   * @param itemIds The list of id's of items to delete
   * @throws XMPPErrorException
   * @throws NoResponseException if there was no response from the server.
   * @throws NotConnectedException
   * @throws InterruptedException
   */
  public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    List<Item> items = new ArrayList<>(itemIds.size());

    for (String id : itemIds) {
       items.add(new Item(id));
    }
    PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
    pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
  }
}
org.jivesoftware.smackx.pubsubItemsExtension

Javadoc

This class is used to for multiple purposes.
  • It can represent an event containing a list of items that have been published
  • It can represent an event containing a list of retracted (deleted) items.
  • It can represent a request to delete a list of items.
  • It can represent a request to get existing items.

    Please note, this class is used for internal purposes, and is not required for usage of pubsub functionality.

  • Most used methods

    • <init>
      Construct an instance with a list representing items that have been published or deleted.Valid scena
    • getElementName
    • getItems
      Gets the items related to the type of request or event. return List of Item, RetractItem, or null
    • getNode
    • toXML
    • getExtensions

    Popular in Java

    • Creating JSON documents from java classes using gson
    • compareTo (BigDecimal)
    • setRequestProperty (URLConnection)
    • runOnUiThread (Activity)
    • UnknownHostException (java.net)
      Thrown when a hostname can not be resolved.
    • Connection (java.sql)
      A connection represents a link from a Java application to a database. All SQL statements and results
    • LinkedList (java.util)
      Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
    • Scanner (java.util)
      A parser that parses a text string of primitive types and strings with the help of regular expressio
    • JPanel (javax.swing)
    • Logger (org.slf4j)
      The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
    • Top plugins for Android Studio
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now