org.clapper.curn.parser
Class RSSChannel

java.lang.Object
  extended by org.clapper.curn.parser.RSSElement
      extended by org.clapper.curn.parser.RSSChannel
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
RSSChannelAdapter, RSSChannelAdapter

public abstract class RSSChannel
extends RSSElement
implements java.lang.Cloneable

This abstract class defines a simplified view of an RSS channel, providing only the methods necessary for curn to work. curn uses the RSSParserFactory class to get a specific implementation of RSSParser, which returns an object that is a subclass of this class. This strategy isolates the bulk of the code from the underlying RSS parser, making it easier to substitute different parsers as more of them become available.

Version:
$Revision: 6509 $
See Also:
RSSParserFactory, RSSParser, RSSItem

Constructor Summary
protected RSSChannel()
          Default constructor.
 
Method Summary
abstract  void addAuthor(java.lang.String author)
          Add to the channel's author list.
abstract  void clearAuthors()
          Clear the authors list.
 java.lang.Object clone()
          Clone this channel.
abstract  java.util.Collection<java.lang.String> getAuthors()
          Get the channel's author list.
abstract  java.lang.String getCopyright()
          Get the channel's copyright string
abstract  java.lang.String getDescription()
          Get the channel's description
abstract  java.util.Collection<RSSItem> getItems()
          Get a Collection of the items in this channel.
abstract  java.util.Collection<RSSLink> getLinks()
          Get the channel's list of published links (its URLs).
 java.lang.Object getNativeRSSFormat()
          Get the RSS format the channel is using, in native format.
abstract  java.util.Date getPublicationDate()
          Get the channel's publication date.
abstract  java.lang.String getRSSFormat()
          Get the RSS format the channel is using, as a string
abstract  java.lang.String getTitle()
          Get the channel's title
 RSSChannel makeCopy()
          Make a deep copy of this RSSChannel object.
abstract  RSSChannel newInstance()
          Create a new, empty instance of the underlying concrete class.
abstract  boolean removeItem(RSSItem item)
          Remove an item from the set of items.
abstract  void setCopyright(java.lang.String copyright)
          Set the channel's copyright string
abstract  void setDescription(java.lang.String desc)
          Set the channel's description
abstract  void setItems(java.util.Collection<? extends RSSItem> newItems)
          Change the items the channel the ones in the specified collection.
abstract  void setLinks(java.util.Collection<RSSLink> links)
          Set the channel's list of published links (its URLs).
abstract  void setNativeRSSFormat(java.lang.Object format)
          Set the RSS format the channel is using.
abstract  void setPublicationDate(java.util.Date date)
          Set the channel's publication date.
abstract  void setTitle(java.lang.String newTitle)
          Set the channel's title
 void stripHTML()
          Strip all HTML and weird plain text from the channel and its items.
 java.lang.String toString()
          Return a string representation of this channel.
 
Methods inherited from class org.clapper.curn.parser.RSSElement
getAuthor, getLink, getLink, getLink, getLinkWithFallback, getURL, setAuthor, setAuthors
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RSSChannel

protected RSSChannel()
Default constructor.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this channel. This method simply calls the type-safe makeCopy() method. The clone is a deep-clone (i.e., the items are cloned, too).

Overrides:
clone in class java.lang.Object
Returns:
the cloned RSSChannel
Throws:
java.lang.CloneNotSupportedException - doesn't, actually, but the Cloneable interface requires that this exception be declared
See Also:
makeCopy()

makeCopy

public RSSChannel makeCopy()
Make a deep copy of this RSSChannel object.

Returns:
the copy

stripHTML

public void stripHTML()
Strip all HTML and weird plain text from the channel and its items. Intended primarily for output handlers and plug-ins that produce plain text. This method edits the channel data directly; it does not produce a copy.


toString

public java.lang.String toString()
Return a string representation of this channel.

Overrides:
toString in class java.lang.Object
Returns:
the string

newInstance

public abstract RSSChannel newInstance()
Create a new, empty instance of the underlying concrete class.

Returns:
the new instance

getItems

public abstract java.util.Collection<RSSItem> getItems()
Get a Collection of the items in this channel. All objects in the collection are of type RSSItem.

Returns:
a (new) Collection of RSSItem objects. The collection will be empty (never null) if there are no items. This Collection is expected to be a copy of whatever the channel is really storing. (That is, if the underlying implementation is using a Collection to store its RSSItem objects, it should not return that Collection directly; instead, it should return a copy.) The order of items in the returned collection is arbitrary and not guaranteed to be sorted, unless sorted by a plug-in.

setItems

public abstract void setItems(java.util.Collection<? extends RSSItem> newItems)
Change the items the channel the ones in the specified collection. If the collection is empty, the items are cleared. The items are copied from the supplied collection. (A reference to the supplied collection is not saved in this object.)

Parameters:
newItems - new collection of RSSItem items.

removeItem

public abstract boolean removeItem(RSSItem item)
Remove an item from the set of items.

Parameters:
item - the item to remove
Returns:
true if removed, false if not found

getTitle

public abstract java.lang.String getTitle()
Get the channel's title

Returns:
the channel's title, or null if there isn't one
See Also:
setTitle(String)

setTitle

public abstract void setTitle(java.lang.String newTitle)
Set the channel's title

Parameters:
newTitle - the channel's title, or null if there isn't one
See Also:
getTitle()

getDescription

public abstract java.lang.String getDescription()
Get the channel's description

Returns:
the channel's description, or null if there isn't one
See Also:
setDescription(java.lang.String)

setDescription

public abstract void setDescription(java.lang.String desc)
Set the channel's description

Parameters:
desc - the channel's description, or null if there isn't one
See Also:
getDescription()

getLinks

public abstract java.util.Collection<RSSLink> getLinks()
Get the channel's list of published links (its URLs). Each element in the returned Collection is an RSSLink object.

Specified by:
getLinks in class RSSElement
Returns:
the collection of links, or an empty list if there are none. The result will never be null.
See Also:
RSSElement.getLink(java.lang.String, org.clapper.curn.parser.RSSLink.Type...), setLinks(java.util.Collection)

setLinks

public abstract void setLinks(java.util.Collection<RSSLink> links)
Set the channel's list of published links (its URLs).

Parameters:
links - the links
See Also:
RSSElement.getLink(java.lang.String, org.clapper.curn.parser.RSSLink.Type...), getLinks()

getPublicationDate

public abstract java.util.Date getPublicationDate()
Get the channel's publication date.

Returns:
the date, or null if not available
See Also:
setPublicationDate(java.util.Date)

setPublicationDate

public abstract void setPublicationDate(java.util.Date date)
Set the channel's publication date.

Parameters:
date - the publication date, or null if not available
See Also:
getPublicationDate()

getCopyright

public abstract java.lang.String getCopyright()
Get the channel's copyright string

Returns:
the copyright string, or null if not available
See Also:
setCopyright(java.lang.String)

setCopyright

public abstract void setCopyright(java.lang.String copyright)
Set the channel's copyright string

Parameters:
copyright - the copyright string, or null if not available
See Also:
getCopyright()

getRSSFormat

public abstract java.lang.String getRSSFormat()
Get the RSS format the channel is using, as a string

Returns:
the format, or null if not available
See Also:
getNativeRSSFormat(), setNativeRSSFormat(java.lang.Object)

getNativeRSSFormat

public java.lang.Object getNativeRSSFormat()
Get the RSS format the channel is using, in native format. This method exists for underlying implementations that store the RSS format as something other than a string; the method allows the makeCopy() method to copy the RSS format without knowing how it's stored. The default implementation of this method simply calls getRSSFormat().

Returns:
the format, or null if not available
See Also:
getRSSFormat(), setNativeRSSFormat(java.lang.Object)

setNativeRSSFormat

public abstract void setNativeRSSFormat(java.lang.Object format)
Set the RSS format the channel is using.

Parameters:
format - the format, or null if not available
See Also:
getRSSFormat(), getNativeRSSFormat()

getAuthors

public abstract java.util.Collection<java.lang.String> getAuthors()
Get the channel's author list.

Specified by:
getAuthors in class RSSElement
Returns:
the authors, or null (or an empty Collection) if not available
See Also:
addAuthor(java.lang.String), clearAuthors(), RSSElement.setAuthor(java.lang.String)

addAuthor

public abstract void addAuthor(java.lang.String author)
Add to the channel's author list.

Specified by:
addAuthor in class RSSElement
Parameters:
author - another author string to add
See Also:
getAuthors(), clearAuthors(), RSSElement.setAuthor(java.lang.String)

clearAuthors

public abstract void clearAuthors()
Clear the authors list.

Specified by:
clearAuthors in class RSSElement
See Also:
getAuthors(), addAuthor(java.lang.String), RSSElement.setAuthor(java.lang.String)


Copyright © 2004-2006 Brian M. Clapper. All Rights Reserved.