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


Java KXmlParser.START_TAG属性代码示例

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


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

示例1: skipBlock

public void skipBlock(String tag) throws XmlPullParserException, IOException {

        while(parser.getEventType() != KXmlParser.END_DOCUMENT) {
            int eventType;
            eventType = parser.next();

            if(eventType == KXmlParser.START_DOCUMENT) {

            } else if(eventType == KXmlParser.END_DOCUMENT) {
                return;
            } else if(eventType == KXmlParser.START_TAG) {

            } else if(eventType == KXmlParser.END_TAG) {
                if(parser.getName().equals(tag)) {
                    return;
                }
            } else if(eventType == KXmlParser.TEXT) {

            }
        }
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:ElementParser.java

示例2: skipBlock

public void skipBlock(String tag) throws XmlPullParserException, IOException {

        while (parser.getEventType() != KXmlParser.END_DOCUMENT) {
            int eventType;
            eventType = parser.next();

            if (eventType == KXmlParser.START_DOCUMENT) {

            } else if (eventType == KXmlParser.END_DOCUMENT) {
                return;
            } else if (eventType == KXmlParser.START_TAG) {

            } else if (eventType == KXmlParser.END_TAG) {
                if (parser.getName().equals(tag)) {
                    return;
                }
            } else if (eventType == KXmlParser.TEXT) {

            }
        }
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:ElementParser.java

示例3: parseProgressFromRetryResult

private boolean parseProgressFromRetryResult(RemoteDataPullResponse response) {
    try {
        InputStream stream = response.writeResponseToCache(syncTask.context).retrieveCache();
        KXmlParser parser = ElementParser.instantiateParser(stream);
        parser.next();
        int eventType = parser.getEventType();
        do {
            if (eventType == KXmlParser.START_TAG) {
                if (parser.getName().toLowerCase().equals("progress")) {
                    serverProgressCompletedSoFar = Integer.parseInt(
                            parser.getAttributeValue(null, "done"));
                    serverProgressTotal = Integer.parseInt(
                            parser.getAttributeValue(null, "total"));
                    return true;
                }
            }
            eventType = parser.next();
        } while (eventType != KXmlParser.END_DOCUMENT);
    } catch (IOException | XmlPullParserException e) {
        Logger.log(LogTypes.TYPE_USER,
                "Error while parsing progress values of retry result");
    }
    return false;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:AsyncRestoreHelper.java

示例4: parse

@Override
public List<AppAvailableToInstall> parse() throws InvalidStructureException, IOException,
        XmlPullParserException, UnfullfilledRequirementsException {
    checkNode(APPS_TAG);
    List<AppAvailableToInstall> appsList = new ArrayList<>();

    parser.next();
    int eventType = parser.getEventType();
    do {
        if (eventType == KXmlParser.START_TAG) {
            String tagName = parser.getName().toLowerCase();
            if (APP_TAG.equals(tagName)) {
                String domain = parser.getAttributeValue(null, DOMAIN_TAG);
                String appName = parser.getAttributeValue(null, APP_NAME_TAG);
                String profileRef = parser.getAttributeValue(null, PROFILE_REF_TAG);
                String mediaProfileRef = parser.getAttributeValue(null, MEDIA_PROFILE_REF_TAG);
                appsList.add(new AppAvailableToInstall(domain, appName, profileRef, mediaProfileRef));
            }
        }
        eventType = parser.next();
    } while (eventType != KXmlParser.END_DOCUMENT);

    commit(appsList);
    return appsList;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:25,代码来源:AvailableAppsParser.java

示例5: parse

public TreeElement parse() throws InvalidStructureException, IOException, XmlPullParserException {

        int depth = parser.getDepth();
        TreeElement element = new TreeElement(parser.getName(), multiplicity);
        element.setInstanceName(instanceId);
        for(int i = 0 ; i < parser.getAttributeCount(); ++i) {
            element.setAttribute(parser.getAttributeNamespace(i), parser.getAttributeName(i), parser.getAttributeValue(i));
        }

        Hashtable<String, Integer> multiplicities = new Hashtable<String, Integer>();
        //NOTE: We never expect this to be the exit condition
        while(parser.getDepth() >= depth) {
        switch(this.nextNonWhitespace()) {
            case KXmlParser.START_TAG:
                String name = parser.getName();
                int val;
                if(multiplicities.containsKey(name)) {
                    val = multiplicities.get(name).intValue()+1;
                } else {
                    val = 0;
                }
                multiplicities.put(name,  new Integer(val));

                TreeElement kid = new TreeElementParser(parser, val, instanceId).parse();
                element.addChild(kid);
                break;
            case KXmlParser.END_TAG:
                return element;
            case KXmlParser.TEXT:
                element.setValue(new UncastData(parser.getText().trim()));
                break;
            default:
                throw new InvalidStructureException("Exception while trying to parse an XML Tree, got something other than tags and text", parser);
            }
        }

        return element;
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:38,代码来源:TreeElementParser.java

示例6: nextTagInBlock

/**
 * Retrieves the next tag in the XML document which is internal
 * to the tag identified by terminal. If there are no further tags
 * inside this tag, false will be returned.
 *
 * @param terminal The name of the tag which the next tag expected
 * should be inside of.
 *
 * @throws InvalidStructureException If any invalid CommCare XML structures are
 * detected.
 * @throws IOException If the parser has a problem reading the document
 * @throws XmlPullParserException If the stream does not contain well-formed
 * XML.
 */
protected boolean nextTagInBlock(String terminal) throws InvalidStructureException, IOException, XmlPullParserException {
        int eventType;

        //eventType = parser.nextTag();
        eventType = parser.next();
        if(eventType == KXmlParser.TEXT && parser.isWhitespace()) {   // skip whitespace
             eventType = parser.next();
        }

        if(eventType == KXmlParser.START_DOCUMENT) {
            //
        } else if(eventType == KXmlParser.END_DOCUMENT) {
            return false;
        } else if(eventType == KXmlParser.START_TAG) {
            return true;
        } else if(eventType == KXmlParser.END_TAG) {
            //If we've reached the end of the current node path,
            //return false (signaling that the parsing action should end).
            if(parser.getName().toLowerCase().equals(terminal.toLowerCase())) { return false; }
            //Elsewise, as long as we haven't left the current context, keep diving
            else if(parser.getDepth() >= level) { return nextTagInBlock(terminal); }
            //if we're below the limit, get out.
            else { return false; }
        } else if(eventType == KXmlParser.TEXT) {
            return true;
        }
        return true;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:42,代码来源:ElementParser.java

示例7: parse

public TreeElement parse() throws InvalidStructureException, IOException,
        XmlPullParserException, UnfullfilledRequirementsException {

    int depth = parser.getDepth();
    TreeElement element = new TreeElement(parser.getName(), multiplicity);
    element.setInstanceName(instanceId);
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        element.setAttribute(parser.getAttributeNamespace(i), parser.getAttributeName(i), parser.getAttributeValue(i));
    }

    Hashtable<String, Integer> multiplicities = new Hashtable<String, Integer>();

    // loop parses all siblings at a given depth
    while (parser.getDepth() >= depth) {
        switch (this.nextNonWhitespace()) {
            case KXmlParser.START_TAG:
                String name = parser.getName();
                int val;
                if (multiplicities.containsKey(name)) {
                    val = multiplicities.get(name).intValue() + 1;
                } else {
                    val = 0;
                }
                multiplicities.put(name, new Integer(val));

                TreeElement kid = new TreeElementParser(parser, val, instanceId).parse();
                element.addChild(kid);
                break;
            case KXmlParser.END_TAG:
                return element;
            case KXmlParser.TEXT:
                element.setValue(new UncastData(parser.getText().trim()));
                break;
            default:
                throw new InvalidStructureException("Exception while trying to parse an XML Tree, got something other than tags and text", parser);
        }
    }

    return element;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:40,代码来源:TreeElementParser.java

示例8: nextTagInBlock

/**
 * Retrieves the next tag in the XML document which is internal
 * to the tag identified by terminal. If there are no further tags
 * inside this tag, false will be returned.
 *
 * @param terminal The name of the tag which the next tag expected
 *                 should be inside of.
 * @throws InvalidStructureException If any invalid XML structures are
 *                                   detected.
 * @throws IOException               If the parser has a problem reading the document
 * @throws XmlPullParserException    If the stream does not contain well-formed
 *                                   XML.
 */
protected boolean nextTagInBlock(String terminal) throws InvalidStructureException, IOException, XmlPullParserException {
    int eventType;

    //eventType = parser.nextTag();
    eventType = parser.next();
    while (eventType == KXmlParser.TEXT && parser.isWhitespace()) {   // skip whitespace
        eventType = parser.next();
    }

    if (eventType == KXmlParser.START_DOCUMENT) {
        //
    } else if (eventType == KXmlParser.END_DOCUMENT) {
        return false;
    } else if (eventType == KXmlParser.START_TAG) {
        return true;
    } else if (eventType == KXmlParser.END_TAG) {
        //If we've reached the end of the current node path,
        //return false (signaling that the parsing action should end).
        if (isTagNamed(terminal)) {
            return false;
        }
        //Elsewise, as long as we haven't left the current context, keep diving
        else if (parser.getDepth() >= level) {
            return nextTagInBlock(terminal);
        }
        //if we're below the limit, get out.
        else {
            return false;
        }
    } else if (eventType == KXmlParser.TEXT) {
        return true;
    }
    return true;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:47,代码来源:ElementParser.java

示例9: parse

@Override
public Profile parse() throws InvalidStructureException, IOException, XmlPullParserException,
        UnfullfilledRequirementsException {

    checkNode("profile");
    Profile profile = parseProfileElement();

    try {
        parser.next();
        int eventType;
        eventType = parser.getEventType();
        do {
            if (eventType == KXmlParser.START_TAG) {
                if (parser.getName().toLowerCase().equals("property")) {
                    parseProperty(profile);
                } else if (parser.getName().toLowerCase().equals("root")) {
                    RootTranslator root = new RootParser(this.parser).parse();
                    profile.addRoot(root);
                } else if (parser.getName().toLowerCase().equals("login")) {
                    parseLogin();
                } else if (parser.getName().toLowerCase().equals("features")) {
                    parseFeatures(profile);
                } else if (parser.getName().toLowerCase().equals("suite")) {
                    parseSuite();
                } else {
                    System.out.println("Unrecognized Tag: "
                            + parser.getName());
                }
            }
            eventType = parser.next();
        } while (eventType != KXmlParser.END_DOCUMENT);

        return profile;
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new InvalidStructureException("Pull Parse Exception, malformed XML.", parser);
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:39,代码来源:ProfileParser.java

示例10: parse

@Override
public TreeElement parse() throws InvalidStructureException, IOException, XmlPullParserException {

    int depth = parser.getDepth();
    TreeElement element = new TreeElement(parser.getName(), multiplicity);
    element.setInstanceName(instanceId);
    for(int i = 0 ; i < parser.getAttributeCount(); ++i) {
        element.setAttribute(parser.getAttributeNamespace(i), parser.getAttributeName(i), parser.getAttributeValue(i));
    }

    Hashtable<String, Integer> multiplicities = new Hashtable<>();
    //NOTE: We never expect this to be the exit condition
    while(parser.getDepth() >= depth) {
    switch(this.nextNonWhitespace()) {
        case KXmlParser.START_TAG:
            String name = parser.getName();
            int val;
            if(multiplicities.containsKey(name)) {
                val = multiplicities.get(name) +1;
            } else {
                val = 0;
            }
            multiplicities.put(name,  val);

            TreeElement kid = new TreeElementParser(parser, val, instanceId).parse();
            element.addChild(kid);
            break;
        case KXmlParser.END_TAG:
            return element;
        case KXmlParser.TEXT:
            element.setValue(new UncastData(parser.getText().trim()));
            break;
        default:
            throw new InvalidStructureException("Exception while trying to parse an XML Tree, got something other than tags and text", parser);
        }
    }

    return element;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:39,代码来源:TreeElementParser.java

示例11: nextStartTag

private void nextStartTag() throws IOException, XmlPullParserException {
    do {
        parser.nextTag();
    } while (parser.getEventType() != KXmlParser.START_TAG);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:5,代码来源:GraphParser.java

示例12: parse

@Override
public TreeElement parse() throws InvalidStructureException, IOException,
        XmlPullParserException, UnfullfilledRequirementsException {

    int depth = parser.getDepth();
    TreeElement element = new TreeElement(parser.getName(), multiplicity);
    element.setInstanceName(instanceId);
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        element.setAttribute(parser.getAttributeNamespace(i), parser.getAttributeName(i), parser.getAttributeValue(i));
    }

    Hashtable<String, Integer> multiplicities = new Hashtable<>();

    // loop parses all siblings at a given depth
    while (parser.getDepth() >= depth) {
        switch (this.nextNonWhitespace()) {
            case KXmlParser.START_TAG:
                String name = parser.getName();
                int val;
                if (multiplicities.containsKey(name)) {
                    val = multiplicities.get(name) + 1;
                } else {
                    val = 0;
                }
                multiplicities.put(name, new Integer(val));

                TreeElement kid = new TreeElementParser(parser, val, instanceId).parse();
                element.addChild(kid);
                break;
            case KXmlParser.END_TAG:
                return element;
            case KXmlParser.TEXT:
                element.setValue(new UncastData(parser.getText().trim()));
                break;
            default:
                throw new InvalidStructureException("Exception while trying to parse an XML Tree, got something other than tags and text", parser);
        }
    }

    return element;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:41,代码来源:TreeElementParser.java


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