org.jivesoftware.smack.packet.NamedElement Java Examples
The following examples show how to use
org.jivesoftware.smack.packet.NamedElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AvatarSendReceiver.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
void processMetadataEvent(JID jid, ItemsExtension itemsExt) { List<? extends NamedElement> items = itemsExt.getItems(); if (items.isEmpty()) { LOGGER.warning("no items in items event"); return; } // there should be only one item NamedElement e = items.get(0); if (!(e instanceof PayloadItem)) { LOGGER.warning("element not a payloaditem"); return; } PayloadItem item = (PayloadItem) e; ExtensionElement metadataExt = item.getPayload(); if (!(metadataExt instanceof AvatarMetadataExtension)) { LOGGER.warning("payload not avatar metadata"); return; } AvatarMetadataExtension metadata = (AvatarMetadataExtension) metadataExt; List<AvatarMetadataExtension.Info> infos = metadata.getInfos(); if (infos.isEmpty()) { // this means the contact disabled avatar publishing mHandler.onNotify(jid, ""); return; } // assuming infos are always in the same order for (AvatarMetadataExtension.Info info : infos) { if (AvatarHandler.SUPPORTED_TYPES.contains(info.getType())) { mHandler.onNotify(jid, info.getId()); break; } else { LOGGER.info("image type not supported: "+info.getType()); } } }
Example #2
Source File: XmlStringBuilder.java From Smack with Apache License 2.0 | 5 votes |
public XmlStringBuilder optTextChild(CharSequence sqc, NamedElement parentElement) { if (sqc == null) { return closeEmptyElement(); } rightAngleBracket(); escape(sqc); closeElement(parentElement); return this; }
Example #3
Source File: Header.java From Smack with Apache License 2.0 | 5 votes |
@Override public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { // Upcast to NamedElement since we don't want a xmlns attribute XmlStringBuilder xml = new XmlStringBuilder((NamedElement) this); xml.attribute("name", name); xml.rightAngleBracket(); xml.escape(value); xml.closeElement(this); return xml; }
Example #4
Source File: JingleContentDescription.java From Smack with Apache License 2.0 | 5 votes |
protected JingleContentDescription(List<? extends NamedElement> payloads) { if (payloads != null) { this.payloads = Collections.unmodifiableList(payloads); } else { this.payloads = Collections.emptyList(); } }
Example #5
Source File: AbstractHttpOverXmppProvider.java From Smack with Apache License 2.0 | 4 votes |
/** * Parses Data element if any. * * @param parser parser * @return Data or null if no data * * @throws XmlPullParserException if an error in the XML parser occurred. * @throws IOException if an I/O error occurred. */ protected AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException { NamedElement child = null; boolean done = false; AbstractHttpOverXmpp.Data data = null; /* We are either at start of data or end of req/res */ if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT) { while (!done) { XmlPullParser.Event eventType = parser.next(); if (eventType == XmlPullParser.Event.START_ELEMENT) { switch (parser.getName()) { case ELEMENT_TEXT: child = parseText(parser); break; case ELEMENT_BASE_64: child = parseBase64(parser); break; case ELEMENT_CHUNKED_BASE_64: child = parseChunkedBase64(parser); break; case ELEMENT_XML: child = parseXml(parser); break; case ELEMENT_IBB: child = parseIbb(parser); break; case ELEMENT_SIPUB: // TODO: sipub is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("sipub is not supported yet"); case ELEMENT_JINGLE: // TODO: jingle is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("jingle is not supported yet"); default: // other elements are not allowed throw new IllegalArgumentException("unsupported child tag: " + parser.getName()); } } else if (eventType == XmlPullParser.Event.END_ELEMENT) { if (parser.getName().equals(ELEMENT_DATA)) { done = true; } } } data = new AbstractHttpOverXmpp.Data(child); } return data; }
Example #6
Source File: XmlStringBuilder.java From Smack with Apache License 2.0 | 4 votes |
public XmlStringBuilder(NamedElement e) { this(); halfOpenElement(e.getElementName()); }
Example #7
Source File: XmlStringBuilder.java From Smack with Apache License 2.0 | 4 votes |
public XmlStringBuilder halfOpenElement(NamedElement namedElement) { return halfOpenElement(namedElement.getElementName()); }
Example #8
Source File: XmlStringBuilder.java From Smack with Apache License 2.0 | 4 votes |
public XmlStringBuilder closeElement(NamedElement e) { closeElement(e.getElementName()); return this; }
Example #9
Source File: JingleContentDescription.java From Smack with Apache License 2.0 | 4 votes |
public List<NamedElement> getJingleContentDescriptionChildren() { return payloads; }
Example #10
Source File: AbstractHttpOverXmpp.java From Smack with Apache License 2.0 | 2 votes |
/** * Creates Data element. * * @param child element nested by Data */ public Data(NamedElement child) { this.child = child; }
Example #11
Source File: AbstractHttpOverXmpp.java From Smack with Apache License 2.0 | 2 votes |
/** * Returns element nested by Data. * * @return element nested by Data */ public NamedElement getChild() { return child; }
Example #12
Source File: ItemsExtension.java From Smack with Apache License 2.0 | 2 votes |
/** * Construct an instance with a list representing items that have been published or deleted. * * <p>Valid scenarios are:</p> * <ul> * <li>Request items from node - itemsType = {@link ItemsElementType#items}, items = list of {@link Item} and an * optional value for the <b>max_items</b> attribute. * <li>Request to delete items - itemsType = {@link ItemsElementType#retract}, items = list of {@link Item} containing * only id's and an optional value for the <b>notify</b> attribute. * <li>Items published event - itemsType = {@link ItemsElementType#items}, items = list of {@link Item} and * attributeValue = <code>null</code> * <li>Items deleted event - itemsType = {@link ItemsElementType#items}, items = list of {@link RetractItem} and * attributeValue = <code>null</code> * </ul> * * @param itemsType Type of representation * @param nodeId The node to which the items are being sent or deleted * @param items The list of {@link Item} or {@link RetractItem} */ public ItemsExtension(ItemsElementType itemsType, String nodeId, List<? extends NamedElement> items) { super(itemsType.getNodeElement(), nodeId); type = itemsType; this.items = items; }
Example #13
Source File: ItemsExtension.java From Smack with Apache License 2.0 | 2 votes |
/** * Gets the items related to the type of request or event. * * @return List of {@link Item}, {@link RetractItem}, or null */ // TODO: Shouldn't this return List<Item>? Why is RetractItem not a subtype of item? public List<? extends NamedElement> getItems() { return items; }