protected List readDocumentsFromFeed(SyndFeed feed, DocumentFactory docFactory) {
List entries = feed.getEntries();
List docs = new ArrayList(entries.size());
for (Iterator itr = entries.iterator(); itr.hasNext(); ) {
SyndEntry entry = (SyndEntry)itr.next();
Document doc = docFactory.createDocument();
doc.addField("title", entry.getTitle(), StoreOption.YES,
IndexOption.TOKENIZED);
SyndContent descContent = entry.getDescription();
String contentType = descContent.getType();
String description = null;
if (contentType != null && contentType.indexOf("text/html") != -1) {
// HTML description; removes the tags
description = descContent.getValue().replaceAll("<[^>]+>", "");
} else {
description = descContent.getValue();
}
doc.addField("description", description, StoreOption.YES,
IndexOption.TOKENIZED);
String author = entry.getAuthor();
if (author == null)
author = "";
doc.addField("author", author, StoreOption.YES,
IndexOption.TOKENIZED);
doc.addField("url", entry.getLink(), StoreOption.YES,
IndexOption.NO);
doc.addField("publishedDate", DateTools.dateToString(entry
.getPublishedDate(), DateTools.Resolution.MINUTE),
StoreOption.YES, IndexOption.UN_TOKENIZED);
docs.add(doc);
}
return docs;