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


Java XmlPullParser.getAttributeName方法代码示例

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


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

示例1: parseIcon

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static XmlTvIcon parseIcon(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    String src = null;
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        String attr = parser.getAttributeName(i);
        String value = parser.getAttributeValue(i);
        if (ATTR_SRC.equalsIgnoreCase(attr)) {
            src = value;
        }
    }
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        if (TAG_ICON.equalsIgnoreCase(parser.getName())
                && parser.getEventType() == XmlPullParser.END_TAG) {
            break;
        }
    }
    if (TextUtils.isEmpty(src)) {
        throw new IllegalArgumentException("src cannot be null.");
    }
    return new XmlTvIcon(src);
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:22,代码来源:XmlTvParser.java

示例2: 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

示例3: 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

示例4: 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

示例5: getFilter

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static StringFilter getFilter(ValueProvider valueProvider, XmlPullParser parser,
                                      int attributeIndex) {
    String attributeName = parser.getAttributeName(attributeIndex);

    switch (attributeName.charAt(0)) {
        case 'e':
            if (!attributeName.equals(ATTR_EQUALS)) {
                return null;
            }
            return new EqualsFilter(valueProvider, parser.getAttributeValue(attributeIndex));
        case 'i':
            if (!attributeName.equals(ATTR_IS_NULL)) {
                return null;
            }
            return new IsNullFilter(valueProvider, parser.getAttributeValue(attributeIndex));
        case 's':
            if (!attributeName.equals(ATTR_STARTS_WITH)) {
                return null;
            }
            return new StartsWithFilter(valueProvider,
                    parser.getAttributeValue(attributeIndex));
        case 'c':
            if (!attributeName.equals(ATTR_CONTAINS)) {
                return null;
            }
            return new ContainsFilter(valueProvider, parser.getAttributeValue(attributeIndex));
        case 'p':
            if (!attributeName.equals(ATTR_PATTERN)) {
                return null;
            }
            return new PatternStringFilter(valueProvider,
                    parser.getAttributeValue(attributeIndex));
        case 'r':
            if (!attributeName.equals(ATTR_REGEX)) {
                return null;
            }
            return new RegexFilter(valueProvider, parser.getAttributeValue(attributeIndex));
    }
    return null;
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:41,代码来源:StringFilter.java

示例6: findMaxChoices

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public int findMaxChoices(XmlPullParser xpp)
{
    for (int i = 0; i < xpp.getAttributeCount(); i++)
    {
        String name = xpp.getAttributeName(i);

        if (name.equals("maxChoices"))
        {

            return Integer.parseInt(xpp.getAttributeValue(i));
        }
    }

    return -1;
}
 
开发者ID:wolfposd,项目名称:IMSQTI2PDF,代码行数:16,代码来源:XmlParser.java

示例7: 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

示例8: parseNode

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private TtmlNode parseNode(XmlPullParser parser, TtmlNode parent,
    Map<String, TtmlRegion> regionMap) throws ParserException {
  long duration = 0;
  long startTime = TtmlNode.UNDEFINED_TIME;
  long endTime = TtmlNode.UNDEFINED_TIME;
  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);
    if (ATTR_BEGIN.equals(attr)) {
      startTime = parseTimeExpression(value,
          DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
    } else if (ATTR_END.equals(attr)) {
      endTime = parseTimeExpression(value,
          DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
    } else if (ATTR_DURATION.equals(attr)) {
      duration = parseTimeExpression(value,
          DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
    } else if (ATTR_STYLE.equals(attr)) {
      // IDREFS: potentially multiple space delimited ids
      String[] ids = parseStyleIds(value);
      if (ids.length > 0) {
        styleIds = ids;
      }
    } else if (ATTR_REGION.equals(attr) && regionMap.containsKey(value)) {
      // If the region has not been correctly declared or does not define a position, we use the
      // anonymous region.
      regionId = value;
    } else {
      // Do nothing.
    }
  }
  if (parent != null && parent.startTimeUs != TtmlNode.UNDEFINED_TIME) {
    if (startTime != TtmlNode.UNDEFINED_TIME) {
      startTime += parent.startTimeUs;
    }
    if (endTime != TtmlNode.UNDEFINED_TIME) {
      endTime += parent.startTimeUs;
    }
  }
  if (endTime == TtmlNode.UNDEFINED_TIME) {
    if (duration > 0) {
      // Infer the end time from the duration.
      endTime = startTime + duration;
    } else if (parent != null && parent.endTimeUs != TtmlNode.UNDEFINED_TIME) {
      // 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:MLNO,项目名称:airgram,代码行数:55,代码来源:TtmlParser.java

示例9: 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

示例10: parseProgram

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static XmlTvProgram parseProgram(XmlPullParser parser)
        throws IOException, XmlPullParserException, ParseException {
    String channelId = null;
    Long startTimeUtcMillis = null;
    Long endTimeUtcMillis = null;
    String videoSrc = null;
    int videoType = DemoPlayer.SOURCE_TYPE_HTTP_PROGRESSIVE;
    for (int i = 0; i < parser.getAttributeCount(); ++i) {
        String attr = parser.getAttributeName(i);
        String value = parser.getAttributeValue(i);
        if (ATTR_CHANNEL.equalsIgnoreCase(attr)) {
            channelId = value;
        } else if (ATTR_START.equalsIgnoreCase(attr)) {
            startTimeUtcMillis = DATE_FORMAT.parse(value).getTime();
        } else if (ATTR_STOP.equalsIgnoreCase(attr)) {
            endTimeUtcMillis = DATE_FORMAT.parse(value).getTime();
        } else if (ATTR_VIDEO_SRC.equalsIgnoreCase(attr)) {
            videoSrc = value;
        } else if (ATTR_VIDEO_TYPE.equalsIgnoreCase(attr)) {
            if (VALUE_VIDEO_TYPE_HTTP_PROGRESSIVE.equals(value)) {
                videoType = DemoPlayer.SOURCE_TYPE_HTTP_PROGRESSIVE;
            } else if (VALUE_VIDEO_TYPE_HLS.equals(value)) {
                videoType = DemoPlayer.SOURCE_TYPE_HLS;
            } else if (VALUE_VIDEO_TYPE_MPEG_DASH.equals(value)) {
                videoType = DemoPlayer.SOURCE_TYPE_MPEG_DASH;
            }
        }
    }
    String title = null;
    String description = null;
    XmlTvIcon icon = null;
    List<String> category = new ArrayList<>();
    List<XmlTvRating> rating = new ArrayList<>();
    while (parser.next() != XmlPullParser.END_DOCUMENT) {
        String tagName = parser.getName();
        if (parser.getEventType() == XmlPullParser.START_TAG) {
            if (TAG_TITLE.equalsIgnoreCase(parser.getName())) {
                title = parser.nextText();
            } else if (TAG_DESC.equalsIgnoreCase(tagName)) {
                description = parser.nextText();
            } else if (TAG_ICON.equalsIgnoreCase(tagName)) {
                icon = parseIcon(parser);
            } else if (TAG_CATEGORY.equalsIgnoreCase(tagName)) {
                category.add(parser.nextText());
            } else if (TAG_RATING.equalsIgnoreCase(tagName)) {
                rating.add(parseRating(parser));
            }
        } else if (TAG_PROGRAM.equalsIgnoreCase(tagName)
                && parser.getEventType() == XmlPullParser.END_TAG) {
            break;
        }
    }
    if (TextUtils.isEmpty(channelId) || startTimeUtcMillis == null
            || endTimeUtcMillis == null) {
        throw new IllegalArgumentException("channel, start, and end can not be null.");
    }
    return new XmlTvProgram(channelId, title, description, icon,
            category.toArray(new String[category.size()]), startTimeUtcMillis, endTimeUtcMillis,
            rating.toArray(new XmlTvRating[rating.size()]), videoSrc, videoType);
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:61,代码来源:XmlTvParser.java

示例11: parseNode

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private TtmlNode parseNode(XmlPullParser parser, TtmlNode parent,
    Map<String, TtmlRegion> regionMap, FrameAndTickRate frameAndTickRate) throws ParserException {
  long duration = 0;
  long startTime = TtmlNode.UNDEFINED_TIME;
  long endTime = TtmlNode.UNDEFINED_TIME;
  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);
    if (ATTR_BEGIN.equals(attr)) {
      startTime = parseTimeExpression(value, frameAndTickRate);
    } else if (ATTR_END.equals(attr)) {
      endTime = parseTimeExpression(value, frameAndTickRate);
    } else if (ATTR_DURATION.equals(attr)) {
      duration = parseTimeExpression(value, frameAndTickRate);
    } else if (ATTR_STYLE.equals(attr)) {
      // IDREFS: potentially multiple space delimited ids
      String[] ids = parseStyleIds(value);
      if (ids.length > 0) {
        styleIds = ids;
      }
    } else if (ATTR_REGION.equals(attr) && regionMap.containsKey(value)) {
      // If the region has not been correctly declared or does not define a position, we use the
      // anonymous region.
      regionId = value;
    } else {
      // Do nothing.
    }
  }
  if (parent != null && parent.startTimeUs != TtmlNode.UNDEFINED_TIME) {
    if (startTime != TtmlNode.UNDEFINED_TIME) {
      startTime += parent.startTimeUs;
    }
    if (endTime != TtmlNode.UNDEFINED_TIME) {
      endTime += parent.startTimeUs;
    }
  }
  if (endTime == TtmlNode.UNDEFINED_TIME) {
    if (duration > 0) {
      // Infer the end time from the duration.
      endTime = startTime + duration;
    } else if (parent != null && parent.endTimeUs != TtmlNode.UNDEFINED_TIME) {
      // 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:pooyafaroka,项目名称:PlusGram,代码行数:52,代码来源:TtmlParser.java

示例12: 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


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