當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlPullParser.END_DOCUMENT屬性代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.END_DOCUMENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.END_DOCUMENT屬性的具體用法?Java XmlPullParser.END_DOCUMENT怎麽用?Java XmlPullParser.END_DOCUMENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.xmlpull.v1.XmlPullParser的用法示例。


在下文中一共展示了XmlPullParser.END_DOCUMENT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readThisListXml

@SuppressWarnings("unchecked")
private static ArrayList readThisListXml(XmlPullParser parser, String endTag, String[] name)
        throws XmlPullParserException, IOException {
    ArrayList list = new ArrayList();

    int eventType = parser.getEventType();
    do {
        if (eventType == XmlPullParser.START_TAG) {
            Object val = readThisValueXml(parser, name);
            list.add(val);
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(endTag)) {
                return list;
            }
            throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName());
        }
        eventType = parser.next();
    } while (eventType != XmlPullParser.END_DOCUMENT);

    throw new XmlPullParserException("Document ended before " + endTag + " end tag");
}
 
開發者ID:Doist,項目名稱:JobSchedulerCompat,代碼行數:21,代碼來源:XmlUtils.java

示例2: parseTbodyXml

private static List<SupportedLanguage> parseTbodyXml(@NonNull XmlPullParser parser) throws Throwable {
    List<SupportedLanguage> tableRows = new LinkedList<>();
    int eventType = parser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        switch (eventType) {
            case XmlPullParser.START_TAG: {
                if ("tr".equalsIgnoreCase(parser.getName())) {
                    List<String> tableRow = parseTableRow(parser);
                    SupportedLanguage convertedEntry = convertElementsToSupportedLanguage(tableRow);
                    tableRows.add(convertedEntry);
                }
                break;
            }
        }
        eventType = parser.next();
    }
    return tableRows;
}
 
開發者ID:powdream,項目名稱:google-speech-api-android,代碼行數:18,代碼來源:SupportedLanguageConverter.java

示例3: parseLayout

/**
 * Parses the layout and returns the number of elements added on the homescreen.
 */
private int parseLayout(int layoutId, ArrayList<Long> screenIds)
        throws XmlPullParserException, IOException {
    XmlResourceParser parser = mSourceRes.getXml(layoutId);
    beginDocument(parser, mRootTag);
    final int depth = parser.getDepth();
    int type;
    HashMap<String, TagParser> tagParserMap = getLayoutElementsMap();
    int count = 0;

    while (((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        count += parseAndAddNode(parser, tagParserMap, screenIds);
    }
    return count;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:21,代碼來源:AutoInstallsLayout.java

示例4: parseMerge

private void parseMerge(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
        throws XmlPullParserException, IOException {
    if (DEBUG) startTag("<%s>", TAG_MERGE);
    while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
        final int event = parser.next();
        if (event == XmlPullParser.START_TAG) {
            final String tag = parser.getName();
            if (TAG_MERGE.equals(tag)) {
                if (row == null) {
                    parseKeyboardContent(parser, skip);
                } else {
                    parseRowContent(parser, row, skip);
                }
                return;
            }
            throw new XmlParseUtils.ParseException(
                    "Included keyboard layout must have <merge> root element", parser);
        }
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:20,代碼來源:KeyboardBuilder.java

示例5: parse

Podcasts parse(InputStream input, @Nullable String charset, String baseUri) throws IOException {
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(input, charset);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String tag = xpp.getName();
                if (LayoutUtils.isDiv(tag) && hasClass(xpp, PODCAST_LIST_CLASS)) {
                    return parsePodcasts(xpp, NetworkUtils.toOptURI(baseUri));
                }
            }
            eventType = lenientNext(xpp);
        }
        return new Podcasts();
    } catch (XmlPullParserException e) {
        throw new IOException(e);
    }
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:24,代碼來源:PodcastsLayoutParser.java

示例6: generateServicesMap

private void generateServicesMap(List<ResolveInfo> services, Map<String, SyncAdapterInfo> map,
                                 RegisteredServicesParser accountParser) {
    for (ResolveInfo info : services) {
        XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo, "android.content.SyncAdapter");
        if (parser != null) {
            try {
                AttributeSet attributeSet = Xml.asAttributeSet(parser);
                int type;
                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
                    // Nothing to do
                }
                if ("sync-adapter".equals(parser.getName())) {
                    SyncAdapterType adapterType = parseSyncAdapterType(
                            accountParser.getResources(mContext, info.serviceInfo.applicationInfo), attributeSet);
                    if (adapterType != null) {
                        String key = adapterType.accountType + "/" + adapterType.authority;
                        map.put(key, new SyncAdapterInfo(adapterType, info.serviceInfo));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:25,代碼來源:VContentService.java

示例7: beginDocument

private static void beginDocument(XmlPullParser parser, String firstElementName)
        throws XmlPullParserException, IOException {

    int type;
    while ((type = parser.next()) != XmlPullParser.START_TAG &&
            type != XmlPullParser.END_DOCUMENT) {
        // Empty
    }

    if (type != XmlPullParser.START_TAG) {
        throw new XmlPullParserException("No start tag found");
    }

    if (!parser.getName().equals(firstElementName)) {
        throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
                ", expected " + firstElementName);
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:Home.java

示例8: skipCurrentTag

public static void skipCurrentTag(XmlPullParser parser)
        throws XmlPullParserException, IOException {
    int outerDepth = parser.getDepth();
    int type;
    while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
           && (type != XmlPullParser.END_TAG
                   || parser.getDepth() > outerDepth)) {
    }
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:9,代碼來源:XmlUtils.java

示例9: parseApplicationNameByManifest

/**
 * get application name by manifest
 *
 * @param parser parser
 * @return application name
 */
private static String parseApplicationNameByManifest(XmlPullParser parser) {
    try {
        int eventType = parser.getEventType();
        String namespaceAndroid = null;
        do {
            switch (eventType) {
                case XmlPullParser.START_DOCUMENT: {
                    break;
                }
                case XmlPullParser.START_TAG: {
                    String tag = parser.getName();
                    if (tag.equals("manifest")) {
                        namespaceAndroid = parser.getNamespace("android");
                    } else if ("application".equals(parser.getName())) {
                        String applicationName = parser.getAttributeValue("", "name");
                        if (applicationName == null || "".equals(applicationName)) {
                            applicationName = parser.getAttributeValue(namespaceAndroid, "name");
                        }
                        return applicationName;
                    }
                    break;
                }
                case XmlPullParser.END_TAG: {
                    break;
                }
            }
            eventType = parser.next();
        } while (eventType != XmlPullParser.END_DOCUMENT);
    } catch (Exception e1) {
    }
    return "";
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:38,代碼來源:ApkManifestParser.java

示例10: getPredefinedDeviceProfiles

ArrayList<InvariantDeviceProfile> getPredefinedDeviceProfiles(Context context) {
    ArrayList<InvariantDeviceProfile> profiles = new ArrayList<>();
    try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
        final int depth = parser.getDepth();
        int type;

        while (((type = parser.next()) != XmlPullParser.END_TAG ||
                parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
            if ((type == XmlPullParser.START_TAG) && "profile".equals(parser.getName())) {
                TypedArray a = context.obtainStyledAttributes(
                        Xml.asAttributeSet(parser), R.styleable.InvariantDeviceProfile);
                int numRows = a.getInt(R.styleable.InvariantDeviceProfile_numRows, 0);
                int numColumns = a.getInt(R.styleable.InvariantDeviceProfile_numColumns, 0);
                float iconSize = a.getFloat(R.styleable.InvariantDeviceProfile_iconSize, 0);
                profiles.add(new InvariantDeviceProfile(
                        a.getString(R.styleable.InvariantDeviceProfile_name),
                        a.getFloat(R.styleable.InvariantDeviceProfile_minWidthDps, 0),
                        a.getFloat(R.styleable.InvariantDeviceProfile_minHeightDps, 0),
                        numRows,
                        numColumns,
                        a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows),
                        a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
                        a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
                        iconSize,
                        a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
                        a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns),
                        a.getFloat(R.styleable.InvariantDeviceProfile_hotseatIconSize, iconSize),
                        a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0)));
                a.recycle();
            }
        }
    } catch (IOException|XmlPullParserException e) {
        throw new RuntimeException(e);
    }
    return profiles;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:36,代碼來源:InvariantDeviceProfile.java

示例11: nextElementWithin

public static boolean nextElementWithin(XmlPullParser parser, int outerDepth)
        throws IOException, XmlPullParserException {
    for (;;) {
        int type = parser.next();
        if (type == XmlPullParser.END_DOCUMENT
                || (type == XmlPullParser.END_TAG && parser.getDepth() == outerDepth)) {
            return false;
        }
        if (type == XmlPullParser.START_TAG
                && parser.getDepth() == outerDepth + 1) {
            return true;
        }
    }
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:14,代碼來源:XmlUtils.java

示例12: parserSimples

public static List<String> parserSimples(String rssFeed) throws XmlPullParserException, IOException {
    // pegando instancia da XmlPullParserFactory [singleton]
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    // criando novo objeto do tipo XmlPullParser
    XmlPullParser parser = factory.newPullParser();
    // Definindo a entrada do nosso parser - argumento passado como parametro
    parser.setInput(new StringReader(rssFeed));
    // Definindo retorno
    List<String> items = new ArrayList<String>();

    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG) {
            String tag = parser.getName();
            //delimitando que estamos apenas interessados em tags <item>
            if (tag.equals("item")) {
                String title = "";
                while (parser.next() != XmlPullParser.END_TAG) {
                    if (parser.getEventType() == XmlPullParser.START_TAG) {
                        String tagAberta = parser.getName();
                        //pegando as tags <title>
                        if (tagAberta.equals("title")) {
                            title = parser.nextText();
                            items.add(title);
                        } else {
                            parser.next();
                        }
                        parser.nextTag();
                    }
                }
            }
        }
    }
    return items;
}
 
開發者ID:if1001,項目名稱:tarefa01-blaandrade,代碼行數:34,代碼來源:ParserRSS.java

示例13: parseImpl

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,代碼行數:40,代碼來源:ProcedureInfo.java

示例14: loadAllDrawables

private void loadAllDrawables(String packageName) {
    mDrawables.clear();
    XmlPullParser xpp;
    try {
        Resources res = mPackageManager.getResourcesForApplication(packageName);
        mCurrentIconPackRes = res;
        int resource = res.getIdentifier("drawable", "xml", packageName);
        if (resource < 0) {
            return;
        }
        xpp = res.getXml(resource);
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                if (xpp.getName().equals("item")) {
                    String drawableName = xpp.getAttributeValue(null, "drawable");
                    if (!mDrawables.contains(drawableName) &&
                            getIdentifier(packageName, drawableName, true) > 0) {
                        mDrawables.add(drawableName);
                    }
                }
            }
            eventType = xpp.next();
        }
    } catch (Exception e) {
        e.printStackTrace();
        // fallback onto appfilter if drawable xml fails
        loadIconPack(packageName, true, mContext);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:30,代碼來源:IconsManager.java

示例15: retrieveSupportedDevices

private static void retrieveSupportedDevices(final Resources resources) {
    final String tag = "retrieveDeviceData - ";

    if (supportedDevices == null) {
        final List<SupportedDevice> result = new ArrayList<>();
        final XmlResourceParser xml = resources.getXml(R.xml.supported_devices);
        try {
            xml.next();
            int eventType;
            while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) {
                switch (eventType) {
                    case XmlPullParser.START_TAG:
                        if (xml.getName().equals("usb-device")) {
                            final AttributeSet as = Xml.asAttributeSet(xml);
                            final Integer vendorId = parseInt(as.getAttributeValue(null, "vendor-id"));
                            final Integer productId = parseInt(as.getAttributeValue(null, "product-id"));

                            // Read description
                            String description=null;
                            xml.next();
                            if (xml.getName().equals("description")) {
                                xml.require(XmlPullParser.START_TAG, null, "description");
                                if (xml.next() == XmlPullParser.TEXT) {
                                    description = xml.getText();
                                    xml.nextTag();
                                }

                                xml.require(XmlPullParser.END_TAG, null, "description");
                            }
                            result.add(new SupportedDevice(new Pair<>(vendorId, productId), description));
                        }
                        break;
                }
                xml.next();
            }
        } catch (XmlPullParserException | IOException e) {
            Log.e(TAG, tag, e);
        }

        supportedDevices = result;
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:42,代碼來源:UsbUtils.java


注:本文中的org.xmlpull.v1.XmlPullParser.END_DOCUMENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。