diff --git a/source/org/jivesoftware/smack/provider/ProviderManager.java b/source/org/jivesoftware/smack/provider/ProviderManager.java index 3e10adee7..0d31bca78 100644 --- a/source/org/jivesoftware/smack/provider/ProviderManager.java +++ b/source/org/jivesoftware/smack/provider/ProviderManager.java @@ -97,7 +97,7 @@ import java.net.URL; * used to try to automatically set properties of the IQ instance using the values found * in the IQ packet XML. For example, an XMPP time packet resembles the following: *
- * <iq type='get' to='joe@example.com' from='mary@example.com' id='time_1'>
+ * <iq type='result' to='joe@example.com' from='mary@example.com' id='time_1'>
  *     <query xmlns='jabber:iq:time'>
  *         <utc>20020910T17:58:35</utc>
  *         <tz>MDT</tz>
@@ -233,19 +233,61 @@ public class ProviderManager {
         catch (Exception e) { }
     }
 
+    /**
+     * Returns the IQ provider registered to the specified XML element name and namespace.
+     * For example, if a provider was registered to the element name "query" and the
+     * namespace "jabber:iq:time", then the following packet would trigger the provider:
+     *
+     * 
+     * <iq type='result' to='joe@example.com' from='mary@example.com' id='time_1'>
+     *     <query xmlns='jabber:iq:time'>
+     *         <utc>20020910T17:58:35</utc>
+     *         <tz>MDT</tz>
+     *         <display>Tue Sep 10 12:58:35 2002</display>
+     *     </query>
+     * </iq>
+ * + * @param elementName the XML element name. + * @param namespace the XML namespace. + * @return + */ public synchronized static Object getIQProvider(String elementName, String namespace) { String key = getProviderKey(elementName, namespace); return iqProviders.get(key); } + /** + * Returns the packet extension provider registered to the specified XML element name + * and namespace. For example, if a provider was registered to the element name "x" and the + * namespace "jabber:x:event", then the following packet would trigger the provider: + * + *
+     * <message to='romeo@montague.net' id='message_1'>
+     *     <body>Art thou not Romeo, and a Montague?</body>
+     *     <x xmlns='jabber:x:event'>
+     *         <composing/>
+     *     </x>
+     * </message>
+ * + * @param elementName + * @param namespace + * @return + */ public synchronized static Object getExtensionProvider(String elementName, String namespace) { String key = getProviderKey(elementName, namespace); return extensionProviders.get(key); } - private static String getProviderKey(String elementName, String nameSpace) { + /** + * Returns a String key for a given element name and namespace. + * + * @param elementName the element name. + * @param namespace the namespace. + * @return a unique key for the element name and namespace pair. + */ + private static String getProviderKey(String elementName, String namespace) { StringBuffer buf = new StringBuffer(); - buf.append("<").append(elementName).append("/><").append(nameSpace).append("/>"); + buf.append("<").append(elementName).append("/><").append(namespace).append("/>"); return buf.toString(); } @@ -280,4 +322,4 @@ public class ProviderManager { } return parser; } -} +} \ No newline at end of file