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


Java PacketParserUtils.addExtensionElement方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement方法的典型用法代码示例。如果您正苦于以下问题:Java PacketParserUtils.addExtensionElement方法的具体用法?Java PacketParserUtils.addExtensionElement怎么用?Java PacketParserUtils.addExtensionElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.util.PacketParserUtils的用法示例。


在下文中一共展示了PacketParserUtils.addExtensionElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
                SmackException {
    final String namespace = parser.getNamespace();
    final String name = parser.getName();
    final int attributeCount = parser.getAttributeCount();
    Map<String, String> attMap = new HashMap<>(attributeCount);

    for (int i = 0; i < attributeCount; i++) {
        attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
    }

    List<ExtensionElement> extensions = new ArrayList<>();
    int event;
    do {
        event = parser.next();

        if (event == XmlPullParser.START_TAG)
            PacketParserUtils.addExtensionElement(extensions, parser);
    }
    while (!(event == XmlPullParser.END_TAG && parser.getDepth() == initialDepth));

    return createReturnExtension(name, namespace, attMap, extensions);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:EmbeddedExtensionProvider.java

示例2: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    TranscriptSearch answer = new TranscriptSearch();

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            // Parse the packet extension
            PacketParserUtils.addExtensionElement(answer, parser);
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(ELEMENT_NAME)) {
                done = true;
            }
        }
    }

    return answer;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:TranscriptSearch.java

示例3: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public WorkgroupForm parse(XmlPullParser parser, int initialDepth)
                throws XmlPullParserException, IOException,
                SmackException {
    WorkgroupForm answer = new WorkgroupForm();

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            // Parse the packet extension
            PacketParserUtils.addExtensionElement(answer, parser);
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(ELEMENT_NAME)) {
                done = true;
            }
        }
    }

    return answer;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:23,代码来源:WorkgroupForm.java

示例4: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
   public PubSub parse(XmlPullParser parser, int initialDepth)
                   throws XmlPullParserException, IOException, SmackException {
       String namespace = parser.getNamespace();
       PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
       PubSub pubsub = new PubSub(pubSubNamespace);

       outerloop: while (true) 
       {
           int eventType = parser.next();
           switch (eventType) {
           case XmlPullParser.START_TAG:
               PacketParserUtils.addExtensionElement(pubsub, parser);
               break;
           case XmlPullParser.END_TAG:
               if (parser.getDepth() == initialDepth) {
                   break outerloop;
               }
               break;
           }
       }
       return pubsub;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:PubSubProvider.java

示例5: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public MUCOwner parse(XmlPullParser parser, int initialDepth)
                throws XmlPullParserException, IOException, SmackException {
    MUCOwner mucOwner = new MUCOwner();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("item")) {
                mucOwner.addItem(MUCParserUtils.parseItem(parser));
            }
            else if (parser.getName().equals("destroy")) {
                mucOwner.setDestroy(MUCParserUtils.parseDestroy(parser));
            }
            // Otherwise, it must be a packet extension.
            else {
                PacketParserUtils.addExtensionElement(mucOwner, parser);
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }

    return mucOwner;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:MUCOwnerProvider.java

示例6: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    UserSearch search = null;
    SimpleUserSearch simpleUserSearch = new SimpleUserSearch();

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG && parser.getName().equals("instructions")) {
            buildDataForm(simpleUserSearch, parser.nextText(), parser);
            return simpleUserSearch;
        }
        else if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) {
            simpleUserSearch.parseItems(parser);
            return simpleUserSearch;
        }
        else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) {
            // Otherwise, it must be a packet extension.
            search = new UserSearch();
            PacketParserUtils.addExtensionElement(search, parser);
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }

    if (search != null) {
        return search;
    }
    return simpleUserSearch;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:34,代码来源:UserSearch.java

示例7: buildDataForm

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
private static void buildDataForm(SimpleUserSearch search,
                String instructions, XmlPullParser parser)
                throws XmlPullParserException, IOException, SmackException {
    DataForm dataForm = new DataForm(DataForm.Type.form);
    boolean done = false;
    dataForm.setTitle("User Search");
    dataForm.addInstruction(instructions);
    while (!done) {
        int eventType = parser.next();

        if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
            String name = parser.getName();
            FormField field = new FormField(name);

            // Handle hard coded values.
            if(name.equals("first")){
                field.setLabel("First Name");
            }
            else if(name.equals("last")){
                field.setLabel("Last Name");
            }
            else if(name.equals("email")){
                field.setLabel("Email Address");
            }
            else if(name.equals("nick")){
                field.setLabel("Nickname");
            }

            field.setType(FormField.Type.text_single);
            dataForm.addField(field);
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
        else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) {
            PacketParserUtils.addExtensionElement(search, parser);
            done = true;
        }
    }
    if (search.getExtension("x", "jabber:x:data") == null) {
        search.addExtension(dataForm);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:46,代码来源:UserSearch.java

示例8: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
   public Registration parse(XmlPullParser parser, int initialDepth)
                   throws XmlPullParserException, IOException, SmackException {
       String instruction = null;
       Map<String, String> fields = new HashMap<String, String>();
       List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
       outerloop:
       while (true) {
           int eventType = parser.next();
           if (eventType == XmlPullParser.START_TAG) {
               // Any element that's in the jabber:iq:register namespace,
               // attempt to parse it if it's in the form <name>value</name>.
               if (parser.getNamespace().equals(Registration.NAMESPACE)) {
                   String name = parser.getName();
                   String value = "";

                   if (parser.next() == XmlPullParser.TEXT) {
                       value = parser.getText();
                   }
                   // Ignore instructions, but anything else should be added to the map.
                   if (!name.equals("instructions")) {
                       fields.put(name, value);
                   }
                   else {
                       instruction = value;
                   }
               }
               // Otherwise, it must be a packet extension.
               else {
                   PacketParserUtils.addExtensionElement(packetExtensions, parser);
               }
           }
           else if (eventType == XmlPullParser.END_TAG) {
               if (parser.getName().equals(IQ.QUERY_ELEMENT)) {
                   break outerloop;
               }
           }
       }
       Registration registration = new Registration(instruction, fields);
       registration.addExtensions(packetExtensions);
       return registration;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:43,代码来源:RegistrationProvider.java

示例9: parse

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Override
public DiscoverInfo parse(XmlPullParser parser, int initialDepth)
                throws XmlPullParserException, IOException, SmackException {
    DiscoverInfo discoverInfo = new DiscoverInfo();
    boolean done = false;
    DiscoverInfo.Identity identity = null;
    String category = "";
    String name = "";
    String type = "";
    String variable = "";
    String lang = "";
    discoverInfo.setNode(parser.getAttributeValue("", "node"));
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("identity")) {
                // Initialize the variables from the parsed XML
                category = parser.getAttributeValue("", "category");
                name = parser.getAttributeValue("", "name");
                type = parser.getAttributeValue("", "type");
                lang = parser.getAttributeValue(parser.getNamespace("xml"), "lang");
            }
            else if (parser.getName().equals("feature")) {
                // Initialize the variables from the parsed XML
                variable = parser.getAttributeValue("", "var");
            }
            // Otherwise, it must be a packet extension.
            else {
                PacketParserUtils.addExtensionElement(discoverInfo, parser);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("identity")) {
                // Create a new identity and add it to the discovered info.
                identity = new DiscoverInfo.Identity(category, type, name, lang);
                discoverInfo.addIdentity(identity);
            }
            if (parser.getName().equals("feature")) {
                // Create a new feature and add it to the discovered info.
                boolean notADuplicateFeature = discoverInfo.addFeature(variable);
                assert(notADuplicateFeature);
            }
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }

    return discoverInfo;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:50,代码来源:DiscoverInfoProvider.java


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