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