本文整理汇总了Java中org.jivesoftware.smack.provider.PacketExtensionProvider类的典型用法代码示例。如果您正苦于以下问题:Java PacketExtensionProvider类的具体用法?Java PacketExtensionProvider怎么用?Java PacketExtensionProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketExtensionProvider类属于org.jivesoftware.smack.provider包,在下文中一共展示了PacketExtensionProvider类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
/**
* Parses a PEPEvent packet and extracts a PEPItem from it.
* (There is only one per <event>.)
*
* @param parser the XML parser, positioned at the starting element of the extension.
* @return a PacketExtension.
* @throws Exception if a parsing error occurs.
*/
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("event")) {
} else if (parser.getName().equals("items")) {
// Figure out the node for this event.
String node = parser.getAttributeValue("", "node");
// Get the parser for this kind of node, and if found then parse the node.
PacketExtensionProvider nodeParser = nodeParsers.get(node);
if (nodeParser != null) {
pepItem = nodeParser.parseExtension(parser);
}
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("event")) {
done = true;
}
}
}
return pepItem;
}
示例2: CcsClient
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
private CcsClient() {
// Add FcmPacketExtension
ProviderManager.getInstance().addExtensionProvider(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE,
new PacketExtensionProvider() {
@Override
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
String json = parser.nextText();
FcmPacketExtension packet = new FcmPacketExtension(json);
return packet;
}
});
}
示例3: parseExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
/**
* Parses a PEPEvent packet and extracts a PEPItem from it. (There is only
* one per <event>.)
*
* @param parser
* the XML parser, positioned at the starting element of the
* extension.
* @return a PacketExtension.
* @throws Exception
* if a parsing error occurs.
*/
public PacketExtension parseExtension(XmlPullParser parser)
throws Exception {
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("event")) {
} else if (parser.getName().equals("items")) {
// Figure out the node for this event.
String node = parser.getAttributeValue("", "node");
// Get the parser for this kind of node, and if found then
// parse the node.
PacketExtensionProvider nodeParser = nodeParsers.get(node);
if (nodeParser != null) {
pepItem = nodeParser.parseExtension(parser);
}
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("event")) {
done = true;
}
}
}
return pepItem;
}
示例4: CcsClient
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
private CcsClient() {
// Add GcmPacketExtension
ProviderManager.getInstance().addExtensionProvider(GCM_ELEMENT_NAME,
GCM_NAMESPACE, new PacketExtensionProvider() {
@Override
public PacketExtension parseExtension(XmlPullParser parser)
throws Exception {
String json = parser.nextText();
GcmPacketExtension packet = new GcmPacketExtension(json);
return packet;
}
});
}
示例5: addSimplePacketExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
private static void addSimplePacketExtension(final String name, final String namespace) {
ProviderManager.getInstance().addExtensionProvider(name, namespace,
new PacketExtensionProvider() {
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace);
int attributeCount = parser.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
packet.addAttribute(parser.getAttributeName(i),
parser.getAttributeValue(i));
}
return packet;
}
});
}
示例6: addSimplePacketExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
private static void addSimplePacketExtension(final String name, final String namespace) {
ProviderManager.getInstance().addExtensionProvider(name, namespace,
new PacketExtensionProvider() {
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace);
int attributeCount = parser.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
packet.addAttribute(parser.getAttributeName(i),
parser.getAttributeValue(i));
}
return packet;
}
});
}
示例7: parsePacketExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
/**
* Parses a packet extension sub-packet.
*
* @param elementName the XML element name of the packet extension.
* @param namespace the XML namespace of the packet extension.
* @param parser the XML parser, positioned at the starting element of the extension.
* @return a PacketExtension.
* @throws Exception if a parsing error occurs.
*/
public static PacketExtension parsePacketExtension(String elementName, String namespace, XmlPullParser parser)
throws Exception
{
// See if a provider is registered to handle the extension.
Object provider = ProviderManager.getInstance().getExtensionProvider(elementName, namespace);
if (provider != null) {
if (provider instanceof PacketExtensionProvider) {
return ((PacketExtensionProvider)provider).parseExtension(parser);
}
else if (provider instanceof Class) {
return (PacketExtension)parseWithIntrospection(
elementName, (Class)provider, parser);
}
}
// No providers registered, so use a default extension.
DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
String name = parser.getName();
// If an empty element, set the value with the empty string.
if (parser.isEmptyElementTag()) {
extension.setValue(name,"");
}
// Otherwise, get the the element text.
else {
eventType = parser.next();
if (eventType == XmlPullParser.TEXT) {
String value = parser.getText();
extension.setValue(name, value);
}
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(elementName)) {
done = true;
}
}
}
return extension;
}
示例8: registerPEPParserExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
public void registerPEPParserExtension(String node, PacketExtensionProvider pepItemParser) {
nodeParsers.put(node, pepItemParser);
}
示例9: parsePacketExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
/**
* Parses a packet extension sub-packet.
*
* @param elementName the XML element name of the packet extension.
* @param namespace the XML namespace of the packet extension.
* @param parser the XML parser, positioned at the starting element of the extension.
* @return a PacketExtension.
* @throws Exception if a parsing error occurs.
*/
public static PacketExtension parsePacketExtension(String elementName, String namespace, XmlPullParser parser)
throws Exception
{
// See if a provider is registered to handle the extension.
Object provider = ProviderManager.getInstance().getExtensionProvider(elementName, namespace);
if (provider != null) {
if (provider instanceof PacketExtensionProvider) {
return ((PacketExtensionProvider)provider).parseExtension(parser);
}
else if (provider instanceof Class) {
return (PacketExtension)parseWithIntrospection(
elementName, (Class<?>)provider, parser);
}
}
// No providers registered, so use a default extension.
DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
String name = parser.getName();
// If an empty element, set the value with the empty string.
if (parser.isEmptyElementTag()) {
extension.setValue(name,"");
}
// Otherwise, get the the element text.
else {
eventType = parser.next();
if (eventType == XmlPullParser.TEXT) {
String value = parser.getText();
extension.setValue(name, value);
}
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(elementName)) {
done = true;
}
}
}
return extension;
}
示例10: parsePacketExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
/**
* Parses a packet extension sub-packet.
*
* @param elementName
* the XML element name of the packet extension.
* @param namespace
* the XML namespace of the packet extension.
* @param parser
* the XML parser, positioned at the starting element of the
* extension.
* @return a PacketExtension.
* @throws Exception
* if a parsing error occurs.
*/
public static PacketExtension parsePacketExtension(String elementName,
String namespace, XmlPullParser parser) throws Exception {
// See if a provider is registered to handle the extension.
Object provider = ProviderManager.getInstance().getExtensionProvider(
elementName, namespace);
if (provider != null) {
if (provider instanceof PacketExtensionProvider) {
return ((PacketExtensionProvider) provider)
.parseExtension(parser);
} else if (provider instanceof Class) {
return (PacketExtension) parseWithIntrospection(elementName,
(Class) provider, parser);
}
}
// No providers registered, so use a default extension.
DefaultPacketExtension extension = new DefaultPacketExtension(
elementName, namespace);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
String name = parser.getName();
// If an empty element, set the value with the empty string.
if (parser.isEmptyElementTag()) {
extension.setValue(name, "");
}
// Otherwise, get the the element text.
else {
eventType = parser.next();
if (eventType == XmlPullParser.TEXT) {
String value = parser.getText();
extension.setValue(name, value);
}
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(elementName)) {
done = true;
}
}
}
return extension;
}
示例11: registerPEPParserExtension
import org.jivesoftware.smack.provider.PacketExtensionProvider; //导入依赖的package包/类
public void registerPEPParserExtension(String node,
PacketExtensionProvider pepItemParser) {
nodeParsers.put(node, pepItemParser);
}