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 org.jivesoftware.smack.packet.ExtensionElement; 020import org.jivesoftware.smack.packet.XmlEnvironment; 021import org.jivesoftware.smack.provider.ExtensionElementProvider; 022import org.jivesoftware.smack.util.XmlStringBuilder; 023import org.jivesoftware.smack.xml.XmlPullParser; 024 025/** 026 * A PacketExtension that implements XEP-0224: Attention 027 * 028 * This extension is expected to be added to message stanzas of type 'headline.' 029 * Please refer to the XEP for more implementation guidelines. 030 * 031 * @author Guus der Kinderen, guus.der.kinderen@gmail.com 032 * @see <a 033 * href="http://xmpp.org/extensions/xep-0224.html">XEP-0224: Attention</a> 034 */ 035public class AttentionExtension implements ExtensionElement { 036 037 /** 038 * The XML element name of an 'attention' extension. 039 */ 040 public static final String ELEMENT_NAME = "attention"; 041 042 /** 043 * The namespace that qualifies the XML element of an 'attention' extension. 044 */ 045 public static final String NAMESPACE = "urn:xmpp:attention:0"; 046 047 /* 048 * (non-Javadoc) 049 * 050 * @see org.jivesoftware.smack.packet.PacketExtension#getElementName() 051 */ 052 @Override 053 public String getElementName() { 054 return ELEMENT_NAME; 055 } 056 057 /* 058 * (non-Javadoc) 059 * 060 * @see org.jivesoftware.smack.packet.PacketExtension#getNamespace() 061 */ 062 @Override 063 public String getNamespace() { 064 return NAMESPACE; 065 } 066 067 /* 068 * (non-Javadoc) 069 * 070 * @see org.jivesoftware.smack.packet.PacketExtension#toXML() 071 */ 072 @Override 073 public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { 074 return new XmlStringBuilder(this).closeEmptyElement(); 075 } 076 077 /** 078 * A {@link ExtensionElementProvider} for the {@link AttentionExtension}. As 079 * Attention elements have no state/information other than the element name 080 * and namespace, this implementation simply returns new instances of 081 * {@link AttentionExtension}. 082 * 083 * @author Guus der Kinderen, guus.der.kinderen@gmail.com 084s */ 085 public static class Provider extends ExtensionElementProvider<AttentionExtension> { 086 087 @Override 088 public AttentionExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) { 089 return new AttentionExtension(); 090 } 091 } 092}