当前位置: 首页>>代码示例>>Java>>正文


Java PrivateDataProvider类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider的典型用法代码示例。如果您正苦于以下问题:Java PrivateDataProvider类的具体用法?Java PrivateDataProvider怎么用?Java PrivateDataProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrivateDataProvider类属于org.jivesoftware.smackx.iqprivate.provider包,在下文中一共展示了PrivateDataProvider类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider; //导入依赖的package包/类
@Override
public PrivateDataIQ parse(XmlPullParser parser, int initialDepth)
                throws XmlPullParserException, IOException, SmackException {
    PrivateData privateData = null;
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            String elementName = parser.getName();
            String namespace = parser.getNamespace();
            // See if any objects are registered to handle this private data type.
            PrivateDataProvider provider = getPrivateDataProvider(elementName, namespace);
            // If there is a registered provider, use it.
            if (provider != null) {
                privateData = provider.parsePrivateData(parser);
            }
            // Otherwise, use a DefaultPrivateData instance to store the private data.
            else {
                DefaultPrivateData data = new DefaultPrivateData(elementName, namespace);
                boolean finished = false;
                while (!finished) {
                    int event = parser.next();
                    if (event == XmlPullParser.START_TAG) {
                        String name = parser.getName();
                        // If an empty element, set the value with the empty string.
                        if (parser.isEmptyElementTag()) {
                            data.setValue(name,"");
                        }
                        // Otherwise, get the the element text.
                        else {
                            event = parser.next();
                            if (event == XmlPullParser.TEXT) {
                                String value = parser.getText();
                                data.setValue(name, value);
                            }
                        }
                    }
                    else if (event == XmlPullParser.END_TAG) {
                        if (parser.getName().equals(elementName)) {
                            finished = true;
                        }
                    }
                }
                privateData = data;
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return new PrivateDataIQ(privateData);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:55,代码来源:PrivateDataManager.java

示例2: addPrivateDataProvider

import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider; //导入依赖的package包/类
/**
 * Adds a private data provider with the specified element name and name space. The provider
 * will override any providers loaded through the classpath.
 *
 * @param elementName the XML element name.
 * @param namespace the XML namespace.
 * @param provider the private data provider.
 */
public static void addPrivateDataProvider(String elementName, String namespace,
        PrivateDataProvider provider)
{
    String key = getProviderKey(elementName, namespace);
    privateDataProviders.put(key, provider);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:PrivateDataManager.java

示例3: getPrivateDataProvider

import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider; //导入依赖的package包/类
/**
 * Returns the private data provider registered to the specified XML element name and namespace.
 * For example, if a provider was registered to the element name "prefs" and the
 * namespace "http://www.xmppclient.com/prefs", then the following stanza(/packet) would trigger
 * the provider:
 *
 * <pre>
 * &lt;iq type='result' to='[email protected]' from='[email protected]' id='time_1'&gt;
 *     &lt;query xmlns='jabber:iq:private'&gt;
 *         &lt;prefs xmlns='http://www.xmppclient.com/prefs'&gt;
 *             &lt;value1&gt;ABC&lt;/value1&gt;
 *             &lt;value2&gt;XYZ&lt;/value2&gt;
 *         &lt;/prefs&gt;
 *     &lt;/query&gt;
 * &lt;/iq&gt;</pre>
 *
 * <p>Note: this method is generally only called by the internal Smack classes.
 *
 * @param elementName the XML element name.
 * @param namespace the XML namespace.
 * @return the PrivateData provider.
 */
public static PrivateDataProvider getPrivateDataProvider(String elementName, String namespace) {
    String key = getProviderKey(elementName, namespace);
    return (PrivateDataProvider)privateDataProviders.get(key);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:PrivateDataManager.java


注:本文中的org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。