de.nava.informa.impl.basic
Class Channel

java.lang.Object
  extended by de.nava.informa.impl.basic.Channel
All Implemented Interfaces:
ChannelIF, ChannelObservableIF, WithCategoriesMIF, WithCreatorMIF, WithDescriptionMIF, WithElementsAndAttributesMIF, WithIdMIF, WithLocationMIF, WithSiteMIF, WithTitleMIF, Serializable
Direct Known Subclasses:
Channel

public class Channel
extends Object
implements ChannelIF

In-Memory implementation of the ChannelIF interface.

Author:
Niko Schmuck (niko@nava.de)
See Also:
Serialized Form

Constructor Summary
Channel()
           
Channel(org.jdom.Element channelElement)
           
Channel(org.jdom.Element channelElement, String title)
           
Channel(String title)
           
 
Method Summary
 void addCategory(CategoryIF category)
           
 void addItem(ItemIF item)
           
 void addObserver(ChannelObserverIF o)
          Adds an observer to the set of observers for this object.
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 String getAttributeValue(String path, String attribute)
          Returns the value of the attribute of the Channel's child element reached by the given path.
 String[] getAttributeValues(String path, String[] attributes)
          Returns the values of the specified attributes of the Channel's child element reached by the given path.
 Collection getCategories()
          Gets the assigned category objects for this channel.
 CloudIF getCloud()
           
 String getCopyright()
           
 String getCreator()
           
 String getDescription()
           
 String getDocs()
           
 String getElementValue(String path)
          Returns the value of the Channel's child element reached by the given path.
 String[] getElementValues(String path, String[] elements)
          Returns the values of the specified sub-elements of the Channel's child reached by the given path.
 ChannelFormat getFormat()
          Gets the syntax format used by the channel.
 String getGenerator()
           
 long getId()
           
 ImageIF getImage()
          Retrieves the Image associated with this feed.
 ItemIF getItem(long anId)
          Returns the news item as specified by the item identifier (WithIdMIF.getId()).
 Set<ItemIF> getItems()
           
 String getLanguage()
           
 Date getLastBuildDate()
           
 Date getLastUpdated()
          Returns that date and time at which the feed was parsed and the channel object was updated (or created) from feed XML content
 URL getLocation()
           
 Date getPubDate()
           
 String getPublisher()
           
 String getRating()
           
 URL getSite()
           
 TextInputIF getTextInput()
           
 String getTitle()
           
 int getTtl()
           
 Date getUpdateBase()
          Accesses data provided by the Syndication module (will apply only to RSS 1.0+).
 int getUpdateFrequency()
          Accesses data provided by the Syndication module (will apply only to RSS 1.0+).
 ChannelUpdatePeriod getUpdatePeriod()
          Accesses data provided by the Syndication module (will apply only to RSS 1.0+).
 int hashCode()
          Returns a hash code value for the object.
 void removeCategory(CategoryIF category)
           
 void removeItem(ItemIF item)
           
 void removeObserver(ChannelObserverIF o)
          Removes an observer from the set of observers of this object.
 void setAllProperties(ChannelIF sourceChan)
          setAllProperties - Set all the properties in this Channel by copying them from a source Channel.
 void setCategories(Collection<CategoryIF> categories)
           
 void setCloud(CloudIF cloud)
           
 void setCopyright(String copyright)
           
 void setCreator(String creator)
           
 void setDescription(String description)
           
 void setDocs(String docs)
           
 void setFormat(ChannelFormat format)
           
 void setGenerator(String generator)
           
 void setId(long id)
           
 void setImage(ImageIF image)
          Sets the image for this feed
 void setLanguage(String language)
           
 void setLastBuildDate(Date date)
           
 void setLastUpdated(Date lastUpdated)
          see ChannelIF.getLastUpdated()
 void setLocation(URL location)
           
 void setPubDate(Date pubDate)
           
 void setPublisher(String publisher)
           
 void setRating(String rating)
           
 void setSite(URL site)
           
 void setTextInput(TextInputIF textInput)
           
 void setTitle(String title)
           
 void setTtl(int ttl)
           
 void setUpdateBase(Date updateBase)
          Sets the base time against which update times should be calculated
 void setUpdateFrequency(int updateFrequency)
          Sets the number of times during updatePeriod that the feed should be updated
 void setUpdatePeriod(ChannelUpdatePeriod updatePeriod)
          Sets the update frequency for the feed.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Channel

public Channel()

Channel

public Channel(String title)

Channel

public Channel(org.jdom.Element channelElement)

Channel

public Channel(org.jdom.Element channelElement,
               String title)
Method Detail

getId

public long getId()
Specified by:
getId in interface WithIdMIF
Returns:
identifier of the object.

setId

public void setId(long id)
Specified by:
setId in interface WithIdMIF
Parameters:
id - the identifier of the object to be set.

getTitle

public String getTitle()
Specified by:
getTitle in interface WithTitleMIF
Returns:
the title of the object

setTitle

public void setTitle(String title)
Specified by:
setTitle in interface WithTitleMIF
Parameters:
title - the title of the object to be set

getDescription

public String getDescription()
Specified by:
getDescription in interface WithDescriptionMIF
Returns:
description of the object

setDescription

public void setDescription(String description)
Specified by:
setDescription in interface WithDescriptionMIF
Parameters:
description - the description of the object to be set

getLocation

public URL getLocation()
Specified by:
getLocation in interface WithLocationMIF
Returns:
The URL where this channel can be retrieved from.

setLocation

public void setLocation(URL location)
Specified by:
setLocation in interface WithLocationMIF
Parameters:
location - The URL where this channel can be retrieved from.

getSite

public URL getSite()
Specified by:
getSite in interface WithSiteMIF
Returns:
the link to the site where more informaion may be obtained

setSite

public void setSite(URL site)
Specified by:
setSite in interface WithSiteMIF
Parameters:
site - the link to the site to be set

getCreator

public String getCreator()
Specified by:
getCreator in interface WithCreatorMIF
Returns:
Creator of the object. Returns null if nothing appropriate found. For RSS 0.91 and 2.0 feeds: return text under managingEditor element For RSS 1.0 feed: first checks if creator element exists as dublin core metadata, and then falls back to managingEditor element For RSS 2.0 entries: checks the author element for each entry or fallback to creator metadata element from dublin core For Atom 0.3 and 1.0 feeds: checks author element. For Atom 1.0, multiple authors are possible, in which case we return a list of authors delimited by semicolon. Note that the author name itself may contain a semicolon, in which case seperation of author names by splitting at every semicolon will not work.

setCreator

public void setCreator(String creator)
Specified by:
setCreator in interface WithCreatorMIF
Parameters:
creator - the creator of the object to be set

getPublisher

public String getPublisher()
Specified by:
getPublisher in interface ChannelIF

setPublisher

public void setPublisher(String publisher)
Specified by:
setPublisher in interface ChannelIF

getLanguage

public String getLanguage()
Specified by:
getLanguage in interface ChannelIF

setLanguage

public void setLanguage(String language)
Specified by:
setLanguage in interface ChannelIF

getRating

public String getRating()
Specified by:
getRating in interface ChannelIF

setRating

public void setRating(String rating)
Specified by:
setRating in interface ChannelIF

getCloud

public CloudIF getCloud()
Specified by:
getCloud in interface ChannelIF

setCloud

public void setCloud(CloudIF cloud)
Specified by:
setCloud in interface ChannelIF

getGenerator

public String getGenerator()
Specified by:
getGenerator in interface ChannelIF

setGenerator

public void setGenerator(String generator)
Specified by:
setGenerator in interface ChannelIF

getDocs

public String getDocs()
Specified by:
getDocs in interface ChannelIF

setDocs

public void setDocs(String docs)
Specified by:
setDocs in interface ChannelIF

getTtl

public int getTtl()
Specified by:
getTtl in interface ChannelIF

setTtl

public void setTtl(int ttl)
Specified by:
setTtl in interface ChannelIF

getFormat

public ChannelFormat getFormat()
Description copied from interface: ChannelIF
Gets the syntax format used by the channel.

Specified by:
getFormat in interface ChannelIF
Returns:
The format of the channel as specified by the constants in ChannelFormat.

setFormat

public void setFormat(ChannelFormat format)
Specified by:
setFormat in interface ChannelIF

getItems

public Set<ItemIF> getItems()
Specified by:
getItems in interface ChannelIF
Returns:
An set of ItemIF objects.

addItem

public void addItem(ItemIF item)
Specified by:
addItem in interface ChannelIF

removeItem

public void removeItem(ItemIF item)
Specified by:
removeItem in interface ChannelIF

getItem

public ItemIF getItem(long anId)
Description copied from interface: ChannelIF
Returns the news item as specified by the item identifier (WithIdMIF.getId()).

Specified by:
getItem in interface ChannelIF
Parameters:
anId - the Item's id.
Returns:
the Item

getImage

public ImageIF getImage()
Description copied from interface: ChannelIF
Retrieves the Image associated with this feed. Optional

Specified by:
getImage in interface ChannelIF
Returns:
An ImageIF representing the image associated with this feed

setImage

public void setImage(ImageIF image)
Description copied from interface: ChannelIF
Sets the image for this feed

Specified by:
setImage in interface ChannelIF
Parameters:
image - The image

getTextInput

public TextInputIF getTextInput()
Specified by:
getTextInput in interface ChannelIF

setTextInput

public void setTextInput(TextInputIF textInput)
Specified by:
setTextInput in interface ChannelIF

getCopyright

public String getCopyright()
Specified by:
getCopyright in interface WithSiteMIF
Returns:
copyright information, if it's presented on the site

setCopyright

public void setCopyright(String copyright)
Specified by:
setCopyright in interface WithSiteMIF
Parameters:
copyright - the copyright information to be set

getCategories

public Collection getCategories()
Description copied from interface: WithCategoriesMIF
Gets the assigned category objects for this channel.

Specified by:
getCategories in interface WithCategoriesMIF
Returns:
A collection of CategoryIF objects, in the case of no assigned categories an empty collection is returned..

setCategories

public void setCategories(Collection<CategoryIF> categories)
Specified by:
setCategories in interface WithCategoriesMIF

addCategory

public void addCategory(CategoryIF category)
Specified by:
addCategory in interface WithCategoriesMIF

removeCategory

public void removeCategory(CategoryIF category)
Specified by:
removeCategory in interface WithCategoriesMIF

getLastUpdated

public Date getLastUpdated()
Description copied from interface: ChannelIF
Returns that date and time at which the feed was parsed and the channel object was updated (or created) from feed XML content

Specified by:
getLastUpdated in interface ChannelIF

setLastUpdated

public void setLastUpdated(Date lastUpdated)
Description copied from interface: ChannelIF
see ChannelIF.getLastUpdated()

Specified by:
setLastUpdated in interface ChannelIF

getLastBuildDate

public Date getLastBuildDate()
Specified by:
getLastBuildDate in interface ChannelIF

setLastBuildDate

public void setLastBuildDate(Date date)
Specified by:
setLastBuildDate in interface ChannelIF

getPubDate

public Date getPubDate()
Specified by:
getPubDate in interface ChannelIF

setPubDate

public void setPubDate(Date pubDate)
Specified by:
setPubDate in interface ChannelIF

setAllProperties

public void setAllProperties(ChannelIF sourceChan)
setAllProperties - Set all the properties in this Channel by copying them from a source Channel. N.B. This includes all properties, but not children such as items etc. N.B. Location and Format are also not copied.

Parameters:
sourceChan - - ChannelIF that will supply new values

getUpdatePeriod

public ChannelUpdatePeriod getUpdatePeriod()
Description copied from interface: ChannelIF
Accesses data provided by the Syndication module (will apply only to RSS 1.0+). The return type will be one of:

Specified by:
getUpdatePeriod in interface ChannelIF
Returns:
see above

setUpdatePeriod

public void setUpdatePeriod(ChannelUpdatePeriod updatePeriod)
Description copied from interface: ChannelIF
Sets the update frequency for the feed. This information will be stored according to the Syndication Module tags. updateFrequency should be one of:

Specified by:
setUpdatePeriod in interface ChannelIF
Parameters:
updatePeriod - See above

getUpdateFrequency

public int getUpdateFrequency()
Description copied from interface: ChannelIF
Accesses data provided by the Syndication module (will apply only to RSS 1.0+). Returns the number of times during the updatePeriod that a feed should be updated

Specified by:
getUpdateFrequency in interface ChannelIF
Returns:
The number of times during updatePeriod to update the feed
See Also:
ChannelIF.setUpdatePeriod(de.nava.informa.core.ChannelUpdatePeriod), ChannelIF.getUpdatePeriod()

setUpdateFrequency

public void setUpdateFrequency(int updateFrequency)
Description copied from interface: ChannelIF
Sets the number of times during updatePeriod that the feed should be updated

Specified by:
setUpdateFrequency in interface ChannelIF
Parameters:
updateFrequency - number of times during updatePeriod to update the feed

getUpdateBase

public Date getUpdateBase()
Description copied from interface: ChannelIF
Accesses data provided by the Syndication module (will apply only to RSS 1.0+). Provides the base date against which to determine the next time to update the feed.

Specified by:
getUpdateBase in interface ChannelIF
Returns:
The date from which the next update times should be calculated

setUpdateBase

public void setUpdateBase(Date updateBase)
Description copied from interface: ChannelIF
Sets the base time against which update times should be calculated

Specified by:
setUpdateBase in interface ChannelIF
Parameters:
updateBase - The base date for updates

getElementValue

public String getElementValue(String path)
Description copied from interface: WithElementsAndAttributesMIF
Returns the value of the Channel's child element reached by the given path.
For example, getElementValue("image/title") will return the title of the Channel's image element.

Specified by:
getElementValue in interface WithElementsAndAttributesMIF
Parameters:
path - a path to the child. Paths are specified as element names, separated by a "/". Namespaces are allowed. e.g. "aaa:bbb/ccc:ddd/eee".
Returns:
the value of the child. Returns null if path is null.

getElementValues

public String[] getElementValues(String path,
                                 String[] elements)
Description copied from interface: WithElementsAndAttributesMIF
Returns the values of the specified sub-elements of the Channel's child reached by the given path. This is useful in cases where a child has several children.
For example, getElementValues("image", new String[] {"title", "url", "link", "width", "height", "description"} ) will return the specified sub-elements of the "image" element.

Specified by:
getElementValues in interface WithElementsAndAttributesMIF
Parameters:
path - a path to the child. Paths are specified as element names, separated by a "/". Namespaces are allowed. e.g. "aaa:bbb/ccc:ddd/eee".
elements - An array of element names. May contain namespace specifiers.
Returns:
an array containing the value of each element.
If path is null, returns the specified sub-elements for the Channel. If elements is null, returns null.

getAttributeValue

public String getAttributeValue(String path,
                                String attribute)
Description copied from interface: WithElementsAndAttributesMIF
Returns the value of the attribute of the Channel's child element reached by the given path.
For example, getAttributeValue("admin:generatorAgent", "rdf:resource") will return the "rdf:resource" attribute of the Channel's "admin:generatorAgent" element.

Specified by:
getAttributeValue in interface WithElementsAndAttributesMIF
Parameters:
path - a path to the root of the elements. Paths are specified as element names, separated by a "/".
attribute - the attribute. May contain a namespace specifier e.g. "rdf:resource".
Returns:
the value of the attribute.
If path is null, returns the specified attribute for the Channel. If attribute is null, returns null.

getAttributeValues

public String[] getAttributeValues(String path,
                                   String[] attributes)
Description copied from interface: WithElementsAndAttributesMIF
Returns the values of the specified attributes of the Channel's child element reached by the given path. This is useful in cases where a child has several attributes.

Specified by:
getAttributeValues in interface WithElementsAndAttributesMIF
Parameters:
path - a path to the child. Paths are specified as element names, separated by a "/". Namespaces are allowed. e.g. "aaa:bbb/ccc:ddd/eee".
attributes - An array of element names. May contain namespace specifiers.
Returns:
an array containing the value of each attribute.
If path is null, returns the specified attributes for the Channel. If attributes is null, returns null.

addObserver

public void addObserver(ChannelObserverIF o)
Description copied from interface: ChannelObservableIF
Adds an observer to the set of observers for this object.

Specified by:
addObserver in interface ChannelObservableIF

removeObserver

public void removeObserver(ChannelObserverIF o)
Description copied from interface: ChannelObservableIF
Removes an observer from the set of observers of this object.

Specified by:
removeObserver in interface ChannelObservableIF

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode()

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
Returns:
a string representation of the object.


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.