net.sourceforge.rssowl.dao.feedparser
Class AbstractFeedParser

java.lang.Object
  extended bynet.sourceforge.rssowl.dao.feedparser.AbstractFeedParser
Direct Known Subclasses:
Atom_0_3_Parser, BaseRSSParser, FeedParser, OPML_1_0_Parser, RDF_1_0_Parser

public abstract class AbstractFeedParser
extends Object

Abstract class of all parser classes in RSSOwl. Provides some methods to access values of the XML document. Is also responsible to parse Namespaces if available.

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
protected  org.jdom.Namespace content
          Namespace: Content
protected  org.jdom.Namespace dc
          Namespace: Dublin Core
protected  org.jdom.Namespace defNs
          Namespace: Default
protected  org.jdom.Document document
          Current document
protected  org.jdom.Namespace rdf
          Namespace: RDF
protected  org.jdom.Element root
          Root Element
protected  Channel rssChannel
          Channel to fill with data
protected  org.jdom.Namespace sy
          Namespace: Syndication
protected  String url
          URL of the Newsfeed
 
Constructor Summary
protected AbstractFeedParser(org.jdom.Document document, Channel rssChannel, String url)
          Instantiate a new Parser for this format.
protected AbstractFeedParser(org.jdom.Document document, Channel rssChannel, String url, org.jdom.Namespace[] nameSpaces)
          Instantiate a new Parser for this format.
 
Method Summary
protected  String getAttributeValue(org.jdom.Element element, String attribute)
          Get an attribute value from the document
protected  String getAttributeValue(org.jdom.Element element, String attribute, org.jdom.Namespace ns)
          Get an attribute value from the document
protected  org.jdom.Element getChildElement(org.jdom.Element parent, String name)
          Get the Child Element of a parent Element
protected  org.jdom.Element getChildElement(org.jdom.Element parent, String name, org.jdom.Namespace ns)
          Get the Child Element of a parent Element
protected  List getChildren(org.jdom.Element parent, String name)
          Get a list of children from the given element.
protected  List getChildren(org.jdom.Element parent, String name, org.jdom.Namespace ns)
          Get a list of children from the given element.
protected  String getChildValue(String element, org.jdom.Element parent)
          Get a value from the document
protected  String getChildValue(String element, org.jdom.Element parent, org.jdom.Namespace ns)
          Get a value from the document
protected abstract  void parse()
          Parse elements that are defined in the specifications and add them to the Channel.
private  void parseAvailableNamespaces()
          Parse document for namespaces
protected  void parseContentModule(org.jdom.Element item, NewsItem newsItem)
          Parse the content module namespace
protected  void parseDCModule(org.jdom.Element item, NewsItem newsItem)
          Parse for the dublin core module namespace
private  void parseRoot()
          Parse the Root Element from the XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

content

protected org.jdom.Namespace content
Namespace: Content


dc

protected org.jdom.Namespace dc
Namespace: Dublin Core


defNs

protected org.jdom.Namespace defNs
Namespace: Default


document

protected org.jdom.Document document
Current document


rdf

protected org.jdom.Namespace rdf
Namespace: RDF


root

protected org.jdom.Element root
Root Element


rssChannel

protected Channel rssChannel
Channel to fill with data


sy

protected org.jdom.Namespace sy
Namespace: Syndication


url

protected String url
URL of the Newsfeed

Constructor Detail

AbstractFeedParser

protected AbstractFeedParser(org.jdom.Document document,
                             Channel rssChannel,
                             String url)
                      throws NewsfeedFactoryException
Instantiate a new Parser for this format. Parse for Namespaces.

Parameters:
document - The document containing the data to parse
rssChannel - The Channel to fill with data from the document
url - The URL of the Newsfeed that is parsed
Throws:
NewsfeedFactoryException - If any error occurs

AbstractFeedParser

protected AbstractFeedParser(org.jdom.Document document,
                             Channel rssChannel,
                             String url,
                             org.jdom.Namespace[] nameSpaces)
                      throws NewsfeedFactoryException
Instantiate a new Parser for this format.

Parameters:
document - The document containing the data to parse
rssChannel - The Channel to fill with data from the document
url - The URL of the Newsfeed that is parsed
nameSpaces - Possible Namespaces of the XML document
Throws:
NewsfeedFactoryException - If any error occurs
Method Detail

parseAvailableNamespaces

private void parseAvailableNamespaces()
Parse document for namespaces


parseRoot

private void parseRoot()
                throws NewsfeedFactoryException
Parse the Root Element from the XML document.

Throws:
NewsfeedFactoryException - If the root element is not set.

getAttributeValue

protected String getAttributeValue(org.jdom.Element element,
                                   String attribute)
Get an attribute value from the document

Parameters:
element - The element's name
attribute - The attributes name
Returns:
String the value or null

getAttributeValue

protected String getAttributeValue(org.jdom.Element element,
                                   String attribute,
                                   org.jdom.Namespace ns)
Get an attribute value from the document

Parameters:
element - The element's name
attribute - The attributes name
ns - The namespace for the attribute
Returns:
String the value or null

getChildElement

protected org.jdom.Element getChildElement(org.jdom.Element parent,
                                           String name)
Get the Child Element of a parent Element

Parameters:
parent - The parent of the child
name - The name of the child
Returns:
Element The child element if existing

getChildElement

protected org.jdom.Element getChildElement(org.jdom.Element parent,
                                           String name,
                                           org.jdom.Namespace ns)
Get the Child Element of a parent Element

Parameters:
parent - The parent of the child
name - The name of the child
ns - The namespace for the child
Returns:
Element The child element if existing

getChildren

protected List getChildren(org.jdom.Element parent,
                           String name)
Get a list of children from the given element.

Parameters:
parent - The parent element
name - The name of the children
Returns:
List A list of child elements

getChildren

protected List getChildren(org.jdom.Element parent,
                           String name,
                           org.jdom.Namespace ns)
Get a list of children from the given element.

Parameters:
parent - The parent element
name - The name of the children
ns - The namespace
Returns:
List A list of child elements

getChildValue

protected String getChildValue(String element,
                               org.jdom.Element parent)
Get a value from the document

Parameters:
element - The element's name
parent - The parent element
Returns:
String the value or null

getChildValue

protected String getChildValue(String element,
                               org.jdom.Element parent,
                               org.jdom.Namespace ns)
Get a value from the document

Parameters:
element - The element's name
parent - The parent element
ns - The Namespace to use
Returns:
String the value or null

parse

protected abstract void parse()
                       throws NewsfeedFactoryException
Parse elements that are defined in the specifications and add them to the Channel.

Throws:
NewsfeedFactoryException - If any error occurs

parseContentModule

protected void parseContentModule(org.jdom.Element item,
                                  NewsItem newsItem)
Parse the content module namespace

Parameters:
item - Current working item
newsItem - Current working newsItem

parseDCModule

protected void parseDCModule(org.jdom.Element item,
                             NewsItem newsItem)
Parse for the dublin core module namespace

Parameters:
item - Current working item
newsItem - Current working newsitem


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo