Class DefaultPrivateData
java.lang.Object
org.jivesoftware.smackx.iqprivate.packet.DefaultPrivateData
- All Implemented Interfaces:
PrivateData
Default implementation of the PrivateData interface. Unless a PrivateDataProvider
is registered with the PrivateDataManager class, instances of this class will be
returned when getting private data.
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
PrivateDataProvider
should be used.-
Constructor Summary
ConstructorDescriptionDefaultPrivateData
(String elementName, String namespace) Creates a new generic private data object. -
Method Summary
Modifier and TypeMethodDescriptionReturns the XML element name of the private data sub-packet root element.getNames()
Returns a Set of the names that can be used to get values of the private data.Returns the XML namespace of the private data sub-packet root element.Returns a value given a name.void
Sets a value given the name.toXML()
Returns the XML representation of the PrivateData.
-
Constructor Details
-
DefaultPrivateData
Creates a new generic private data object.- Parameters:
elementName
- the name of the element of the XML sub-document.namespace
- the namespace of the element.
-
-
Method Details
-
getElementName
Returns the XML element name of the private data sub-packet root element.- Specified by:
getElementName
in interfacePrivateData
- Returns:
- the XML element name of the stanza extension.
-
getNamespace
Returns the XML namespace of the private data sub-packet root element.- Specified by:
getNamespace
in interfacePrivateData
- Returns:
- the XML namespace of the stanza extension.
-
toXML
Description copied from interface:PrivateData
Returns the XML representation of the PrivateData.- Specified by:
toXML
in interfacePrivateData
- Returns:
- the private data as XML.
-
getNames
Returns a Set of the names that can be used to get values of the private data.- Returns:
- a Set of the names.
-
getValue
Returns a value given a name.- Parameters:
name
- the name.- Returns:
- the value.
-
setValue
Sets a value given the name.- Parameters:
name
- the name.value
- the value.
-