001/* 002 * 003 * Copyright 2003-2010 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smackx.attention.packet; 018 019import javax.xml.namespace.QName; 020 021import org.jivesoftware.smack.packet.ExtensionElement; 022import org.jivesoftware.smack.packet.XmlEnvironment; 023import org.jivesoftware.smack.provider.ExtensionElementProvider; 024import org.jivesoftware.smack.util.XmlStringBuilder; 025import org.jivesoftware.smack.xml.XmlPullParser; 026 027import org.jxmpp.JxmppContext; 028 029/** 030 * A PacketExtension that implements XEP-0224: Attention 031 * 032 * This extension is expected to be added to message stanzas of type 'headline.' 033 * Please refer to the XEP for more implementation guidelines. 034 * 035 * @author Guus der Kinderen, guus.der.kinderen@gmail.com 036 * @see <a 037 * href="http://xmpp.org/extensions/xep-0224.html">XEP-0224: Attention</a> 038 */ 039public class AttentionExtension implements ExtensionElement { 040 041 /** 042 * The XML element name of an 'attention' extension. 043 */ 044 public static final String ELEMENT_NAME = "attention"; 045 046 /** 047 * The namespace that qualifies the XML element of an 'attention' extension. 048 */ 049 public static final String NAMESPACE = "urn:xmpp:attention:0"; 050 051 public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME); 052 053 @Override 054 public String getElementName() { 055 return QNAME.getLocalPart(); 056 } 057 058 @Override 059 public String getNamespace() { 060 return QNAME.getNamespaceURI(); 061 } 062 063 @Override 064 public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { 065 return new XmlStringBuilder(this).closeEmptyElement(); 066 } 067 068 /** 069 * A {@link ExtensionElementProvider} for the {@link AttentionExtension}. As 070 * Attention elements have no state/information other than the element name 071 * and namespace, this implementation simply returns new instances of 072 * {@link AttentionExtension}. 073 * 074 * @author Guus der Kinderen, guus.der.kinderen@gmail.com 075s */ 076 public static class Provider extends ExtensionElementProvider<AttentionExtension> { 077 078 @Override 079 public AttentionExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment, JxmppContext jxmppContext) { 080 return new AttentionExtension(); 081 } 082 } 083}