com.myjavatools.xml
Class Rss

java.lang.Object
  extended bycom.myjavatools.xml.BasicXmlData
      extended bycom.myjavatools.xml.Rss
All Implemented Interfaces:
XmlData

public class Rss
extends BasicXmlData

Title: MyJavaTools: Rss Class

Description: Defines a container for RSS, Real Simple Syndication data format.

Copyright: This is public domain; The right of people to use, distribute, copy or improve the contents of the following may not be restricted.

See Also:
Introduction to RSS, Another introduction, RSS 1.0 Spec, RSS 2.0 Spec

The following RSS formats are suppored for reading: 0.91, 0.92, 1.0, 2.0. Output is always 2.0. The version of original document can be retrieved using getOriginalVersion().


Nested Class Summary
static class Rss.Image
          Image, Rss member class
static class Rss.Item
          Item, Rss member class
static class Rss.TextInput
          TextInput, Rss member class
 
Nested classes inherited from class com.myjavatools.xml.BasicXmlData
BasicXmlData.Expression, BasicXmlData.Policy
 
Nested classes inherited from class com.myjavatools.xml.XmlData
XmlData.Condition
 
Field Summary
static java.lang.String LATEST_VERSION
          Current RSS version "2.0"
 
Fields inherited from class com.myjavatools.xml.BasicXmlData
XmlDataClass
 
Constructor Summary
Rss()
          creates empty Rss instance
Rss(java.io.File file)
          reads Rss contents from a file
Rss(java.io.InputStream is)
          reads Rss from input stream
Rss(java.net.URL url)
          reads Rss from a URL
Rss(XmlData source)
          creates an instance of Rss based on data from XmlData
 
Method Summary
 void addItem(Rss.Item item)
          adds an item to RSS
 void addItem(java.lang.String title, java.lang.String link, java.lang.String description)
          adds a new item to RSS
 Rss.Item findItemByDescription(java.lang.String description)
          finds RSS item by its description
 Rss.Item findItemByGuid(java.lang.String guid)
          finds an item by its guid
 Rss.Item findItemByUrl(java.lang.String url)
          finds item by its url
 java.lang.String getCategory()
          gets category
 XmlData getCloud()
          gets RSS cloud
 java.lang.String getCopyright()
          gets copyright
 java.lang.String getDescription()
          gets RSS description
 java.lang.String getDocs()
          gets docs value
 java.lang.String getGenerator()
          gets RSS generator
 Rss.Image getImage()
          gets RSS image
 Rss.Item getItem(java.lang.String title)
          gets RSS item by title
 int getItemCount()
          Returns number of items in RSS
 java.util.Collection getItems()
          gets a collection of all items in RSS
 java.lang.String getLanguage()
          gets RSS language
 java.lang.String getLastBuildDate()
          gets last build date
 java.lang.String getLink()
          gets RSS link
 java.lang.String getManagingEditor()
          gets managing editor
 java.lang.String getOriginalVersion()
          gets original version
Original version is the RSS version of source data
 java.lang.String getPubDate()
          gets publication date
 java.lang.String getRating()
          gets RSS rating
 java.lang.String getSkipDays()
          gets skip days
 java.lang.String getSkipHours()
          gets skip hours
 Rss.TextInput getTextInput()
          gets RSS textinput
 java.lang.String getTitle()
          gets RSS title
 java.lang.String getTtl()
          gets RSS TTL (Time-To-Live, number of days RSS is valid)
 java.lang.String getVersion()
          gets RSS version (which is 2.0)
 java.lang.String getWebMaster()
          gets webmaster
 void setCategory(java.lang.String category)
          sets RSS category
 void setCloud(XmlData cloud)
          sets RSS cloud
 void setCopyright(java.lang.String copyright)
          sets copyright string
 void setDescription(java.lang.String description)
          sets RSS description
 void setDocs(java.lang.String docs)
          sets docs value
 void setGenerator(java.lang.String generator)
          sets RSS generator
 void setImage(Rss.Image image)
           
 void setImage(java.lang.String title, java.lang.String description, java.lang.String url, java.lang.String link, java.lang.String width, java.lang.String height)
          sets RSS Image element
 void setLanguage(java.lang.String language)
          sets RSS langauge
 void setLastBuildDate(java.lang.String lastBuildDate)
          sets last build date
 void setLink(java.lang.String link)
          sets RSS link
 void setManagingEditor(java.lang.String managingEditor)
          sets managing editor
 void setPubDate(java.lang.String pubDate)
          sets publication date
 void setRating(java.lang.String rating)
          sets RSS rating
 void setSkipDays(java.lang.String skipDays)
          sets skip days
 void setSkipHours(java.lang.String skipHours)
          sets skip hours
 void setTextInput(Rss.TextInput textInput)
          sets RSS textinput element
 void setTextInput(java.lang.String title, java.lang.String description, java.lang.String name, java.lang.String link)
          sets RSS textinput element
 void setTitle(java.lang.String title)
          sets RSS title
 void setTtl(java.lang.String ttl)
          sets RSS TTL (Time-To-Live, number of days RSS is valid)
 void setWebMaster(java.lang.String webMaster)
           
 
Methods inherited from class com.myjavatools.xml.BasicXmlData
addKid, addKids, addKids, cast, cast, castKids, castToPackage, castToPackage, cleanAttributes, clone, debug, deepCopy, equals, getAllKids, getAttribute, getAttribute, getAttributes, getId, getKid, getKid, getKid, getKid, getKidAttribute, getKidCount, getKids, getKidTypes, getKidValue, getName, getType, getValue, getXmlContent, indexOf, insertKid, insertKid, removeKid, removeKids, replaceKid, satisfies, satisfies, save, save, save, selectTree, selectTree, setAttribute, setAttributes, setAttributes, setAttributes, setKidValue, setType, setValue, setXmlContent, trim
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LATEST_VERSION

public static final java.lang.String LATEST_VERSION
Current RSS version "2.0"

See Also:
Constant Field Values
Constructor Detail

Rss

public Rss()
    throws java.lang.InstantiationException
creates empty Rss instance

Throws:
java.lang.InstantiationException - it should not

Rss

public Rss(java.io.File file)
    throws java.io.FileNotFoundException,
           java.io.IOException,
           java.lang.InstantiationException
reads Rss contents from a file

Parameters:
file - File data source
Throws:
java.io.FileNotFoundException - if file not found
java.io.IOException - if could not read
java.lang.InstantiationException - if could not parse the contents

Rss

public Rss(java.io.InputStream is)
    throws java.io.IOException,
           java.lang.InstantiationException
reads Rss from input stream

Parameters:
is - InputStream data source
Throws:
java.io.IOException - if could not read
java.lang.InstantiationException - if could not parse the data

Rss

public Rss(XmlData source)
    throws java.lang.InstantiationException
creates an instance of Rss based on data from XmlData

Parameters:
source - XmlData data source
Throws:
java.lang.InstantiationException - if could not extract data

Rss

public Rss(java.net.URL url)
    throws java.lang.InstantiationException,
           java.io.IOException
reads Rss from a URL

Parameters:
url - URL data source
Throws:
java.io.IOException - if could not read data
java.lang.InstantiationException - if could not parse data
Method Detail

getOriginalVersion

public java.lang.String getOriginalVersion()
gets original version
Original version is the RSS version of source data

Returns:
String original version

getVersion

public java.lang.String getVersion()
gets RSS version (which is 2.0)

Returns:
String current RSS version

getTitle

public java.lang.String getTitle()
gets RSS title

Returns:
String title

setTitle

public void setTitle(java.lang.String title)
sets RSS title

Parameters:
title - String

getDescription

public java.lang.String getDescription()
gets RSS description

Returns:
String description

setDescription

public void setDescription(java.lang.String description)
sets RSS description

Parameters:
description - String

getLink

public java.lang.String getLink()
gets RSS link

Returns:
String link

setLink

public void setLink(java.lang.String link)
sets RSS link

Parameters:
link - String

getLanguage

public java.lang.String getLanguage()
gets RSS language

Returns:
String RSS language

setLanguage

public void setLanguage(java.lang.String language)
sets RSS langauge

Parameters:
language - String

getRating

public java.lang.String getRating()
gets RSS rating

Returns:
String rating

setRating

public void setRating(java.lang.String rating)
sets RSS rating

Parameters:
rating - String

getCopyright

public java.lang.String getCopyright()
gets copyright

Returns:
String copyright

setCopyright

public void setCopyright(java.lang.String copyright)
sets copyright string

Parameters:
copyright - String

getPubDate

public java.lang.String getPubDate()
gets publication date

Returns:
String publication date

setPubDate

public void setPubDate(java.lang.String pubDate)
sets publication date

Parameters:
pubDate - String

getLastBuildDate

public java.lang.String getLastBuildDate()
gets last build date

Returns:
String last build date

setLastBuildDate

public void setLastBuildDate(java.lang.String lastBuildDate)
sets last build date

Parameters:
lastBuildDate - String

getManagingEditor

public java.lang.String getManagingEditor()
gets managing editor

Returns:
String managing editor

setManagingEditor

public void setManagingEditor(java.lang.String managingEditor)
sets managing editor

Parameters:
managingEditor - String

getWebMaster

public java.lang.String getWebMaster()
gets webmaster

Returns:
String webmaster

setWebMaster

public void setWebMaster(java.lang.String webMaster)

getSkipHours

public java.lang.String getSkipHours()
gets skip hours

Returns:
String skip hours

setSkipHours

public void setSkipHours(java.lang.String skipHours)
sets skip hours

Parameters:
skipHours - String

getSkipDays

public java.lang.String getSkipDays()
gets skip days

Returns:
String skip days

setSkipDays

public void setSkipDays(java.lang.String skipDays)
sets skip days

Parameters:
skipDays - String

getDocs

public java.lang.String getDocs()
gets docs value

Returns:
String RSS docs

setDocs

public void setDocs(java.lang.String docs)
sets docs value

Parameters:
docs - String

setImage

public void setImage(Rss.Image image)

setImage

public void setImage(java.lang.String title,
                     java.lang.String description,
                     java.lang.String url,
                     java.lang.String link,
                     java.lang.String width,
                     java.lang.String height)
sets RSS Image element

Parameters:
title - String image title
description - String image description
url - String image url
link - String image link
width - String image width
height - String image height

getImage

public Rss.Image getImage()
gets RSS image

Returns:
Image RSS image element

setTextInput

public void setTextInput(Rss.TextInput textInput)
sets RSS textinput element

Parameters:
textInput - TextInput

setTextInput

public void setTextInput(java.lang.String title,
                         java.lang.String description,
                         java.lang.String name,
                         java.lang.String link)
sets RSS textinput element

Parameters:
title - String textinput title
description - String textinput description
name - String textinput name
link - String textinput link

getTextInput

public Rss.TextInput getTextInput()
gets RSS textinput

Returns:
TextInput

addItem

public void addItem(Rss.Item item)
adds an item to RSS

Parameters:
item - Item

addItem

public void addItem(java.lang.String title,
                    java.lang.String link,
                    java.lang.String description)
adds a new item to RSS

Parameters:
title - String item title
link - String item link
description - String item description

getItems

public java.util.Collection getItems()
gets a collection of all items in RSS

Returns:
Collection all RSS items

getItemCount

public int getItemCount()
Returns number of items in RSS

Returns:
int the number of items, 0 if none

getItem

public Rss.Item getItem(java.lang.String title)
gets RSS item by title

Parameters:
title - String item title to look for
Returns:
Item with specified title, or null if not found This should have better been named findItem, but Java tradition suggests using 'get'

setGenerator

public void setGenerator(java.lang.String generator)
sets RSS generator

Parameters:
generator - String

getGenerator

public java.lang.String getGenerator()
gets RSS generator

Returns:
String generator

setCategory

public void setCategory(java.lang.String category)
sets RSS category

Parameters:
category - String

getCategory

public java.lang.String getCategory()
gets category

Returns:
String category

setTtl

public void setTtl(java.lang.String ttl)
sets RSS TTL (Time-To-Live, number of days RSS is valid)

Parameters:
ttl - String

getTtl

public java.lang.String getTtl()
gets RSS TTL (Time-To-Live, number of days RSS is valid)

Returns:
String RSS TTL

getCloud

public XmlData getCloud()
gets RSS cloud

Returns:
XmlData cloud (see 2.0 standard for description)

setCloud

public void setCloud(XmlData cloud)
sets RSS cloud

Parameters:
cloud - XmlData

findItemByDescription

public Rss.Item findItemByDescription(java.lang.String description)
finds RSS item by its description

Parameters:
description - String
Returns:
Item the first (random) item that has this description, or null

findItemByGuid

public Rss.Item findItemByGuid(java.lang.String guid)
finds an item by its guid

Parameters:
guid - String
Returns:
Item any item that has this guid, or null if none found

findItemByUrl

public Rss.Item findItemByUrl(java.lang.String url)
finds item by its url

Parameters:
url - String
Returns:
Item an item that has specified url (or null if none)