Java 类org.xmlpull.v1.XmlPullParser 实例源码

项目:NanoIconPackLite    文件:LiteIconActivityV1.java   
private Set<String> getIcons() {
//        Set<String> iconSet = new TreeSet<>(); // 字母顺序
        Set<String> iconSet = new LinkedHashSet<>(); // 录入顺序
        XmlResourceParser parser = getResources().getXml(R.xml.drawable);
        try {
            int event = parser.getEventType();
            while (event != XmlPullParser.END_DOCUMENT) {
                if (event == XmlPullParser.START_TAG) {
                    if (!"item".equals(parser.getName())) {
                        event = parser.next();
                        continue;
                    }
                    iconSet.add(parser.getAttributeValue(null, "drawable"));
                }
                event = parser.next();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return iconSet;
    }
项目:VirtualHook    文件:VAccountManagerService.java   
private void generateServicesMap(List<ResolveInfo> services, Map<String, AuthenticatorInfo> map,
                                 IAccountParser accountParser) {
    for (ResolveInfo info : services) {
        XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo,
                AccountManager.AUTHENTICATOR_META_DATA_NAME);
        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 (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
                    AuthenticatorDescription desc = parseAuthenticatorDescription(
                            accountParser.getResources(mContext, info.serviceInfo.applicationInfo),
                            info.serviceInfo.packageName, attributeSet);
                    if (desc != null) {
                        map.put(desc.type, new AuthenticatorInfo(desc, info.serviceInfo));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
项目:AOSP-Kayboard-7.1.2    文件:KeyboardRow.java   
public KeyboardRow(final Resources res, final KeyboardParams params,
        final XmlPullParser parser, final int y) {
    mParams = params;
    final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.Keyboard);
    mRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr,
            R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mDefaultRowHeight);
    keyboardAttr.recycle();
    final TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.Keyboard_Key);
    mRowAttributesStack.push(new RowAttributes(
            keyAttr, params.mDefaultKeyWidth, params.mBaseWidth));
    keyAttr.recycle();

    mCurrentY = y;
    mCurrentX = 0.0f;
}
项目:NanoIconPack    文件:AppfilterReader.java   
private boolean init(@NonNull Resources resources) {
    try {
        XmlResourceParser parser = resources.getXml(R.xml.appfilter);
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!"item".equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                String drawable = parser.getAttributeValue(null, "drawable");
                if (TextUtils.isEmpty(drawable)) {
                    event = parser.next();
                    continue;
                }
                String component = parser.getAttributeValue(null, "component");
                if (TextUtils.isEmpty(component)) {
                    event = parser.next();
                    continue;
                }
                Matcher matcher = componentPattern.matcher(component);
                if (!matcher.matches()) {
                    event = parser.next();
                    continue;
                }
                dataList.add(new Bean(matcher.group(1), matcher.group(2), drawable));
            }
            event = parser.next();
        }
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
项目:q-mail    文件:SettingsImporter.java   
private static ImportedServer parseServerSettings(XmlPullParser xpp, String endTag)
        throws XmlPullParserException, IOException {
    ImportedServer server = new ImportedServer();

    server.type = xpp.getAttributeValue(null, SettingsExporter.TYPE_ATTRIBUTE);

    int eventType = xpp.next();
    while (!(eventType == XmlPullParser.END_TAG && endTag.equals(xpp.getName()))) {
        if (eventType == XmlPullParser.START_TAG) {
            String element = xpp.getName();
            if (SettingsExporter.HOST_ELEMENT.equals(element)) {
                server.host = getText(xpp);
            } else if (SettingsExporter.PORT_ELEMENT.equals(element)) {
                server.port = getText(xpp);
            } else if (SettingsExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) {
                server.connectionSecurity = getText(xpp);
            } else if (SettingsExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) {
                String text = getText(xpp);
                server.authenticationType = AuthType.valueOf(text);
            } else if (SettingsExporter.USERNAME_ELEMENT.equals(element)) {
                server.username = getText(xpp);
            } else if (SettingsExporter.CLIENT_CERTIFICATE_ALIAS_ELEMENT.equals(element)) {
                server.clientCertificateAlias = getText(xpp);
            } else if (SettingsExporter.PASSWORD_ELEMENT.equals(element)) {
                server.password = getText(xpp);
            } else if (SettingsExporter.EXTRA_ELEMENT.equals(element)) {
                server.extras = parseSettings(xpp, SettingsExporter.EXTRA_ELEMENT);
            } else {
                Timber.w("Unexpected start tag: %s", xpp.getName());
            }
        }
        eventType = xpp.next();
    }

    return server;
}
项目:q-mail    文件:SettingsImporter.java   
private static List<ImportedFolder> parseFolders(XmlPullParser xpp) throws XmlPullParserException, IOException {
    List<ImportedFolder> folders = null;

    int eventType = xpp.next();
    while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.FOLDERS_ELEMENT.equals(xpp.getName()))) {
        if (eventType == XmlPullParser.START_TAG) {
            String element = xpp.getName();
            if (SettingsExporter.FOLDER_ELEMENT.equals(element)) {
                if (folders == null) {
                    folders = new ArrayList<>();
                }

                ImportedFolder folder = parseFolder(xpp);
                folders.add(folder);
            } else {
                Timber.w("Unexpected start tag: %s", xpp.getName());
            }
        }
        eventType = xpp.next();
    }

    return folders;
}
项目:boohee_v5.6    文件:c.java   
private static String f(XmlPullParser xmlPullParser) {
    String str = "";
    int depth = xmlPullParser.getDepth();
    while (true) {
        if (xmlPullParser.next() == 3 && xmlPullParser.getDepth() == depth) {
            return str;
        }
        str = str + xmlPullParser.getText();
    }
}
项目:eBread    文件:SettingManager.java   
/***
 * Public method that read information about theme settings from XML file
 * @param parser                    the current parser used to parse the XML file
 * @return ThemeSetting contains loaded settings
 * @throws XmlPullParserException
 * @throws IOException
 */
private ThemeSetting readThemeSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, null, "themesetting");

    ArrayMap<String, String> newValues = new ArrayMap<>();
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("font")) {
            newValues.put("font", readText(parser));
        } else if (name.equals("palette")) {
            newValues.put("palette", readText(parser));
        } else if (name.equals("highlight")) {
            newValues.put("highlight", readText(parser));
        }
    }

    ThemeSetting themesetting = new ThemeSetting();
    themesetting.changeSetting(newValues);
    return themesetting;
}
项目:FlickLauncher    文件:AutoInstallsLayout.java   
/**
 * Parses the layout and returns the number of elements added on the homescreen.
 */
protected 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;
}
项目:simple-keyboard    文件:KeyboardLayoutSet.java   
private void parseKeyboardLayoutSetElement(final XmlPullParser parser)
        throws XmlPullParserException, IOException {
    final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.KeyboardLayoutSet_Element);
    try {
        XmlParseUtils.checkAttributeExists(a,
                R.styleable.KeyboardLayoutSet_Element_elementName, "elementName",
                TAG_ELEMENT, parser);
        XmlParseUtils.checkAttributeExists(a,
                R.styleable.KeyboardLayoutSet_Element_elementKeyboard, "elementKeyboard",
                TAG_ELEMENT, parser);
        XmlParseUtils.checkEndTag(TAG_ELEMENT, parser);

        final ElementParams elementParams = new ElementParams();
        final int elementName = a.getInt(
                R.styleable.KeyboardLayoutSet_Element_elementName, 0);
        elementParams.mKeyboardXmlId = a.getResourceId(
                R.styleable.KeyboardLayoutSet_Element_elementKeyboard, 0);
        elementParams.mAllowRedundantMoreKeys = a.getBoolean(
                R.styleable.KeyboardLayoutSet_Element_allowRedundantMoreKeys, true);
        mParams.mKeyboardLayoutSetElementIdToParamsMap.put(elementName, elementParams);
    } finally {
        a.recycle();
    }
}
项目:SciChart.Android.Examples    文件:ExampleDefinitionParser.java   
private List<Features> readFeatures(XmlPullParser parser) throws XmlPullParserException {
    final List<Features> result = new ArrayList<>();
    try {
        parser.require(XmlPullParser.START_TAG, null, FEATURES);
        while(parser.next() != XmlPullParser.END_TAG){
            if(parser.getEventType() != XmlPullParser.START_TAG){
                continue;
            }

            String name = parser.getName();
            if (name.equals(FEATURES)) {
                result.add(Features.valueOf(readText(parser)));
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
项目:SimpleRssReader    文件:FeedParser.java   
private static void skip(final XmlPullParser parser) throws XmlPullParserException,
                                                            IOException {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
        throw new IllegalStateException();
    }

    int depth = 1;

    while (depth != 0) {
        switch (parser.next()) {
            case XmlPullParser.END_TAG:
                depth--;
                break;
            case XmlPullParser.START_TAG:
                depth++;
                break;
            default:
                break;
        }
    }
}
项目:directory-ldap-api    文件:Dsmlv2Parser.java   
/**
 * Processes the task required in the grammar to the given tag type
 *
 * @param container the DSML container
 * @param tagType the tag type
 * @throws XmlPullParserException when an error occurs during the parsing
 */
private static void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
{
    XmlPullParser xpp = container.getParser();

    String tagName = Strings.lowerCase( xpp.getName() );

    GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );

    if ( transition != null )
    {
        container.setState( transition.getNextState() );

        if ( transition.hasAction() )
        {
            transition.getAction().action( container );
        }
    }
    else
    {
        throw new XmlPullParserException( I18n.err( I18n.ERR_03036, new Tag( tagName, tagType ) ), xpp, null );
    }
}
项目:IFWManager    文件:SenderFilter.java   
@Override
public Filter newFilter(XmlPullParser parser) throws IOException, XmlPullParserException {
    String typeString = parser.getAttributeValue(null, ATTR_TYPE);
    if (typeString == null) {
        throw new XmlPullParserException("type attribute must be specified for <sender>",
                parser, null);
    }
    if (typeString.equals(VAL_SYSTEM)) {
        return SYSTEM;
    } else if (typeString.equals(VAL_SIGNATURE)) {
        return SIGNATURE;
    } else if (typeString.equals(VAL_SYSTEM_OR_SIGNATURE)) {
        return SYSTEM_OR_SIGNATURE;
    } else if (typeString.equals(VAL_USER_ID)) {
        return USER_ID;
    }
    throw new XmlPullParserException(
            "Invalid type attribute for <sender>: " + typeString, parser, null);
}
项目:keepass2android    文件:PropfindXmlParser.java   
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;
}
项目:directory-ldap-api    文件:Dsmlv2Grammar.java   
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml )
        container.getBatchRequest().getCurrentRequest();

    XmlPullParser xpp = container.getParser();

    OrFilter filter = new OrFilter();

    // Adding the filter to the Search Filter
    try
    {
        searchRequestDecorator.addCurrentFilter( filter );
    }
    catch ( DecoderException de )
    {
        throw new XmlPullParserException( de.getMessage(), xpp, de );
    }
}
项目:GankIO_weex    文件:ConfigXmlParser.java   
private void handleEndTag(XmlPullParser xml) {
  String strNode = xml.getName();
  if (strNode.equals(Constants.TAG_FEATURE)) {
    if (TextUtils.equals(Constants.CATEGORY_MODULE, mCategory)) {
      mModules.put(mApi, new PluginEntry(mApi, mPluginClass, mOnLoad, Constants.CATEGORY_MODULE));
    } else if (TextUtils.equals(Constants.CATEGORY_COMPONENT, mCategory)) {
      mComponents.put(mApi, new PluginEntry(mApi, mPluginClass, mOnLoad, Constants.CATEGORY_COMPONENT));
    }

    mService = "";
    mPluginClass = "";
    mInsideFeature = false;
    mOnLoad = false;
    mCategory = Constants.CATEGORY_MODULE;
    mApi = "";
    mParamType = "";
  }
}
项目:AOSP-Kayboard-7.1.2    文件:KeyboardBuilder.java   
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
        throws XmlPullParserException {
    final AttributeSet attr = Xml.asAttributeSet(parser);
    final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
    try {
        if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
        }
        if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
        }
        return new KeyboardRow(mResources, mParams, parser, mCurrentY);
    } finally {
        keyboardAttr.recycle();
    }
}
项目:simple-keyboard    文件:KeyboardBuilder.java   
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
        throws XmlPullParserException {
    final AttributeSet attr = Xml.asAttributeSet(parser);
    final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
    try {
        if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
        }
        if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
        }
        return new KeyboardRow(mResources, mParams, parser, mCurrentY);
    } finally {
        keyboardAttr.recycle();
    }
}
项目:LeMondeRssReader    文件:RssParser.java   
@NonNull
ArrayList<RssItem> parse(String stream) {
    ArrayList<RssItem> items = null;
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(new StringReader(stream));
        parser.nextTag();
        parser.require(XmlPullParser.START_TAG, null, TAG_RSS);
        items = readFeed(parser);
    } catch (@NonNull XmlPullParserException | IOException e) {
        Log.w(e.getMessage(), e);
    } finally {
        if (items == null) {
            items = new ArrayList<>();
        }
    }
    return items;
}
项目:gexporter    文件:Gpx2Fit.java   
public Gpx2Fit(String name, InputStream in, Gpx2FitOptions options) throws Exception {
    mGpx2FitOptions = options;
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser parser = factory.newPullParser();
    //parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
    courseName = name;
    BufferedInputStream inputStream = new BufferedInputStream(in);
    inputStream.mark(64000);

    //FileInputStream in = new FileInputStream(file);

    try {
        parser.setInput(inputStream, null);
        parser.nextTag();
        readGPX(parser);
        inputStream.close();
        return;
    } catch (Exception e) {
        ns = HTTP_WWW_TOPOGRAFIX_COM_GPX_1_0;
        Log.debug("Ex {}", e);
    }

    inputStream.reset();

    try {
        parser.setInput(inputStream, null);
        parser.nextTag();
        readGPX(parser);
    } finally {
        inputStream.close();
    }
}
项目:AndroidApktool    文件:XmlPullUtil.java   
public static String getRequiredAttributeValue(XmlPullParser var0, String var1, String var2) throws IOException, XmlPullParserException {
   String var3 = var0.getAttributeValue(var1, var2);
   if(var3 == null) {
      throw new XmlPullParserException("required attribute " + var2 + " is not present");
   } else {
      return var3;
   }
}
项目:webtrekk-android-sdk    文件:TrackingConfigurationXmlParser.java   
/**
 * reads a String value from xml tag
 *
 * @param parser
 * @return
 * @throws IOException
 * @throws XmlPullParserException
 */
private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";
    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }
    return result;
}
项目:boohee_v5.6    文件:VectorDrawableCompat.java   
public void inflate(Resources r, AttributeSet attrs, Theme theme, XmlPullParser parser) {
    if (TypedArrayUtils.hasAttribute(parser, "pathData")) {
        TypedArray a = VectorDrawableCommon.obtainAttributes(r, theme, attrs, AndroidResources.styleable_VectorDrawableClipPath);
        updateStateFromTypedArray(a);
        a.recycle();
    }
}
项目:gexporter    文件:Gpx2Fit.java   
private String readTrkName(XmlPullParser parser) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, ns, "name");
    String txt = readText(parser);
    if (txt.length() > 15)
        txt = txt.substring(0, 15);
    parser.require(XmlPullParser.END_TAG, ns, "name");
    return txt;
}
项目:q-mail    文件:SettingsImporter.java   
private static Map<String, ImportedAccount> parseAccounts(XmlPullParser xpp, List<String> accountUuids,
        boolean overview) throws XmlPullParserException, IOException {

    Map<String, ImportedAccount> accounts = null;

    int eventType = xpp.next();
    while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.ACCOUNTS_ELEMENT.equals(xpp.getName()))) {
        if (eventType == XmlPullParser.START_TAG) {
            String element = xpp.getName();
            if (SettingsExporter.ACCOUNT_ELEMENT.equals(element)) {
                if (accounts == null) {
                    accounts = new HashMap<>();
                }

                ImportedAccount account = parseAccount(xpp, accountUuids, overview);

                if (account == null) {
                    // Do nothing - parseAccount() already logged a message
                } else if (!accounts.containsKey(account.uuid)) {
                    accounts.put(account.uuid, account);
                } else {
                    Timber.w("Duplicate account entries with UUID %s. Ignoring!", account.uuid);
                }
            } else {
                Timber.w("Unexpected start tag: %s", xpp.getName());
            }
        }
        eventType = xpp.next();
    }

    return accounts;
}
项目:LucaHome-AndroidApplication    文件:RssParser.java   
private String readText(@NonNull XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";

    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }

    return result;
}
项目:PlusGram    文件:SmoothStreamingManifestParser.java   
protected final boolean parseBoolean(XmlPullParser parser, String key, boolean defaultValue) {
  String value = parser.getAttributeValue(null, key);
  if (value != null) {
    return Boolean.parseBoolean(value);
  } else {
    return defaultValue;
  }
}
项目:boohee_v5.6    文件:VectorDrawableCompat.java   
private void updateStateFromTypedArray(TypedArray a, XmlPullParser parser) throws XmlPullParserException {
    VectorDrawableCompatState state = this.mVectorState;
    VPathRenderer pathRenderer = state.mVPathRenderer;
    state.mTintMode = parseTintModeCompat(TypedArrayUtils.getNamedInt(a, parser, "tintMode", 6, -1), Mode.SRC_IN);
    ColorStateList tint = a.getColorStateList(1);
    if (tint != null) {
        state.mTint = tint;
    }
    state.mAutoMirrored = TypedArrayUtils.getNamedBoolean(a, parser, "autoMirrored", 5, state.mAutoMirrored);
    pathRenderer.mViewportWidth = TypedArrayUtils.getNamedFloat(a, parser, "viewportWidth", 7, pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = TypedArrayUtils.getNamedFloat(a, parser, "viewportHeight", 8, pathRenderer.mViewportHeight);
    if (pathRenderer.mViewportWidth <= 0.0f) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0.0f) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    } else {
        pathRenderer.mBaseWidth = a.getDimension(3, pathRenderer.mBaseWidth);
        pathRenderer.mBaseHeight = a.getDimension(2, pathRenderer.mBaseHeight);
        if (pathRenderer.mBaseWidth <= 0.0f) {
            throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
        } else if (pathRenderer.mBaseHeight <= 0.0f) {
            throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
        } else {
            pathRenderer.setAlpha(TypedArrayUtils.getNamedFloat(a, parser, "alpha", 4, pathRenderer.getAlpha()));
            String name = a.getString(0);
            if (name != null) {
                pathRenderer.mRootName = name;
                pathRenderer.mVGTargetsMap.put(name, pathRenderer);
            }
        }
    }
}
项目:simple-keyboard    文件:KeyboardBuilder.java   
private boolean parseCase(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
        throws XmlPullParserException, IOException {
    final boolean selected = parseCaseCondition(parser);
    if (row == null) {
        // Processing Rows.
        parseKeyboardContent(parser, !selected || skip);
    } else {
        // Processing Keys.
        parseRowContent(parser, row, !selected || skip);
    }
    return selected;
}
项目:referendum_1o_android    文件:StringsManager.java   
private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, "string");
    String stringName = parser.getAttributeValue(null, "name");
    String value = getInnerXml(parser);
    parser.require(XmlPullParser.END_TAG, null, "string");
    mStrings.put(stringName, value.replace("\\n", "\n"));
}
项目:nat-explorer    文件:AppConfigXmlParser.java   
private void handleStartTag(XmlPullParser xml) {
  String strNode = xml.getName();
  if (strNode.equals("preference")) {
    String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
    String value = xml.getAttributeValue(null, "value");
    prefs.set(name, value);
  }
}
项目:LaunchEnr    文件:AutoInstallsLayout.java   
@Override
public long parseAndAdd(XmlResourceParser parser)
        throws XmlPullParserException, IOException {
    final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
    final String className = getAttributeValue(parser, ATTR_CLASS_NAME);
    if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) {
        return -1;
    }

    mValues.put(Favorites.SPANX, getAttributeValue(parser, ATTR_SPAN_X));
    mValues.put(Favorites.SPANY, getAttributeValue(parser, ATTR_SPAN_Y));
    mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);

    // Read the extras
    Bundle extras = new Bundle();
    int widgetDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > widgetDepth) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        if (TAG_EXTRA.equals(parser.getName())) {
            String key = getAttributeValue(parser, ATTR_KEY);
            String value = getAttributeValue(parser, ATTR_VALUE);
            if (key != null && value != null) {
                extras.putString(key, value);
            } else {
                throw new RuntimeException("Widget extras must have a key and value");
            }
        } else {
            throw new RuntimeException("Widgets can contain only extras");
        }
    }

    return verifyAndInsert(new ComponentName(packageName, className), extras);
}
项目:keemob    文件:ConfigXmlParser.java   
public void handleStartTag(XmlPullParser xml) {
    String strNode = xml.getName();
    if (strNode.equals("feature")) {
        //Check for supported feature sets  aka. plugins (Accelerometer, Geolocation, etc)
        //Set the bit for reading params
        insideFeature = true;
        service = xml.getAttributeValue(null, "name");
    }
    else if (insideFeature && strNode.equals("param")) {
        paramType = xml.getAttributeValue(null, "name");
        if (paramType.equals("service")) // check if it is using the older service param
            service = xml.getAttributeValue(null, "value");
        else if (paramType.equals("package") || paramType.equals("android-package"))
            pluginClass = xml.getAttributeValue(null,"value");
        else if (paramType.equals("onload"))
            onload = "true".equals(xml.getAttributeValue(null, "value"));
    }
    else if (strNode.equals("preference")) {
        String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
        String value = xml.getAttributeValue(null, "value");
        prefs.set(name, value);
    }
    else if (strNode.equals("content")) {
        String src = xml.getAttributeValue(null, "src");
        if (src != null) {
            setStartUrl(src);
        }
    }
}
项目:localcloud_fe    文件:ConfigXmlParser.java   
public void handleStartTag(XmlPullParser xml) {
    String strNode = xml.getName();
    if (strNode.equals("feature")) {
        //Check for supported feature sets  aka. plugins (Accelerometer, Geolocation, etc)
        //Set the bit for reading params
        insideFeature = true;
        service = xml.getAttributeValue(null, "name");
    }
    else if (insideFeature && strNode.equals("param")) {
        paramType = xml.getAttributeValue(null, "name");
        if (paramType.equals("service")) // check if it is using the older service param
            service = xml.getAttributeValue(null, "value");
        else if (paramType.equals("package") || paramType.equals("android-package"))
            pluginClass = xml.getAttributeValue(null,"value");
        else if (paramType.equals("onload"))
            onload = "true".equals(xml.getAttributeValue(null, "value"));
    }
    else if (strNode.equals("preference")) {
        String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
        String value = xml.getAttributeValue(null, "value");
        prefs.set(name, value);
    }
    else if (strNode.equals("content")) {
        String src = xml.getAttributeValue(null, "src");
        if (src != null) {
            setStartUrl(src);
        }
    }
}
项目:OCast-Java    文件:DialServiceParser.java   
private AdditionalData readAdditionalData(XmlPullParser parser) throws IOException, XmlPullParserException, DialException {
    AdditionalData data = null;
    parser.require(XmlPullParser.START_TAG, null, TAG_ADDITIONAL_DATA);
    AbsAdditionalDataParser addparser = additionnalDataParser.get(parser.getNamespace("ocast"));
    if(addparser != null) {
        data = new OcastAdditionalDataParser().parseAdditionalData(parser);
    } else {
        DialParserUtils.skip(parser);
    }
    parser.require(XmlPullParser.END_TAG, null, TAG_ADDITIONAL_DATA);
    return data;
}
项目:container    文件:VUserManagerService.java   
private int readIntAttribute(XmlPullParser parser, String attr, int defaultValue) {
    String valueString = parser.getAttributeValue(null, attr);
    if (valueString == null) return defaultValue;
    try {
        return Integer.parseInt(valueString);
    } catch (NumberFormatException nfe) {
        return defaultValue;
    }
}
项目:Android-skin-support    文件:SkinCompatDrawableManager.java   
@SuppressLint("NewApi")
@Override
public Drawable createFromXmlInner(@NonNull Context context, @NonNull XmlPullParser parser,
                                   @NonNull AttributeSet attrs, @Nullable Resources.Theme theme) {
    try {
        return AnimatedVectorDrawableCompat
                .createFromXmlInner(context, context.getResources(), parser, attrs, theme);
    } catch (Exception e) {
        Log.e("AvdcInflateDelegate", "Exception while inflating <animated-vector>", e);
        return null;
    }
}
项目:AIMSICDL    文件:StackOverflowXmlParser.java   
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;
}
项目:directory-ldap-api    文件:Dsmlv2ResponseGrammar.java   
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    ExtendedResponseDsml extendedResponse = ( ExtendedResponseDsml ) container.getBatchResponse()
        .getCurrentResponse();

    XmlPullParser xpp = container.getParser();

    try
    {
        // We have to catch the type Attribute Value before going to the next Text node
        String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );

        // Getting the value
        String nextText = xpp.nextText();

        if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
        {
            extendedResponse.setResponseValue( Base64.decode( nextText.trim().toCharArray() ) );
        }
        else
        {
            extendedResponse.setResponseValue( Strings.getBytesUtf8( nextText.trim() ) );
        }
    }
    catch ( IOException ioe )
    {
        throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
    }
}