本文整理汇总了Java中org.jivesoftware.smackx.packet.DefaultPrivateData类的典型用法代码示例。如果您正苦于以下问题:Java DefaultPrivateData类的具体用法?Java DefaultPrivateData怎么用?Java DefaultPrivateData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultPrivateData类属于org.jivesoftware.smackx.packet包,在下文中一共展示了DefaultPrivateData类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseIQ
import org.jivesoftware.smackx.packet.DefaultPrivateData; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
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 PrivateDataResult(privateData);
}
示例2: parseIQ
import org.jivesoftware.smackx.packet.DefaultPrivateData; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
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 PrivateDataResult(privateData);
}