|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.smack.packet.DefaultPacketExtension
public class DefaultPacketExtension
Default implementation of the PacketExtension interface. Unless a PacketExtensionProvider
is registered with 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 Summary | |
---|---|
DefaultPacketExtension(String elementName,
String namespace)
Creates a new generic packet extension. |
Method Summary | |
---|---|
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. |
String |
toXML()
Returns the XML reppresentation of the PacketExtension. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultPacketExtension(String elementName, String namespace)
elementName
- the name of the element of the XML sub-document.namespace
- the namespace of the element.Method Detail |
---|
public String getElementName()
getElementName
in interface PacketExtension
public String getNamespace()
getNamespace
in interface PacketExtension
public String toXML()
PacketExtension
toXML
in interface PacketExtension
public Collection<String> getNames()
public String getValue(String name)
name
- the name.
public void setValue(String name, String value)
name
- the name.value
- the value.
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |