本文整理汇总了Java中com.rometools.rome.feed.synd.SyndEntry.getCategories方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.getCategories方法的具体用法?Java SyndEntry.getCategories怎么用?Java SyndEntry.getCategories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.synd.SyndEntry
的用法示例。
在下文中一共展示了SyndEntry.getCategories方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCategories
import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public static List<String> getCategories() {
final List<String> allCategories = new ArrayList<>();
for (final SyndEntry entry : sCurrentFeed.getEntries()) {
for (final SyndCategory category : entry.getCategories()) {
final String name = category.getName();
if (!TextUtils.isEmpty(name) && !allCategories.contains(name)) {
allCategories.add(name);
}
}
}
Collections.sort(allCategories);
return allCategories;
}
示例2: getCategoriesPositions
import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public static List<Integer> getCategoriesPositions(final List<String> categories) {
final List<Integer> positions = new ArrayList<>();
int i = 1;
for (final SyndEntry entry : sCurrentFeed.getEntries()) {
for (final SyndCategory category : entry.getCategories()) {
if (categories.contains(category.getName()) && !positions.contains(i)) {
positions.add(i);
}
}
i++;
}
Collections.sort(positions);
return positions;
}
示例3: createRSSItem
import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = super.createRSSItem(sEntry);
final List<SyndCategory> sCats = sEntry.getCategories(); // c
if (!sCats.isEmpty()) {
item.setCategories(createRSSCategories(sCats));
}
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
if (!sEnclosures.isEmpty()) {
item.setEnclosures(createEnclosures(sEnclosures));
}
return item;
}
示例4: isCategoriesAvailable
import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public static boolean isCategoriesAvailable() {
if (sCurrentFeed != null) {
for (final SyndEntry entry : sCurrentFeed.getEntries()) {
for (final SyndCategory category : entry.getCategories()) {
if (!TextUtils.isEmpty(category.getName())) {
return true;
}
}
}
}
return false;
}
示例5: doParseXML
import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
protected FeedParseBo doParseXML(String feedId, Date lastedSyncDate, String xml) throws Exception {
FeedParseBo feedParseBo = null;
StringReader sr = null;
InputSource is = null;
try {
xml = new String(xml.getBytes("utf-8"));
sr = new StringReader(xml);
is = new InputSource(sr);
SyndFeedInput input = new SyndFeedInput();
// 得到SyndFeed对象,即得到Rss源里的所有信息
SyndFeed syndFeed = input.build(is);
// 得到Rss新闻中子项列表
List<SyndEntry> entries = syndFeed.getEntries();
// 循环得到每个子项信息
for (int i = 0; i < entries.size(); i++) {
SyndEntry entry = entries.get(i);
// 标题、连接地址、标题简介、时间是一个Rss源项最基本的组成部分
// logger.debug("标题:" + entry.getTitle());
// logger.debug("连接地址:" + entry.getLink());
SyndContent description = entry.getDescription();
String descriptionValue = description.getValue();
if (!StringUtils.isEmpty(descriptionValue)) {
descriptionValue = descriptionValue.substring(0, 10) + "...";
}
// logger.debug("简介model:" + description.getMode());
// logger.debug("简介type:" + description.getType());
// logger.debug("简介value:" + descriptionValue);
// logger.debug("发布时间:" + entry.getPublishedDate());
// 以下是Rss源可先的几个部分
// logger.debug("标题的作者:" + entry.getAuthor());
logger.debug("entry:" + StringUtils.toJSONString(entry));
// 此标题所属的范畴
List<SyndCategory> categoryList = entry.getCategories();
if (categoryList != null) {
for (int m = 0; m < categoryList.size(); m++) {
// SyndCategory category = (SyndCategory)
// categoryList.get(m);
// logger.debug("此标题所属的范畴:" + category.getName());
}
}
// 得到流媒体播放文件的信息列表
List<SyndEnclosure> enclosureList = entry.getEnclosures();
if (enclosureList != null) {
for (int n = 0; n < enclosureList.size(); n++) {
// SyndEnclosure enclosure = (SyndEnclosure)
// enclosureList.get(n);
// logger.debug("流媒体播放文件:" + entry.getEnclosures());
// logger.debug("流媒体播放文件2:" + enclosure.getUrl());
}
}
}
} catch (Exception e) {
logger.error("RSSParser.doParseByRome is error.", e);
throw e;
} finally {
if (is != null) {
is = null;
}
if (sr != null) {
sr.close();
}
}
return feedParseBo;
}