public class DefaultPacketExtension extends Object implements PacketExtension
ProviderManager,
instances of this class will be returned when getting packet extensions.This class provides a very simple representation of an XML sub-document. Each element is a key in a Map with its CDATA being the value. For example, given the following XML sub-document:
<foo xmlns="http://bar.com">
<color>blue</color>
<food>pizza</food>
</foo>
In this case, getValue("color") would return "blue", and getValue("food") would
return "pizza". This parsing mechanism mechanism is very simplistic and will not work
as desired in all cases (for example, if some of the elements have attributes. In those
cases, a custom PacketExtensionProvider should be used.| Constructor and Description |
|---|
DefaultPacketExtension(String elementName,
String namespace)
Creates a new generic packet extension.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getElementName()
Returns the XML element name of the extension sub-packet root element.
|
Collection<String> |
getNames()
Returns an unmodifiable collection of the names that can be used to get
values of the packet extension.
|
String |
getNamespace()
Returns the XML namespace of the extension sub-packet root element.
|
String |
getValue(String name)
Returns a packet extension value given a name.
|
void |
setValue(String name,
String value)
Sets a packet extension value using the given name.
|
CharSequence |
toXML()
Returns the XML representation of the PacketExtension.
|
public DefaultPacketExtension(String elementName, String namespace)
elementName - the name of the element of the XML sub-document.namespace - the namespace of the element.public String getElementName()
getElementName in interface PacketExtensionpublic String getNamespace()
getNamespace in interface PacketExtensionpublic CharSequence toXML()
PacketExtensiontoXML in interface PacketExtensionpublic Collection<String> getNames()
public String getValue(String name)
name - the name.