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


Java SyndCategory类代码示例

本文整理汇总了Java中com.sun.syndication.feed.synd.SyndCategory的典型用法代码示例。如果您正苦于以下问题:Java SyndCategory类的具体用法?Java SyndCategory怎么用?Java SyndCategory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyndCategory类属于com.sun.syndication.feed.synd包,在下文中一共展示了SyndCategory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCategories

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
/**
 * Returns a list of categories for feed or entry.
 * 
 * @param categories
 * @return
 */
private ArrayList<BasicDBObject> getCategories(
		ArrayList<SyndCategory> categories) {
	ArrayList<BasicDBObject> categoriesDB = new ArrayList<BasicDBObject>();
	for (SyndCategory category : categories) {
		BasicDBObject categoryDB = new BasicDBObject();

		if (category.getName() != null)
			categoryDB.append("name", category.getName());
		if (category.getTaxonomyUri() != null)
			categoryDB.append("taxonomyURI", category.getTaxonomyUri());
		if (category.getName() != null || category.getTaxonomyUri() != null)
			categoriesDB.add(categoryDB);
	}

	return categoriesDB;
}
 
开发者ID:jeryini,项目名称:distributed-rss,代码行数:23,代码来源:RSSThreadWorker.java

示例2: _testCategories

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
protected void _testCategories(List cats,String prefix) throws Exception {
    Set s1 = new HashSet();
    Set s2 = new HashSet();
    for (int i=0;i<cats.size();i++) {
        SyndCategory cat = (SyndCategory) cats.get(i);
        s1.add(cat.getTaxonomyUri()+" "+cat.getName());
        s2.add(getPrefix() + "." +prefix+".category["+i+"]^domain"+" "+getPrefix() + "." +prefix+".category["+i+"]");
    }
    assertTrue(s1.equals(s2));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:TestSyndFeedRSS092.java

示例3: getCategories

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List getCategories() {
    List<SyndCategory> categories = super.getCategories();
    List<SyndCategory> result = new ArrayList<SyndCategory>(categories.size());
    for (SyndCategory c : categories) {
        SyndCategory cc = new SyndCategoryImpl();
        if (c != null) {
            cc.setName(removeInvalidChars(c.getName()));
            cc.setTaxonomyUri(removeInvalidChars(c.getTaxonomyUri()));
        }
        result.add(cc);
    }
    return result;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:16,代码来源:ExtendedSyndEntryImpl.java

示例4: makeEntryFromRSSCorrespon

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
/**
 * コレポンからRSSのエントリー(それぞれのItem)を作成.
 */
private SyndEntry makeEntryFromRSSCorrespon(
    RSSCorrespon c, String baseURL) {
    if (log.isDebugEnabled()) {
        log.debug("id[{}]", c.getId());
    }
    SyndEntry entry = new ExtendedSyndEntryImpl();

    // title設定
    entry.setTitle(c.getSubject());
    // description設定
    entry.setDescription(makeDescriptionFromRSSCorrespon(c, baseURL));
    // link(とguid)設定
    entry.setLink(baseURL + "correspon/correspon.jsf?id=" + c.getId()
            + "&projectId=" + c.getProjectId());
    // author設定
    SyndPerson author = new SyndPersonImpl();
    author.setEmail(c.getProjectId() + " : " + c.getProjectNameE());
    List<SyndPerson> authors = new ArrayList<SyndPerson>();
    authors.add(author);
    entry.setAuthors(authors);
    // category設定
    SyndCategory category = new SyndCategoryImpl();
    category.setName(c.getCategory().getLabel());
    List<SyndCategory> categories = new ArrayList<SyndCategory>();
    categories.add(category);
    entry.setCategories(categories);
    // pubDate(とdc:date)設定
    entry.setPublishedDate(c.getUpdatedAt());

    return entry;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:35,代码来源:RSSServiceImpl.java

示例5: createSyndCategories

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
protected List createSyndCategories(List rssCats) {
    List syndCats = new ArrayList();
    for (int i=0;i<rssCats.size();i++) {
        Category rssCat = (Category) rssCats.get(i);
        SyndCategory sCat = new SyndCategoryImpl();
        sCat.setTaxonomyUri(rssCat.getDomain());
        sCat.setName(rssCat.getValue());
        syndCats.add(sCat);
    }
    return syndCats;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:12,代码来源:ConverterForRSS092.java

示例6: createRSSCategories

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
protected List createRSSCategories(List sCats) {
    List cats = new ArrayList();
    for (int i=0;i<sCats.size();i++) {
        SyndCategory sCat = (SyndCategory) sCats.get(i);
        Category cat = new Category();
        cat.setDomain(sCat.getTaxonomyUri());
        cat.setValue(sCat.getName());
        cats.add(cat);
    }
    return cats;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:12,代码来源:ConverterForRSS092.java

示例7: readAndPrintFeed

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
public void readAndPrintFeed(String feedURL) throws Exception {
        SyndFeedInput input = new SyndFeedInput();                
        SyndFeed feed = input.build(new XmlReader(new URL(feedURL)));
        System.out.println("FEED: " + feed.getDescription());
        System.out.println("type: "+feed.getFeedType()+"\n"+
                "copyright: "+feed.getCopyright()+"\n"+
                "author: "+feed.getAuthor()+"\n"+
                "uri: "+feed.getUri()+"\n"+
                "language: "+feed.getLanguage()+"\n"+
                "link: "+feed.getLink()+"\n");
        //System.out.println(feed);
        List entries = feed.getEntries();
        System.out.println("ENTRIES: ");
        for (Object o : entries) {
            SyndEntry e = (SyndEntry)o;
            System.out.println("FEED ENTRY:");
            System.out.println("title: "+e.getTitle()+"\n"+
                    "date published: "+e.getPublishedDate()+"\n"+
                    "author: "+e.getAuthor()+"\n"+                    
                    "link: "+e.getLink()+"\n"+
                    "uri: "+e.getUri());      
            System.out.println("- categories: ");
            List cat = e.getCategories();
            for (Object oc : cat) {
                SyndCategory c = (SyndCategory)oc;
                System.out.println("name: "+c.getName()+"\n"+
                        "taxonomy uri: "+c.getTaxonomyUri());
            }            
            
            SyndContent content = e.getDescription();
            System.out.println("content: "+content.getValue());       
            System.out.println("--- entry end ---");
//          List contents = e.getContents();            
//            System.out.println("- contents: ");
//            for (Object oc : contents) {
//                SyndContent c = (SyndContent)oc;
//                System.out.println("type: "+c.getType());
//                System.out.println("value:");
//                System.out.println(c.getValue());
//            }
        }
    }
 
开发者ID:dkorenci,项目名称:feedsucker,代码行数:43,代码来源:BasicTests.java

示例8: parse

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void parse() throws Exception {
	SyndFeedInput input = new SyndFeedInput();
	byte b[] = downloadAndSendBinary(url);
	if (b != null) {
		SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(b)));
		name = feed.getTitle();
		if (feed.getCategories() != null && feed.getCategories().size() > 0) {
			SyndCategory category = (SyndCategory) feed.getCategories().get(0);
			tempCategory = category.getName();
		}
		List<SyndEntry> entries = feed.getEntries();
		for (SyndEntry entry : entries) {
			tempItemTitle = entry.getTitle();
			tempItemLink = entry.getLink();
			tempFeedLink = entry.getUri();
			tempItemThumbURL = null;

			ArrayList<Element> elements = (ArrayList<Element>) entry.getForeignMarkup();
			for (Element elt : elements) {
				if ("group".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())) {
					List<Content> subElts = elt.getContent();
					for (Content subelt : subElts) {
						if (subelt instanceof Element) {
							parseElement((Element) subelt, false);
						}
					}
				}
				parseElement(elt, true);
			}
			List<SyndEnclosure> enclosures = entry.getEnclosures();
			for (SyndEnclosure enc : enclosures) {
				if (StringUtils.isNotBlank(enc.getUrl())) {
					tempItemLink = enc.getUrl();
				}
			}
			manageItem();
		}
	}
	setLastModified(System.currentTimeMillis());
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:42,代码来源:Feed.java

示例9: createRssEntry

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
/**
 * Creates the feeds entry.
 *
 * @param item
 *            The note.
 * @param locale
 *            The locale.
 * @param dateFormatter
 *            The date formatter.
 * @return The entry as {@link SyndEntry}.
 */
private SyndEntry createRssEntry(final NoteData item, Locale locale, DateFormat dateFormatter) {
    SyndEntry entry = new SyndEntryImpl();
    String noHtmlTitle = StringEscapeHelper.getSingleLineTextFromXML(item.getContent());
    int endIndex = Math.min(noHtmlTitle.length(), 100);
    String title = item.getBlog().getTitle() + ": " + noHtmlTitle.substring(0, endIndex);
    if (title.length() < noHtmlTitle.length()) {
        title += "...";
    }
    if (item.isDirect()) {
        title = messages.getText("rss.item.direct.message.prefix", locale) + " " + title;
    }
    entry.setTitle(title);
    entry.setLink(ServiceLocator.instance().getService(PermalinkGenerationManagement.class)
            .getNoteLink(item.getBlog().getAlias(), item.getId(), true));
    entry.setPublishedDate(item.getCreationDate());
    entry.setUpdatedDate(item.getLastModificationDate());
    String author = UserNameHelper.getCompleteSignature(item.getUser(), " ", item.getUser()
            .getAlias());
    entry.setAuthor(author);

    ArrayList<SyndCategory> categories = new ArrayList<SyndCategory>();
    for (TagData tag : item.getTags()) {
        SyndCategoryImpl category = new SyndCategoryImpl();
        category.setName(tag.getName());
        category.setTaxonomyUri(ServiceLocator.instance()
                .getService(PermalinkGenerationManagement.class)
                .getTagLink(tag.getName(), true));
        categories.add(category);
    }
    entry.setCategories(categories);
    SyndContent description = new SyndContentImpl();
    description.setType("text/html");
    StringBuilder content = new StringBuilder();
    content.append(messages.getText("newsfeed.microblog.content.metadata.author", locale));
    content.append(author);
    content.append(messages.getText(
            "newsfeed.microblog.content.metadata.author.date.separator", locale));
    content.append(dateFormatter.format(item.getCreationDate()));
    content.append(messages.getText(
            "newsfeed.microblog.content.metadata.date.content.separator", locale));
    content.append(item.getContent());

    if (CollectionUtils.isNotEmpty(item.getAttachments())) {
        content.append(messages.getText("rss.item.attachment.list", locale) + " ");
        for (AttachmentData attachment : item.getAttachments()) {
            content.append("<a href=\"");
            content.append(AttachmentHelper.determineAbsoluteAttachmentUrl(attachment, true));
            content.append("\">");
            content.append(attachment.getFileName());
            content.append("</a> ");
        }
    }
    description.setValue(content.toString());
    entry.setDescription(description);
    return entry;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:68,代码来源:RssNoteWriter.java

示例10: matchCategory

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean matchCategory(@Nonnull SyndEntry entry) {
	return ((List<SyndCategory>)entry.getCategories()).stream()
			.filter(e -> e != null && isNotBlank(e.getName()))
			.anyMatch(e -> match(e.getName()));
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:7,代码来源:FeedContentFilterImpl.java

示例11: feedUpdate

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
/**
 * Updates feed information such as accessed time and other attributes
 * pertaining feed/channel.
 * 
 * @param feedDB
 * @param feed
 */
@SuppressWarnings("unchecked")
private void feedUpdate(DBObject feedDB, SyndFeed feed) {
	// this field is for RSS Delegate worker to check for stalled threads or
	// threads that crashed and were not able to update used filed back to 0
	feedDB.put("accessedAt", new Date());

	/******** REQUIRED channel elements as defined in RSS 2.0 Specification ********/
	// http://cyber.law.harvard.edu/rss/rss.html#
	// even though this elements are required by specification we
	// cannot trust the source
	if (feed.getTitle() != null)
		feedDB.put("title", feed.getTitle());
	if (feed.getLink() != null)
		feedDB.put("link", feed.getLink());
	if (feed.getDescription() != null)
		feedDB.put("description", feed.getDescription());

	/******** OPTIONAL channel elements as defined in RSS 2.0 Specification ********/
	if (feed.getLanguage() != null)
		feedDB.put("language", feed.getLanguage());
	if (feed.getCopyright() != null)
		feedDB.put("copyright", feed.getCopyright());
	// no specific get method for managing editor and web master in rome
	// library. Using authors instead
	if (feed.getAuthors() != null && feed.getAuthors().size() > 0) {
		ArrayList<BasicDBObject> authors = getAuthors((ArrayList<SyndPerson>) feed
				.getAuthors());
		feedDB.put("authors", authors);
	}
	if (feed.getPublishedDate() != null)
		feedDB.put("pubDate", feed.getPublishedDate());
	// last build date does not exist in rome library
	if (feed.getCategories() != null && feed.getCategories().size() > 0) {
		ArrayList<BasicDBObject> categories = getCategories((ArrayList<SyndCategory>) feed
				.getCategories());
		feedDB.put("category", categories);
	}
	// generator does not exist in rome library
	// docs does not exist in rome library
	// cloud does not exist in rome library
	// ttl does not exist in rome library
	SyndImage feedImage = feed.getImage();
	if (feedImage != null) {
		BasicDBObject imageDB = new BasicDBObject();
		if (feedImage.getUrl() != null)
			imageDB.append("url", feedImage.getUrl());
		if (feedImage.getTitle() != null)
			imageDB.append("title", feedImage.getTitle());
		if (feedImage.getLink() != null)
			imageDB.append("link", feedImage.getLink());
		if (feedImage.getDescription() != null)
			imageDB.append("description", feedImage.getDescription());
		if (feedImage.getUrl() != null || feedImage.getTitle() != null
				|| feedImage.getLink() != null
				|| feedImage.getDescription() != null)
			feedDB.put("image", imageDB);
		// width does not exist in rome library
		// height does not exist in rome library
	}
	// rating does not exist in rome library
	// text input does not exist in rome library
	// skip hours does not exist in rome library
	// skip days does not exist in rome library

	rssColl.update(new BasicDBObject("feedUrl", feedDB.get("feedUrl")),
			feedDB);
}
 
开发者ID:jeryini,项目名称:distributed-rss,代码行数:75,代码来源:RSSThreadWorker.java

示例12: readFeed

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
/**
 * Reads a Gitblit RSS feed.
 * 
 * @param url
 *            the url of the Gitblit server
 * @param parameters
 *            the list of RSS parameters
 * @param repository
 *            the repository name
 * @param username
 * @param password
 * @return a list of SyndicationModel entries
 * @throws {@link IOException}
 */
private static List<FeedEntryModel> readFeed(String url, List<String> parameters,
		String repository, String branch, String username, char[] password) throws IOException {
	// build url
	StringBuilder sb = new StringBuilder();
	sb.append(MessageFormat.format("{0}" + Constants.SYNDICATION_PATH + "{1}", url, repository));
	if (parameters.size() > 0) {
		boolean first = true;
		for (String parameter : parameters) {
			if (first) {
				sb.append('?');
				first = false;
			} else {
				sb.append('&');
			}
			sb.append(parameter);
		}
	}
	String feedUrl = sb.toString();
	URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);
	InputStream is = conn.getInputStream();
	SyndFeedInput input = new SyndFeedInput();
	SyndFeed feed = null;
	try {
		feed = input.build(new XmlReader(is));
	} catch (FeedException f) {
		throw new GitBlitException(f);
	}
	is.close();
	List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
	for (Object o : feed.getEntries()) {
		SyndEntryImpl entry = (SyndEntryImpl) o;
		FeedEntryModel model = new FeedEntryModel();
		model.repository = repository;
		model.branch = branch;
		model.title = entry.getTitle();
		model.author = entry.getAuthor();
		model.published = entry.getPublishedDate();
		model.link = entry.getLink();
		model.content = entry.getDescription().getValue();
		model.contentType = entry.getDescription().getType();
		if (entry.getCategories() != null && entry.getCategories().size() > 0) {
			List<String> tags = new ArrayList<String>();
			for (Object p : entry.getCategories()) {
				SyndCategory cat = (SyndCategory) p;
				tags.add(cat.getName());
			}
			model.tags = tags;
		}
		entries.add(model);
	}
	return entries;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:67,代码来源:SyndicationUtils.java

示例13: loop

import com.sun.syndication.feed.synd.SyndCategory; //导入依赖的package包/类
@Override
@SuppressWarnings( "unchecked" )
protected void loop()
    throws Exception
{
    final URL url = new URL( getProperties().getConfigString( "url" ) );

    final int max = getProperties().getConfigInteger( "max" );

    if ( LOGGER.isTraceEnabled() )
    {
        LOGGER.trace( "[" + getNodeID() + "] read feed : " + url + " with max " + max + " elements" );
    }

    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build( new XmlReader( url ) );

    int count = 0;
    final List<SyndEntry> entries = feed.getEntries();
    for ( final SyndEntry entry : entries )
    {
        if ( entry.getUri() != null )
        {
            // Tags
            final Tags tags = new Tags();

            final List<SyndCategory> categories = entry.getCategories();
            if ( categories != null )
            {
                for ( final SyndCategory category : categories )
                {
                    tags.add( category.getName() );
                }
            }

            setMessage( Message.create(
                Message.KeyIndex.URI ,
                new URI( entry.getUri() ) ,
                Message.KeyIndex.TAGS ,
                tags
            ) );

            // Title
            if ( entry.getTitle() != null )
            {
                getMessage().setProperty( Message.KeyIndex.TITLE ,
                                          HTMLhelper.cleanHTML( entry.getTitle() ) );
            }

            // Description
            if ( entry.getDescription() != null )
            {
                getMessage().setProperty( Message.KeyIndex.DESCRIPTION ,
                                          HTMLhelper.cleanHTML( entry.getDescription().getValue() ) );
            }

            // Author
            if ( entry.getAuthor() != null )
            {
                getMessage().setProperty( Message.KeyIndex.AUTHOR ,
                                          entry.getAuthor() );
            }

            // Published date
            if ( entry.getPublishedDate() != null )
            {
                getMessage().setProperty( Message.KeyIndex.PUBLISHED_DATE ,
                                          new DateTime( entry.getPublishedDate() ) );
            }

            sendMessage();
        }

        ++count;

        if ( count >= max )
        {
            break;
        }
    }
}
 
开发者ID:fabienvauchelles,项目名称:superpipes,代码行数:82,代码来源:N_RSS.java


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