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


Java XmlPullParser.getAttributeCount方法代码示例

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


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

示例1: writeStartTag

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void writeStartTag(XmlPullParser var1) throws XmlPullParserException, IOException {
   int var2;
   if(!var1.getFeature("http://xmlpull.org/v1/doc/features.html#report-namespace-prefixes")) {
      var2 = var1.getNamespaceCount(var1.getDepth() - 1);
      int var3 = var1.getNamespaceCount(var1.getDepth());

      for(int var4 = var2; var4 < var3; ++var4) {
         String var5 = var1.getNamespacePrefix(var4);
         String var6 = var1.getNamespaceUri(var4);
         this.setPrefix(var5, var6);
      }
   }

   this.startTag(var1.getNamespace(), var1.getName());

   for(var2 = 0; var2 < var1.getAttributeCount(); ++var2) {
      this.attribute(var1.getAttributeNamespace(var2), var1.getAttributeName(var2), var1.getAttributeValue(var2));
   }

}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:21,代码来源:StaticXmlSerializerWrapper.java

示例2: onLoadAppFilter

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
@WorkerThread
private void onLoadAppFilter(XmlPullParser parser) {
    String componentName = null;
    String drawableName = null;

    for (int i = 0; i < parser.getAttributeCount(); i++) {
        if (parser.getAttributeName(i).equals(Constants.COMPONENT)) {
            componentName = parser.getAttributeValue(i);
        } else if (parser.getAttributeName(i).equals(Constants.DRAWABLE)) {
            drawableName = parser.getAttributeValue(i);
        }
    }
    if (!mAppFilterMap.containsKey(componentName)) {
        mAppFilterMap.put(componentName, drawableName);
    }
}
 
开发者ID:sofakingforever,项目名称:IconPackParser-Android,代码行数:17,代码来源:IconPack.java

示例3: getInnerXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException {
    StringBuilder sb = new StringBuilder();
    int depth = 1;
    while (depth != 0) {
        switch (parser.next()) {
            case XmlPullParser.END_TAG:
                depth--;
                if (depth > 0) {
                    sb.append("</").append(parser.getName()).append(">");
                }
                break;
            case XmlPullParser.START_TAG:
                depth++;
                StringBuilder attrs = new StringBuilder();
                for (int i = 0; i < parser.getAttributeCount(); i++) {
                    attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" ");
                }
                sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">");
                break;
            default:
                sb.append(parser.getText());
                break;
        }
    }
    return sb.toString();
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:27,代码来源:StringsManager.java

示例4: readAllAttribute

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void readAllAttribute(XmlPullParser parser) {
    int count = parser.getAttributeCount();
    for (int i = 0; i < count; i++) {
        String name = parser.getAttributeName(i);
        String value = parser.getAttributeValue(i);
        Log.d(TAG, name + "=" + "\"" + value + "\"");
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:ShortcutParser.java

示例5: getAttributeValue

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static String getAttributeValue(XmlPullParser xpp, String attributeName) {
  int attributeCount = xpp.getAttributeCount();
  for (int i = 0; i < attributeCount; i++) {
    if (attributeName.equals(xpp.getAttributeName(i))) {
      return xpp.getAttributeValue(i);
    }
  }
  return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:10,代码来源:ParserUtil.java

示例6: parse

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static void parse(final InputStream in, final OPMLFile file) throws OPMLParserException,
                                                                        XmlPullParserException,
                                                                        IOException {
    final XmlPullParser parser = Xml.newPullParser();

    parser.setInput(in, null);

    if (isInputEncodingUnsupported(parser)) {
        parserInvalidDocument(parser);
    }

    parser.nextTag();

    if (parser.getAttributeCount() != 1) {
        parserInvalidDocument(parser);
    }

    final String version = parser.getAttributeValue(0);

    if (!version.equals(OPML_1_0) && !version.equals(OPML_1_1) && !version.equals(OPML_2_0)) {
        parserInvalidDocument(parser);
    }

    parseOPML(parser, file, version);

    in.close();
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:28,代码来源:OPMLParser.java

示例7: getAttrPosition

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private int getAttrPosition(XmlPullParser xpp, String attrName) {
    for (int i = 0; i < xpp.getAttributeCount(); i++) {
        if (xpp.getAttributeName(i).equals(attrName)) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:harjot-oberai,项目名称:VectorMaster,代码行数:9,代码来源:VectorMasterDrawable.java

示例8: getAttrPosition

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
int getAttrPosition(XmlPullParser xpp, String attrName) {
    for (int i = 0; i < xpp.getAttributeCount(); i++) {
        if (xpp.getAttributeName(i).equals(attrName)) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:harjot-oberai,项目名称:VectorMaster,代码行数:9,代码来源:VectorMasterView.java

示例9: g

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static String g(XmlPullParser xmlPullParser) {
    int i = 0;
    while (i < xmlPullParser.getAttributeCount()) {
        String attributeName = xmlPullParser.getAttributeName(i);
        if ("xml:lang".equals(attributeName) || ("lang".equals(attributeName) && "xml".equals
                (xmlPullParser.getAttributePrefix(i)))) {
            return xmlPullParser.getAttributeValue(i);
        }
        i++;
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:c.java

示例10: parseAppLink

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static XmlTvAppLink parseAppLink(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    String text = null;
    Integer color = null;
    String posterUri = null;
    String intentUri = null;
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        String attr = parser.getAttributeName(i);
        String value = parser.getAttributeValue(i);
        if (ATTR_APP_LINK_TEXT.equalsIgnoreCase(attr)) {
            text = value;
        } else if (ATTR_APP_LINK_COLOR.equalsIgnoreCase(attr)) {
            color = Integer.valueOf(Color.parseColor(value));
        } else if (ATTR_APP_LINK_POSTER_URI.equalsIgnoreCase(attr)) {
            posterUri = value;
        } else if (ATTR_APP_LINK_INTENT_URI.equalsIgnoreCase(attr)) {
            intentUri = value;
        }
    }

    XmlTvIcon icon = null;
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG
                && TAG_ICON.equalsIgnoreCase(parser.getName()) && icon == null) {
            icon = parseIcon(parser);
        } else if (TAG_APP_LINK.equalsIgnoreCase(parser.getName())
                && parser.getEventType() == XmlPullParser.END_TAG) {
            break;
        }
    }

    return new XmlTvAppLink(text, color, posterUri, intentUri, icon);
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:34,代码来源:XmlTvParser.java

示例11: getRootFilesFromContainer

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static List<String> getRootFilesFromContainer(BufferedReader containerxml) {

        List<String> rootFiles = new ArrayList<>();

        try {

            containerxml.mark(4);
            if ('\ufeff' != containerxml.read()) containerxml.reset(); // not the BOM marker

            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(false);
            XmlPullParser xpp = factory.newPullParser();
            xpp.setInput(containerxml);

            int eventType = xpp.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                if (eventType == XmlPullParser.START_TAG) {
                    if (xpp.getName().equals("rootfile")) {
                        for (int i = 0; i < xpp.getAttributeCount(); i++) {
                            if (xpp.getAttributeName(i).equals("full-path")) {
                                rootFiles.add(xpp.getAttributeValue(i));
                            }
                        }
                    }

                }
                eventType = xpp.next();
            }
        } catch (Exception e) {
            Log.e("BMBF", "Error parsing xml " + e, e);
        }

        return rootFiles;

    }
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:36,代码来源:EpubBook.java

示例12: getAttributeValue

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * Returns the value of an attribute of the current start tag.
 *
 * @param xpp The {@link XmlPullParser} to query.
 * @param attributeName The name of the attribute.
 * @return The value of the attribute, or null if the current event is not a start tag or if no
 *     no such attribute was found.
 */
public static String getAttributeValue(XmlPullParser xpp, String attributeName) {
  int attributeCount = xpp.getAttributeCount();
  for (int i = 0; i < attributeCount; i++) {
    if (attributeName.equals(xpp.getAttributeName(i))) {
      return xpp.getAttributeValue(i);
    }
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:18,代码来源:XmlPullParserUtil.java

示例13: process

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * Be called when parser has found 'layout' node at a time
 */
@Override
public void process(XmlPullParser parser) throws XmlPullParserException, IOException {

	int attributesCount = parser.getAttributeCount();
	String attributeName, attributeValue;
	// Iterate attributes!			
	for (int i = 0; i < attributesCount; ++i) {
		attributeName = parser.getAttributeName(i);
		attributeValue = parser.getAttributeValue(i);
		// The 'name' attribute is as a layout code of each layout's class  
		if ( "name".equals(attributeName)) {
			// Skip if attribute value is null or empty 
			if ( attributeValue == null || attributeValue.length() == 0 ) {
				continue;
			}
			
			// Get layout's class name
			String clazzName = parser.nextText();
			
			// Insert new class name 
			layoutClazzNameMap.put(attributeValue, clazzName);

			// Do 'break' because nextText() method has been called
			break;
		}
	}
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:31,代码来源:PullToRefreshConfigXmlParser.java

示例14: parseNode

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private TtmlNode parseNode(XmlPullParser parser, TtmlNode parent,
    Map<String, TtmlRegion> regionMap, FrameAndTickRate frameAndTickRate)
    throws SubtitleDecoderException {
  long duration = C.TIME_UNSET;
  long startTime = C.TIME_UNSET;
  long endTime = C.TIME_UNSET;
  String regionId = TtmlNode.ANONYMOUS_REGION_ID;
  String[] styleIds = null;
  int attributeCount = parser.getAttributeCount();
  TtmlStyle style = parseStyleAttributes(parser, null);
  for (int i = 0; i < attributeCount; i++) {
    String attr = parser.getAttributeName(i);
    String value = parser.getAttributeValue(i);
    switch (attr) {
      case ATTR_BEGIN:
        startTime = parseTimeExpression(value, frameAndTickRate);
        break;
      case ATTR_END:
        endTime = parseTimeExpression(value, frameAndTickRate);
        break;
      case ATTR_DURATION:
        duration = parseTimeExpression(value, frameAndTickRate);
        break;
      case ATTR_STYLE:
        // IDREFS: potentially multiple space delimited ids
        String[] ids = parseStyleIds(value);
        if (ids.length > 0) {
          styleIds = ids;
        }
        break;
      case ATTR_REGION:
        if (regionMap.containsKey(value)) {
          // If the region has not been correctly declared or does not define a position, we use
          // the anonymous region.
          regionId = value;
        }
        break;
      default:
        // Do nothing.
        break;
    }
  }
  if (parent != null && parent.startTimeUs != C.TIME_UNSET) {
    if (startTime != C.TIME_UNSET) {
      startTime += parent.startTimeUs;
    }
    if (endTime != C.TIME_UNSET) {
      endTime += parent.startTimeUs;
    }
  }
  if (endTime == C.TIME_UNSET) {
    if (duration != C.TIME_UNSET) {
      // Infer the end time from the duration.
      endTime = startTime + duration;
    } else if (parent != null && parent.endTimeUs != C.TIME_UNSET) {
      // If the end time remains unspecified, then it should be inherited from the parent.
      endTime = parent.endTimeUs;
    }
  }
  return TtmlNode.buildNode(parser.getName(), startTime, endTime, style, styleIds, regionId);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:62,代码来源:TtmlDecoder.java

示例15: parseChannel

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static XmlTvChannel parseChannel(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    String id = null;
    boolean repeatPrograms = false;
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        String attr = parser.getAttributeName(i);
        String value = parser.getAttributeValue(i);
        if (ATTR_ID.equalsIgnoreCase(attr)) {
            id = value;
        } else if (ATTR_REPEAT_PROGRAMS.equalsIgnoreCase(attr)) {
            repeatPrograms = "TRUE".equalsIgnoreCase(value);
        }
    }
    String displayName = null;
    String displayNumber = null;
    XmlTvIcon icon = null;
    XmlTvAppLink appLink = null;
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (parser.getEventType() == XmlPullParser.START_TAG) {
            if (TAG_DISPLAY_NAME.equalsIgnoreCase(parser.getName())
                    && displayName == null) {
                // TODO: support multiple display names.
                displayName = parser.nextText();
            } else if (TAG_DISPLAY_NUMBER.equalsIgnoreCase(parser.getName())
                    && displayNumber == null) {
                displayNumber = parser.nextText();
            } else if (TAG_ICON.equalsIgnoreCase(parser.getName()) && icon == null) {
                icon = parseIcon(parser);
            } else if (TAG_APP_LINK.equalsIgnoreCase(parser.getName()) && appLink == null) {
                appLink = parseAppLink(parser);
            }
        } else if (TAG_CHANNEL.equalsIgnoreCase(parser.getName())
                && parser.getEventType() == XmlPullParser.END_TAG) {
            break;
        }
    }
    if (TextUtils.isEmpty(id) || TextUtils.isEmpty(displayName)) {
        throw new IllegalArgumentException("id and display-name can not be null.");
    }

    // Developers should assign original network ID in the right way not using the fake ID.
    int fakeOriginalNetworkId = (displayNumber + displayName).hashCode();
    return new XmlTvChannel(id, displayName, displayNumber, icon, appLink,
            fakeOriginalNetworkId, 0, 0, repeatPrograms);
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:46,代码来源:XmlTvParser.java


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