本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEntry.getPublishedDate方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.getPublishedDate方法的具体用法?Java SyndEntry.getPublishedDate怎么用?Java SyndEntry.getPublishedDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.feed.synd.SyndEntry
的用法示例。
在下文中一共展示了SyndEntry.getPublishedDate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SyndEntryAdapter
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public SyndEntryAdapter(SyndFeed feed, SyndEntry entry) {
if (entry.getTitleEx() != null) {
this.title = entry.getTitle();
this.titleType = entry.getTitleEx().getType();
}
if (entry.getDescription() != null) {
this.description = entry.getDescription().getValue();
this.descriptionType = entry.getDescription().getType();
}
this.uri = entry.getUri();
this.author = entry.getAuthor();
this.link = entry.getLink();
if (entry.getPublishedDate() != null)
this.publishedDate = ISO_8601_DATE_FORMAT.format(entry.getPublishedDate());
if (entry.getUpdatedDate() != null)
this.updatedDate = ISO_8601_DATE_FORMAT.format(entry.getUpdatedDate());
this.fetchDate = ISO_8601_DATE_FORMAT.format(new Date());
this.sourceLink = feed.getLink();
this.sourceUri = feed.getUri();
this.sourceTitle = feed.getTitle();
this.language = feed.getLanguage();
this.sourceType = feed.getFeedType();
}
示例2: RSSPost
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public RSSPost(SyndEntry rssEntry) {
if(rssEntry == null || rssEntry.getLink() == null)
return;
//Id
id = rssEntry.getLink();
//Document's title
title = rssEntry.getTitle();
//Document's content - Extract text content from html structure
if(rssEntry.getDescription()!=null)
description = extractDocumentContent(rssEntry.getDescription().getValue());
//Document's time of publication
creationDate = rssEntry.getPublishedDate();
//The url where the document can be found
url = rssEntry.getLink();
}
示例3: getUpdatedDate
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
private Date getUpdatedDate(SyndEntry entry) {
Date date = entry.getUpdatedDate();
if (date == null) {
date = entry.getPublishedDate();
}
return date;
}
示例4: getPubDate
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public Date getPubDate(@Body Object body) {
SyndFeed feed = (SyndFeed) body;
SyndEntry syndEntry = (SyndEntry) feed.getEntries().get(0);
Date date = syndEntry.getUpdatedDate();
if (date == null) {
date = syndEntry.getPublishedDate();
}
return date;
}
示例5: apply
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
public FeedEntry apply(SyndEntry entry) {
if (entry.getDescription() == null) {
return null;
}
String title = entry.getTitle();
String link = entry.getLink();
String description = entry.getDescription().getValue();
Date publishedDate = entry.getPublishedDate();
return new FeedEntry(title, link, description, publishedDate);
}
示例6: shoudRemove
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
* Check the syndentry for creation or update date.
* If they are available (in some feeds they are not!) then perform
* a simple check - if the article was posted today, or updated today.
*
* @param anEntry The entry of feed entry
* @return boolean
*/
private boolean shoudRemove(SyndEntry anEntry) {
boolean shouldRemove = false;
if (Objects.nonNull(anEntry.getPublishedDate())) {
Date pubD = anEntry.getPublishedDate();
LocalDate publishLocalDate =
LocalDate.parse(new SimpleDateFormat("yyyy-MM-dd").format(pubD));
if (!LocalDate.now().equals(publishLocalDate)) {
shouldRemove = true;
}
}
return shouldRemove;
}
示例7: compare
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
public int compare(SyndEntry entry1, SyndEntry entry2) {
if (entry1 == null || entry1.getPublishedDate() == null) {
return 1;
}
if (entry2 == null) {
return -1;
}
return ((-1) * entry1.getPublishedDate().compareTo(entry2.getPublishedDate()));
}
示例8: read
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public void read() throws Exception {
FTPClient ftpClient = new FTPClient();
ftpClient.setBufferSize(1024 * 1024);
ftpClient.setDefaultTimeout(1000);
ftpClient.setControlEncoding("UTF-8");
ftpClient.setDataTimeout(10000);
ZipFile zipFile = new ZipFile();
Parser parser = new Parser();
URL feedUrl = new URL("https://download.kortforsyningen.dk/sites/default/files/feeds/MATRIKELKORT_GML.xml");
SyndFeedInput input = new SyndFeedInput();
System.out.println("Henter Atom feed....\n");
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println("Feed Titel: " + feed.getTitle());
Date lastPublishedDate;
Date currentDate;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fileName;
Integer elavsKode;
Track track = new Track();
String lastStr = track.getLastFromDb();
lastPublishedDate = sdf.parse(lastStr);
System.out.println("\nSidste entry: " + lastStr + "\n");
this.login(ftpClient);
for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) {
System.out.println("\n--------------\n");
currentDate = entry.getPublishedDate();
if (currentDate.before(lastPublishedDate) || currentDate.equals(lastPublishedDate)) {
break;
}
System.out.println("Published Date: " + entry.getPublishedDate() + "\n");
// Get the Links
for (SyndLinkImpl link : (List<SyndLinkImpl>) entry.getLinks()) {
System.out.println("Link: " + link.getHref());
fileName = link.getHref().split("/")[7];
elavsKode = Integer.valueOf(fileName.split("_")[0]);
track.storeInDb(currentDate.toString(), elavsKode);
// Get the file
this.c(ftpClient, fileName, zipFile);
// Get xml stream from zip-file
ZipInputStream zin = zipFile.getGml(fileName);
// Parse the xml and insert in database
parser.build(zin, elavsKode);
// Delete the file
File file = new File(fileName);
file.delete();
}
}
// logout the user, returned true if logout successfully
ftpClient.disconnect();
System.out.println("Alt hentet...");
System.out.println("FTP forbindelse afbrydes.");
}
示例9: setColumnValue
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
protected void setColumnValue(int tablecolumnindex, int returncolumnindex, AdapterRow row, Object o) throws AdapterException {
SyndEntry entry = (SyndEntry) o;
// col.setName("URI");
// col.setName("AUTHOR");
// col.setName("LINK");
// col.setName("PUBLISHEDDATE");
// col.setName("TITLE");
// col.setName("UPDATEDATE");
// col.setName("DESCRIPTION");
switch (tablecolumnindex) {
case 0:
row.setColumnValue(returncolumnindex, checkStringLength(entry.getUri(), 512));
break;
case 1:
row.setColumnValue(returncolumnindex, checkStringLength(entry.getAuthor(), 255));
break;
case 2:
row.setColumnValue(returncolumnindex, checkStringLength(entry.getLink(), 512));
break;
case 3:
if (entry.getPublishedDate() != null)
row.setColumnValue(returncolumnindex, new Timestamp(entry.getPublishedDate()));
else
row.setColumnNull(returncolumnindex);
break;
case 4:
row.setColumnValue(returncolumnindex, checkStringLength(entry.getTitle(), 255));
break;
case 5:
if (entry.getUpdatedDate() != null)
row.setColumnValue(returncolumnindex, new Timestamp(entry.getUpdatedDate()));
else
row.setColumnNull(returncolumnindex);
break;
case 6:
if (entry.getDescription() != null) {
row.setColumnValue(returncolumnindex, checkStringLength(entry.getDescription().getValue(), 5000));
} else
row.setColumnNull(returncolumnindex);
break;
}
}
示例10: createFeedEntry
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
protected FeedEntry createFeedEntry(long id, SyndEntry syndEntry, long currentTime) {
String descriptionType = null;
String descriptionValue = null;
if (syndEntry.getDescription() != null) {
if (syndEntry.getDescription().getType() != null) {
descriptionType = syndEntry.getDescription().getType();
}
if (syndEntry.getDescription().getValue() != null) {
descriptionValue = syndEntry.getDescription().getValue();
}
}
// If we don't have description (summary on atom feed entry), use the first content item
if (descriptionValue == null && syndEntry.getContents().size() > 0) {
SyndContent content = syndEntry.getContents().get(0);
descriptionType = content.getType();
descriptionValue = content.getValue();
}
// Fallback to safe values
if (descriptionValue == null || descriptionValue.length() == 0
|| descriptionType == null || descriptionType.length() == 0) {
descriptionValue = FeedEntry.DEFAULT_DESCRIPTION_VALUE;
descriptionType = FeedEntry.DEFAULT_DESCRIPTION_TYPE;
}
// Proper MIME types
if (descriptionType.equals(Content.HTML)) {
descriptionType = "text/html";
} else if (descriptionType.equals(Content.TEXT)) {
descriptionType = "text/plain";
} else if (descriptionType.equals(Content.XHTML)) {
descriptionType = "application/xhtml+xml";
}
return new FeedEntry(
null,
id,
syndEntry.getLink(),
syndEntry.getTitle() != null && syndEntry.getTitle().length() > 0 ? syndEntry.getTitle() : FeedEntry.DEFAULT_TITLE,
syndEntry.getAuthor() != null && syndEntry.getAuthor().length() > 0 ? syndEntry.getAuthor() : FeedEntry.DEFAULT_AUTHOR,
currentTime,
syndEntry.getPublishedDate() != null ? syndEntry.getPublishedDate().getTime() : FeedEntry.DEFAULT_DATE,
syndEntry.getUpdatedDate() != null ? syndEntry.getUpdatedDate().getTime() : FeedEntry.DEFAULT_DATE,
descriptionType,
descriptionValue,
false
);
}
示例11: create
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
private void create(SyndEntry entry, NewswireService source) throws DataExistsException {
List<NewswireItem> results = pluginContext.findNewswireItemsByExternalId(entry.getUri());
if (results.isEmpty()) {
NewswireItem item = new NewswireItem();
item.setExternalId(entry.getUri());
item.setTitle(StringUtils.stripHtml(entry.getTitle()));
if (entry.getDescription() != null) {
item.setSummary(StringUtils.stripHtml(entry.getDescription().getValue()));
}
item.setUrl(entry.getLink());
item.setNewswireService(source);
item.setAuthor(entry.getAuthor());
Calendar now = Calendar.getInstance();
item.setDate(now);
item.setUpdated(now);
if (entry.getPublishedDate() != null) {
item.getDate().setTime(entry.getPublishedDate());
item.getUpdated().setTime(entry.getPublishedDate());
}
if (entry.getUpdatedDate() != null) {
item.getUpdated().setTime(entry.getUpdatedDate());
}
if (useOpenCalais) {
enrich(pluginContext, item);
}
NewswireItem nwi = pluginContext.createNewswireItem(item);
try {
pluginContext.index(nwi);
} catch (SearchEngineIndexingException ex) {
pluginContext.log(LogSeverity.SEVERE, ex.getMessage(),
this.newswireService, this.newswireService.getId());
}
} else {
throw new DataExistsException("NewswireItem with external id [" + entry.getUri() + "] already downloaded");
}
}
示例12: getRssNewsLinkForNewFeed
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
private RssFeeds getRssNewsLinkForNewFeed(final String url, final RssFeeds rssFeed) throws RssFeedException {
final Set<RssNewsLinks> rssLinks = new HashSet<RssNewsLinks>();
try {
final URLConnection connection = new URL(url).openConnection();
connection.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
connection.connect();
final InputStream is = connection.getInputStream();
final InputSource source = new InputSource(is);
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(source);
@SuppressWarnings("rawtypes")
final Iterator iFeed = feed.getEntries().iterator();
while (iFeed.hasNext()) {
final RssNewsLinks link = new RssNewsLinks();
link.setFeedId(rssFeed.getId());
link.setRssFeed(rssFeed);
final SyndEntry entry = (SyndEntry) iFeed.next();
link.setTitle(entry.getTitle());
link.setLink(entry.getLink());
if(null != entry.getDescription()) {
link.setDescription(entry.getDescription().getValue().replaceAll("\\<.*?>", ""));
}
final Date publicationDate = entry.getPublishedDate();
final DateTime publishedDate = new DateTime(publicationDate);
link.setPubDate(publishedDate);
rssLinks.add(link);
}
rssFeed.setRssNewsLinks(rssLinks);
} catch (final Exception ex) {
throw new RssFeedException("The feed appears to be invalid");
}
return rssFeed;
}
示例13: loop
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的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;
}
}
}