1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 21:17:58 +01:00

Javadoc improvements.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2049 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-08-20 16:03:32 +00:00 committed by mtucker
parent 83275fa888
commit 3c3b3d5cdf
2 changed files with 30 additions and 11 deletions

View file

@ -65,7 +65,20 @@ import java.util.Map;
import java.util.Hashtable; import java.util.Hashtable;
/** /**
* Manages private data. * Manages private data, which is a mechanism to allow users to store arbitrary XML
* data on an XMPP server. Each private data chunk is defined by a element name and
* XML namespace. Example private data:
*
* <pre>
* &lt;color xmlns="http://example.com/xmpp/color"&gt;
* &lt;favorite&gt;blue&lt;/blue&gt;
* &lt;leastFavorite&gt;puce&lt;/leastFavorite&gt;
* &lt;/color&gt;
* </pre>
*
* {@link PrivateDataProvider} instances are responsible for translating the XML into objects.
* If no PrivateDataProvider is registered for a given element name and namespace, then
* a {@link DefaultPrivateData} instance will be returned.
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
@ -119,15 +132,21 @@ public class PrivateDataManager {
} }
private XMPPConnection con; private XMPPConnection connection;
/** /**
* Creates a new private data manager. * Creates a new private data manager. The connection must have
* undergone a successful login before being used to construct an instance of
* this class.
* *
* @param con an XMPPConnection. * @param connection an XMPP connection which must have already undergone a
* successful login.
*/ */
public PrivateDataManager(XMPPConnection con) { public PrivateDataManager(XMPPConnection connection) {
this.con = con; if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must be logged in to XMPP server.");
}
this.connection = connection;
} }
/** /**
@ -160,10 +179,10 @@ public class PrivateDataManager {
// Setup a listener for the reply to the set operation. // Setup a listener for the reply to the set operation.
String packetID = privateDataGet.getPacketID(); String packetID = privateDataGet.getPacketID();
PacketCollector collector = con.createPacketCollector(new PacketIDFilter(packetID)); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(packetID));
// Send the private data. // Send the private data.
con.sendPacket(privateDataGet); connection.sendPacket(privateDataGet);
// Wait up to five seconds for a response from the server. // Wait up to five seconds for a response from the server.
IQ response = (IQ)collector.nextResult(5000); IQ response = (IQ)collector.nextResult(5000);
@ -200,10 +219,10 @@ public class PrivateDataManager {
// Setup a listener for the reply to the set operation. // Setup a listener for the reply to the set operation.
String packetID = privateDataSet.getPacketID(); String packetID = privateDataSet.getPacketID();
PacketCollector collector = con.createPacketCollector(new PacketIDFilter(packetID)); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(packetID));
// Send the private data. // Send the private data.
con.sendPacket(privateDataSet); connection.sendPacket(privateDataSet);
// Wait up to five seconds for a response from the server. // Wait up to five seconds for a response from the server.
IQ response = (IQ)collector.nextResult(5000); IQ response = (IQ)collector.nextResult(5000);

View file

@ -75,7 +75,7 @@ import java.util.HashMap;
* In this case, getValue("color") would return "blue", and getValue("food") would * 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 * 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 * as desired in all cases (for example, if some of the elements have attributes. In those
* cases, a custom PrivateDataProvider should be used. * cases, a custom {@link org.jivesoftware.smackx.provider.PrivateDataProvider} should be used.
* *
* @author Matt Tucker * @author Matt Tucker
*/ */