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


Java KXmlParser.END_TAG属性代码示例

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


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

示例4: 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

示例5: 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

示例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 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

示例7: parseConfiguration

private void parseConfiguration(Configurable data) throws InvalidStructureException, IOException, XmlPullParserException {
    checkNode("configuration");

    TextParser textParser = new TextParser(parser);
    do {
        parser.nextTag();
        if (parser.getName().equals("text")) {
            String id = parser.getAttributeValue(null, "id");
            Text t = textParser.parse();
            data.setConfiguration(id, t);
        }
    }
    while (parser.getEventType() != KXmlParser.END_TAG || !parser.getName().equals("configuration"));
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:14,代码来源:GraphParser.java

示例8: parseSeries

private XYSeries parseSeries(String type) throws InvalidStructureException, IOException, XmlPullParserException {
    checkNode("series");
    String nodeSet = parser.getAttributeValue(null, "nodeset");
    XYSeries series = type.equals(GraphUtil.TYPE_BUBBLE) ? new BubbleSeries(nodeSet) : new XYSeries(nodeSet);

    nextStartTag();
    if (parser.getName().equals("configuration")) {
        parseConfiguration(series);
        nextStartTag();
    }

    checkNode("x");
    series.setX(parseFunction("x"));

    nextStartTag();
    series.setY(parseFunction("y"));

    if (type.equals(GraphUtil.TYPE_BUBBLE)) {
        nextStartTag();
        checkNode("radius");
        ((BubbleSeries)series).setRadius(parseFunction("radius"));
    }

    while (parser.getEventType() != KXmlParser.END_TAG || !parser.getName().equals("series")) {
        parser.nextTag();
    }

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

示例9: 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

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