com.johnmunsch.rss
Class Channel

java.lang.Object
  |
  +--com.johnmunsch.rss.Channel
All Implemented Interfaces:
java.io.Serializable

public class Channel
extends java.lang.Object
implements java.io.Serializable

Channel is the fundamental element of RSS library. You must have a channel before you can do anything because you must have an address from which the RSS data will be retrieved. Once you have a channel and that channel is associated with a URI you can retrieve the channel and get its current set of items.

Author:
johnm
See Also:
Serialized Form

Constructor Summary
Channel()
          Creates a bare channel object.
Channel(java.lang.String _uri)
          Creates a new Channel object and fills in a URI for it to use.
Channel(java.lang.String _uri, java.lang.String _title, java.net.URL _link, java.lang.String _description, java.lang.String _language, java.net.URL _imageURL, java.net.URL _imageLink, java.lang.String _imageDescription)
          This constructor is mainly useful for those times when we already have complete information on the channel at the time we create it.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Two channels are treated as being equal if they both are retrieved from the same URI.
 java.lang.String getDescription()
          A description of the RSS channel.
 java.lang.String getImageDescription()
          Gets any description for the image.
 javax.swing.ImageIcon getImageIcon()
          If a channel has an associated image (an optional element) then we can get it in ImageIcon form ready for drawing from this function.
 java.net.URL getImageLink()
          Gets the address that the image should link to for the channel.
 java.net.URL getImageURL()
          Gets the URL of the image (if any) for this RSS channel.
 java.lang.String getLanguage()
          Returns a string describing the language of the RSS channel.
 java.util.Date getLastRetrieved()
          Returns the last date when this channel was _successfully_ parsed.
 java.net.URL getLink()
          Returns the main link for an RSS channel (this is usually the address of the main page for the website that generated the channel).
 java.lang.String getTitle()
          Gets the title of an RSS channel (this is usually the name of the website which generated the channel).
 java.lang.String getURI()
          The URI is what makes a channel a channel.
 java.util.List retrieve(boolean updateChannel)
          Retrieves the current set of items for an RSS channel.
 java.lang.String setDescription(java.lang.String _description)
          Allows setting the description of the RSS channel.
 java.lang.String setImageDescription(java.lang.String _imageDescription)
          Allows setting the image description for the RSS channel.
 java.net.URL setImageLink(java.net.URL _imageLink)
          Allows setting the address that the image should line to for the RSS channel.
 java.net.URL setImageURL(java.net.URL _imageURL)
          Allows setting the image URL for the RSS channel.
 java.lang.String setLanguage(java.lang.String _language)
          Allows setting the language of the RSS channel.
 java.net.URL setLink(java.net.URL _link)
          Allows setting the link for an RSS channel.
 java.lang.String setTitle(java.lang.String _title)
          Allows setting the title of an RSS channel.
 java.lang.String setURI(java.lang.String _uri)
          This allows us to update the URI of a given channel.
 java.lang.String toString()
          Genereates a nicely formatted string version of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Channel

public Channel()
Creates a bare channel object.


Channel

public Channel(java.lang.String _uri)
Creates a new Channel object and fills in a URI for it to use.

Parameters:
_uri - The address from which this RSS channel may be pulled.

Channel

public Channel(java.lang.String _uri,
               java.lang.String _title,
               java.net.URL _link,
               java.lang.String _description,
               java.lang.String _language,
               java.net.URL _imageURL,
               java.net.URL _imageLink,
               java.lang.String _imageDescription)
This constructor is mainly useful for those times when we already have complete information on the channel at the time we create it. For example, if we are creating channels from a list of all available channels (say an OCS list from syndic8.com) then we already know what the name of the channel is when we create it.

Parameters:
_uri - The address from which this RSS channel may be pulled.
_title - The title of this RSS channel.
_link - A link to the homepage for the channel.
_description - A description of the channel.
_language - The channel's language.
_imageURL - The URL for an image (if any) that may be used to represent the channel.
_imageLink - What the image links to (may be different from the channel link above.
_imageDescription - A description associated with the image.
Method Detail

getURI

public java.lang.String getURI()
The URI is what makes a channel a channel. It refers to the location of an RSS channel. All the rest of the data about a channel can actually be parsed from the RSS XML data after it is retrieved.


setURI

public java.lang.String setURI(java.lang.String _uri)
This allows us to update the URI of a given channel.


getLastRetrieved

public java.util.Date getLastRetrieved()
Returns the last date when this channel was _successfully_ parsed. That is, attempts to call parse that don't work because the channel is unavailable or returns unparsable data do not reset this value to a new date. Only a successful attempt to parse will change this date.

Returns:
Returns the date this channel was last successfully parsed or null if it has never been parsed successfully.

getImageIcon

public javax.swing.ImageIcon getImageIcon()
If a channel has an associated image (an optional element) then we can get it in ImageIcon form ready for drawing from this function. If the channel does not have an associated image or if the channel has never been retrieved then this function will return null.


equals

public boolean equals(java.lang.Object obj)
Two channels are treated as being equal if they both are retrieved from the same URI. So even if the name of one channel has been changed or they have retrieved different images, if the URIs are the same, they are considered to be the same.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Genereates a nicely formatted string version of this object. Very handy for debugging or sanity checking your work.

Overrides:
toString in class java.lang.Object

retrieve

public java.util.List retrieve(boolean updateChannel)
Retrieves the current set of items for an RSS channel. This list may include items which were retrieved before. It is up to the caller to eliminate duplicates if necessary (or to use the duplicate elimination facilities of the item store).


getTitle

public java.lang.String getTitle()
Gets the title of an RSS channel (this is usually the name of the website which generated the channel). May return a blank string if the channel has never been retrieved.


setTitle

public java.lang.String setTitle(java.lang.String _title)
Allows setting the title of an RSS channel.


getLink

public java.net.URL getLink()
Returns the main link for an RSS channel (this is usually the address of the main page for the website that generated the channel). May return null if this the channel has never been retrieved.


setLink

public java.net.URL setLink(java.net.URL _link)
Allows setting the link for an RSS channel.


getDescription

public java.lang.String getDescription()
A description of the RSS channel. This may be an empty string if the channel has never been retrieved.


setDescription

public java.lang.String setDescription(java.lang.String _description)
Allows setting the description of the RSS channel.


getLanguage

public java.lang.String getLanguage()
Returns a string describing the language of the RSS channel. This is not currently filled in by the parser and will always return an empty string.


setLanguage

public java.lang.String setLanguage(java.lang.String _language)
Allows setting the language of the RSS channel.


getImageURL

public java.net.URL getImageURL()
Gets the URL of the image (if any) for this RSS channel. The image is optional for an RSS channel so this may return null. It may also return null if the channel has never been retrieved. Note: If you are planning to draw the image then getImageIcon may be a more useful function to call.


setImageURL

public java.net.URL setImageURL(java.net.URL _imageURL)
Allows setting the image URL for the RSS channel.


getImageLink

public java.net.URL getImageLink()
Gets the address that the image should link to for the channel. RSS allows a separate link for the channel and the image for a channel. Note that this may return null if the channel has never been retrieved.


setImageLink

public java.net.URL setImageLink(java.net.URL _imageLink)
Allows setting the address that the image should line to for the RSS channel.


getImageDescription

public java.lang.String getImageDescription()
Gets any description for the image. RSS allows a description and link for the image vs. the channel. This may return an empty string if the channel has never been retrieved.


setImageDescription

public java.lang.String setImageDescription(java.lang.String _imageDescription)
Allows setting the image description for the RSS channel.