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


Java XmlPullParser.require方法代码示例

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


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

示例1: readItem

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static ItemRSS readItem(XmlPullParser parser) throws XmlPullParserException, IOException {
    String title = null;
    String link = null;
    String pubDate = null;
    String description = null;
    parser.require(XmlPullParser.START_TAG, null, "item");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("title")) {
            title = readData(parser, "title");
        } else if (name.equals("link")) {
            link = readData(parser, "link");
        } else if (name.equals("pubDate")) {
            pubDate = readData(parser, "pubDate");
        } else if (name.equals("description")) {
            description = readData(parser, "description");
        } else {
            skip(parser);
        }
    }
    ItemRSS result = new ItemRSS(title, link, pubDate, description);
    return result;
}
 
开发者ID:if1001,项目名称:tarefa01-blaandrade,代码行数:27,代码来源:ParserRSS.java

示例2: readPropStat

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Response.PropStat readPropStat(XmlPullParser parser) throws IOException, XmlPullParserException {
    Response.PropStat propstat = new Response.PropStat();
    parser.require(XmlPullParser.START_TAG, ns, "propstat");
    android.util.Log.d("PARSE", "readPropStat");
    while (parser.next() != XmlPullParser.END_TAG) {

        android.util.Log.d("PARSE", "3eventtype=" + parser.getEventType());

        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        android.util.Log.d("PARSE", "3name=" + name);
        if (name.equals("prop"))
        {
            propstat.prop = readProp(parser);
        } else if (name.equals("status"))
        {
            propstat.status = readText(parser);
        } else {
            skip(parser);
        }
    }
    return propstat;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:26,代码来源:PropfindXmlParser.java

示例3: readRecommendationConfig

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Map<String, String> readRecommendationConfig(XmlPullParser parser) throws XmlPullParserException, IOException {

        Map<String, String> retValue = new HashMap<>();
        while (parser.next() != XmlPullParser.END_TAG) {

            if (parser.getEventType() != XmlPullParser.START_TAG) {
                continue;
            }

            String name = parser.getName();
            if (name.equals("recommendation"))
            {
                parser.require(XmlPullParser.START_TAG, ns, "recommendation");
                String recName = parser.getAttributeValue(ns, "name");
                String value = readText(parser);

                if (recName == null || value == null || !HelperFunctions.testIsValidURL(value)) {
                    WebtrekkLogging.log("invalid parameter configuration while reading recommendation value, missing name or value or value URL incorrect");
                } else {
                    retValue.put(recName, value);
                }
            }
        }
        return retValue;
    }
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:26,代码来源:TrackingConfigurationXmlParser.java

示例4: readRtePt

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void readRtePt(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
    parser.require(XmlPullParser.START_TAG, ns, "rtept");
    Date time = null;
    double lat = Double.parseDouble(parser.getAttributeValue(null, "lat"));
    double lon = Double.parseDouble(parser.getAttributeValue(null, "lon"));
    double ele = Double.NaN;

    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        switch (name) {
            case "ele":
                ele = readEle(parser);
                break;
            case "time":
                time = readTime(parser);
                break;
            default:
                skip(parser);
                break;
        }
    }
    wayPoints.add(new WayPoint(lat, lon, ele, time));
}
 
开发者ID:gimportexportdevs,项目名称:gexporter,代码行数:27,代码来源:Gpx2Fit.java

示例5: readRss

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static List<ItemRSS> readRss(XmlPullParser parser)
        throws XmlPullParserException, IOException {
    List<ItemRSS> items = new ArrayList<ItemRSS>();
    parser.require(XmlPullParser.START_TAG, null, "rss");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("channel")) {
            items.addAll(readChannel(parser));
        } else {
            skip(parser);
        }
    }
    return items;
}
 
开发者ID:if1001,项目名称:tarefa01-blaandrade,代码行数:18,代码来源:ParserRSS.java

示例6: readEntry

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Entry readEntry(XmlPullParser parser) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, ns, "recipe");
    String NNaame = null;
    String NIngredients[] = null;
    while (parser.next() != XmlPullParser.END_TAG) {
        int i = 0;
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("name")) {
            NNaame = readName(parser);
        } else if (name.equals("ingredient")) {
            NIngredients[i] = readIngredient(parser);
            i++;
        } else {
            skip(parser);
        }
    }
    return new Entry(NNaame, NIngredients);
}
 
开发者ID:Recipe4Meals,项目名称:BLG-411E,代码行数:22,代码来源:IngredientsXMLParser.java

示例7: readGPX

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void readGPX(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
    parser.require(XmlPullParser.START_TAG, ns, "gpx");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        // Starts by looking for the entry tag
        switch (name) {
            case "trk":
                readTrk(parser);
                // If waypoints found, bail out.
                if (wayPoints.size() > 0)
                    return;
                break;
            case "rte":
                readRte(parser);
                // If waypoints found, bail out.
                if (wayPoints.size() > 0)
                    return;
                break;
            default:
                skip(parser);
                break;
        }
    }
}
 
开发者ID:gimportexportdevs,项目名称:gexporter,代码行数:28,代码来源:Gpx2Fit.java

示例8: parseShortcut

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void parseShortcut(XmlPullParser parser) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, TAG_SHORTCUT);
    String id = getAttribute(parser, ATTRIBUTE_SHORTCUT_ID);
    CharSequence shortLabel = getCharSequence(parser, ATTRIBUTE_SHORTCUT_SHORT_LABEL);
    CharSequence longLabel = getCharSequence(parser, ATTRIBUTE_SHORTCUT_LONG_LABEL);
    CharSequence disabledMessage = getCharSequence(parser, ATTRIBUTE_SHORTCUT_DISABLED_MESSAGE);
    Drawable icon = mResources.getDrawable(getResourceAttribute(parser, ATTRIBUTE_SHORTCUT_ICON));
    Intent activity = null;
    int depth = 1;
    while (depth != 0) {
        switch (parser.next()) {
            case XmlPullParser.END_TAG:
                depth--;
                break;
            case XmlPullParser.START_TAG:
                depth++;
                if (TAG_INTENT.equals(parser.getName())) {
                    Intent intent = parseIntent(parser);
                    if (activity == null) {
                        activity = intent;
                    }
                    depth--;
                }
                break;
        }
    }
    if (activity == null) return;
    if (id == null) {
        id = activity.getComponent().toString() + "_shortcut" + mShortcutsList.size();
    }
    if (shortLabel == null && longLabel == null) {
        shortLabel = "null";
    }
    if (isComponentExported(activity.getComponent())) {
        mShortcutsList.add(new ShortcutInfoCompat(mPackageName, id, shortLabel, longLabel, mComponentName, activity, Utilities.myUserHandle(), 0, true, disabledMessage, icon));
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:38,代码来源:ShortcutParser.java

示例9: readCell

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Cell readCell(XmlPullParser parser) throws XmlPullParserException, IOException {
    Cell cell = new Cell();
    parser.require(XmlPullParser.START_TAG, ns, "cell");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        switch (name) {
            case "lat":
                cell.setLat(readDouble(parser));
                break;
            case "lon":
                cell.setLon(readDouble(parser));
                break;
            case "mcc":
                cell.setMCC(readInt(parser));
                break;
            case "mnc":
                cell.setMNC(readInt(parser));
                break;
            case "cellid":
                cell.setCID(readInt(parser));
                break;
            case "lac":
                cell.setLAC(readInt(parser));
                break;
            default:
                skip(parser);
                break;
        }
    }
    return cell;
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:35,代码来源:StackOverflowXmlParser.java

示例10: parseImpl

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static ProcedureInfo parseImpl(XmlPullParser parser)
        throws BlockLoadingException, IOException, XmlPullParserException {
    List<String> argNames = new ArrayList<>();
    String procedureName = null;
    boolean hasStatementInput = HAS_STATEMENTS_DEFAULT;

    int tokenType = parser.next();
    if (tokenType != XmlPullParser.END_DOCUMENT) {
        parser.require(XmlPullParser.START_TAG, null, Mutator.TAG_MUTATION);

        String attrValue = parser.getAttributeValue(null, ATTR_NAME);
        if (!TextUtils.isEmpty(attrValue)) {
            procedureName = attrValue;
        }

        attrValue = parser.getAttributeValue(null, ATTR_STATEMENTS);
        if (!TextUtils.isEmpty(attrValue)) {
            hasStatementInput = Boolean.getBoolean(attrValue);
        }

        tokenType = parser.next();
        while (tokenType != XmlPullParser.END_DOCUMENT) {
            if (tokenType == XmlPullParser.START_TAG) {
                parser.require(XmlPullParser.START_TAG, null, TAG_ARG);
                String argName = parser.getAttributeValue(null, ATTR_ARG_NAME);
                if (argName == null) {
                    throw new BlockLoadingException(
                            "Function argument #" + argNames.size() + " missing name.");
                }
                argNames.add(argName);
            } else if (tokenType == XmlPullParser.END_TAG
                    && parser.getName().equals(Mutator.TAG_MUTATION)) {
                break;
            }
            tokenType = parser.next();
        }
    }

    return new ProcedureInfo(procedureName, argNames, hasStatementInput);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:41,代码来源:ProcedureInfo.java

示例11: readElement

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private String readElement(
        @NonNull XmlPullParser parser,
        @NonNull String element) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, NAME_SPACE, element);
    String value = readText(parser);
    parser.require(XmlPullParser.END_TAG, NAME_SPACE, element);

    return value;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:10,代码来源:RssParser.java

示例12: readFromXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * XML interface: procedure reads the formula state
 */
public void readFromXml(XmlPullParser parser) throws Exception
{
    final String text = parser.getAttributeValue(null, FormulaList.XML_PROP_TEXT);
    final String termCode = parser.getAttributeValue(null, FormulaList.XML_PROP_CODE);
    parser.require(XmlPullParser.START_TAG, FormulaList.XML_NS, parser.getName());
    boolean finishTag = true;
    if (termCode == null)
    {
        setText(text == null ? "" : text);
    }
    else
    {
        term = convertToTerm(termCode, null, /*ensureManualTrigger=*/ false);
        if (isTerm())
        {
            setText("");
            term.readFromXml(parser);
            finishTag = false;
        }
        else
        {
            throw new Exception("can not create term");
        }
    }
    if (finishTag)
    {
        while (parser.next() != XmlPullParser.END_TAG) ;
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:33,代码来源:TermField.java

示例13: readLink

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private String readLink(XmlPullParser parser) throws IOException, XmlPullParserException {
    String link = "";
    parser.require(XmlPullParser.START_TAG, ns, "link");
    String tag = parser.getName();
    String relType = parser.getAttributeValue(null, "rel");
    if (tag.equals("link")) {
        if (relType.equals("alternate")) {
            link = parser.getAttributeValue(null, "href");
            parser.nextTag();
        }
    }
    parser.require(XmlPullParser.END_TAG, ns, "link");
    return link;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:StackOverflowXmlParser.java

示例14: parseOPML

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static void parseOPML(final XmlPullParser parser, final OPMLFile opml,
                              final String version) throws OPMLParserException,
                                                           XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, null, TAG_OPML);

    int validationsPassed = 0;

    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        switch (parser.getName()) {
            case TAG_HEAD:
                parseHead(parser, opml);
                validationsPassed++;
                break;
            case TAG_BODY:
                parseBody(parser, opml, version);
                validationsPassed++;
                break;
        }
    }

    parser.require(XmlPullParser.END_TAG, null, TAG_OPML);

    if (validationsPassed < 2)  {
        parserInvalidDocument(parser);
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:30,代码来源:OPMLParser.java

示例15: readService

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private DialService readService(XmlPullParser parser) throws DialException, IOException, XmlPullParserException {
    DialService service;
    String name = null;
    DialService.State state = null;
    URL absoluteLink = null;
    AdditionalData additionalData = null;

    parser.require(XmlPullParser.START_TAG, "urn:dial-multiscreen-org:schemas:dial", TAG_SERVICE);
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String tag = parser.getName();
        if (tag.equals(TAG_ADDITIONAL_DATA)) {
            additionalData = readAdditionalData(parser);
        } else if (tag.equals(TAG_NAME)) {
            name = DialParserUtils.readTextValue(parser, TAG_NAME, null);
        } else if (tag.equals(TAG_STATE)) {
            state = readState(parser);
        } else if (tag.equals(TAG_LINK)) {
            URI link = readLink(parser);
            if(link != null && link.isAbsolute()) {
                absoluteLink = link.toURL();
            } else {
                try {
                    // not confident about this being the right way to do it
                    absoluteLink = new URI(baseUrl.toString() + "/").resolve(link).toURL();
                } catch (URISyntaxException e) {
                    throw new DialException(e);
                }
            }
        } else {
            DialParserUtils.skip(parser);
        }
    }

    service = new DialService(baseUrl, name, state, absoluteLink, additionalData);
    checkService(service);
    return service;
}
 
开发者ID:Orange-OpenSource,项目名称:OCast-Java,代码行数:41,代码来源:DialServiceParser.java


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