Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/***********************************************************************************************************************
*
* blueBill Core - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it
* SCM: https://kenai.com/hg/bluebill~core-src
*
**********************************************************************************************************************/
package it.tidalwave.semantic.rss;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.InputStream;
import org.jaxen.XPath;
import it.tidalwave.util.Id;
import it.tidalwave.xml.XPathProvider;
import it.tidalwave.xml.XmlParser;
import it.tidalwave.xml.dom4j.Dom4jXmlParser;
import it.tidalwave.xml.jaxen.JaxenXPathProvider;
import it.tidalwave.semantic.document.Document;
import static it.tidalwave.semantic.rss.RssVocabulary.*;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public class RssFeedReader
{
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public RssFeed readMessages (final @Nonnull InputStream is)
throws Exception
{
final XmlParser xmlParser = new Dom4jXmlParser();
final Object document = xmlParser.parse(is);
final XPathProvider xPathProvider = new JaxenXPathProvider();
final XPath channelExpr = xPathProvider.createXPath(document, "/rss/channel");
final XPath titleExpr = xPathProvider.createXPath(document, "title");
final XPath linkExpr = xPathProvider.createXPath(document, "link");
final XPath descriptionExpr = xPathProvider.createXPath(document, "description");
final XPath languageExpr = xPathProvider.createXPath(document, "language");
final XPath copyrightExpr = xPathProvider.createXPath(document, "copyright");
final XPath lastBuildDate = xPathProvider.createXPath(document, "lastBuildDate");
final XPath generatorExpr = xPathProvider.createXPath(document, "generator");
final XPath itemExpr = xPathProvider.createXPath(document, "item");
final XPath pubDateExpr = xPathProvider.createXPath(document, "pubDate");
final XPath dcCreatorExpr = xPathProvider.createXPath(document, "dc:creator");
dcCreatorExpr.addNamespace("dc", "http://purl.org/dc/elements/1.1/");
final XPath guidExpr = xPathProvider.createXPath(document, "guid");
final XPath contentExpr = xPathProvider.createXPath(document, "content:encoded");
contentExpr.addNamespace("content", "http://purl.org/rss/1.0/modules/content/");
final Object channel = channelExpr.selectSingleNode(document);
final List