|
Jitsi: the OpenSource Java VoIP and Instant Messaging client. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.java.sip.communicator.impl.protocol.jabber.extensions.AbstractPacketExtension
public abstract class AbstractPacketExtension
A generic implementation of PacketExtension. The purpose of this
class is quite similar to that of smack's DefaultPacketExtension
with the main difference being that this one is meant primarily for
extension rather than using as a fallback for unknown elements. We let for
example our descendants handle child elements and we automate attribute
handling instead.
| Field Summary | |
|---|---|
protected Map<String,String> |
attributes
A map of all attributes that this extension is currently using. |
| Constructor Summary | |
|---|---|
protected |
AbstractPacketExtension(String namespace,
String elementName)
Creates an AbstractPacketExtension instance for the specified
namespace and elementName. |
| Method Summary | ||
|---|---|---|
void |
addChildExtension(org.jivesoftware.smack.packet.PacketExtension childExtension)
Adds the specified childExtension to the list of extensions registered with this packet. |
|
Object |
getAttribute(String attribute)
Returns the attribute with the specified name from the list of attributes registered with this packet extension. |
|
int |
getAttributeAsInt(String attribute)
Returns the int value of the attribute with the specified name. |
|
int |
getAttributeAsInt(String attribute,
int defaultValue)
Returns the int value of the attribute with the specified name. |
|
String |
getAttributeAsString(String attribute)
Returns the string value of the attribute with the specified name. |
|
URI |
getAttributeAsURI(String attribute)
Tries to parse the value of the specified attribute as an URI and returns it. |
|
List<String> |
getAttributeNames()
Gets the names of the attributes which currently have associated values in this extension. |
|
List<? extends org.jivesoftware.smack.packet.PacketExtension> |
getChildExtensions()
Returns all sub-elements for this AbstractPacketExtension or null if there aren't any. |
|
|
getChildExtensionsOfType(Class<T> type)
Returns this packet's direct child extensions that match the specified type. |
|
String |
getElementName()
Returns the name of the encryption element. |
|
|
getFirstChildOfType(Class<T> type)
Returns this packet's first direct child extension that matches the specified type. |
|
String |
getNamespace()
Returns the XML namespace for this element or null if the element does not live in a namespace of its own. |
|
String |
getText()
Returns the text content of this extension or null if no text content has been specified so far. |
|
void |
removeAttribute(String name)
Removes the attribute with the specified name from the list of attributes registered with this packet extension. |
|
void |
setAttribute(String name,
Object value)
Sets the value of the attribute named name to value. |
|
void |
setNamespace(String namespace)
Set the XML namespace for this element. |
|
void |
setText(String text)
Specifies the text content of this extension. |
|
String |
toXML()
Returns an XML representation of this extension. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Map<String,String> attributes
| Constructor Detail |
|---|
protected AbstractPacketExtension(String namespace,
String elementName)
AbstractPacketExtension instance for the specified
namespace and elementName.
namespace - the XML namespace for this element.elementName - the name of the element| Method Detail |
|---|
public String getElementName()
getElementName in interface org.jivesoftware.smack.packet.PacketExtensionpublic void setNamespace(String namespace)
namespace - the XML namespace for this element.public String getNamespace()
getNamespace in interface org.jivesoftware.smack.packet.PacketExtensionpublic String toXML()
toXML in interface org.jivesoftware.smack.packet.PacketExtensionpublic List<? extends org.jivesoftware.smack.packet.PacketExtension> getChildExtensions()
Overriding extensions may need to override this method if they would like to have anything more elaborate than just a list of extensions.
List of elements that this packet extension contains.public void addChildExtension(org.jivesoftware.smack.packet.PacketExtension childExtension)
childExtension - the extension we'd like to add here.
public void setAttribute(String name,
Object value)
name - the name of the attribute that we are setting.value - an Object whose toString() method returns
the XML value of the attribute we are setting or null if we'd
like to remove the attribute with the specified name.public void removeAttribute(String name)
name - the name of the attribute that we are removing.public Object getAttribute(String attribute)
attribute - the name of the attribute that we'd like to retrieve.
public String getAttributeAsString(String attribute)
attribute - the name of the attribute that we'd like to retrieve.
public int getAttributeAsInt(String attribute)
attribute - the name of the attribute that we'd like to retrieve.
public int getAttributeAsInt(String attribute,
int defaultValue)
attribute - the name of the attribute that we'd like to retrievedefaultValue - the int to be returned as the value of the
specified attribute if no such attribute is currently registered with
this extension
public URI getAttributeAsURI(String attribute)
throws IllegalArgumentException
attribute - the name of the attribute that we'd like to retrieve.
IllegalArgumentException - if attribute is not a valid URIpublic List<String> getAttributeNames()
public void setText(String text)
text - the text content of this extension.public String getText()
public <T extends org.jivesoftware.smack.packet.PacketExtension> T getFirstChildOfType(Class<T> type)
T - the specific type of PacketExtension to be returnedtype - the Class of the extension we are looking for.
public <T extends org.jivesoftware.smack.packet.PacketExtension> List<T> getChildExtensionsOfType(Class<T> type)
T - the specific PacketExtension type of child extensions
to be returnedtype - the Class of the extension we are looking for.
|
Jitsi: the OpenSource Java VoIP and Instant Messaging client. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||