當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。