de.nava.informa.impl.hibernate
Class Channel

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

public class Channel
extends Object
implements ChannelIF

Hibernate 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(org.jdom.Element channelElement, String title, String location)
           
Channel(String title)
           
Channel(String title, String location)
           
Channel(String title, URL location)
           
 
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)
          Compare two Channels for equality.
 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 getFormatString()
           
 String getGenerator()
           
 Set<ChannelGroup> getGroups()
           
 long getId()
           
 ImageIF getImage()
          Retrieves the Image associated with this feed.
 ItemIF getItem(long itemId)
          Returns the news item as specified by the item identifier (WithIdMIF.getId()).
 Set<ItemIF> getItems()
           
 String getLanguage()
           
 Date getLastBuildDate()
          RSS 0.91: The date-time the last time the content of the channel changed.
 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()
           
 String getLocationString()
           
 Date getPubDate()
           
 String getPublisher()
           
 String getRating()
           
 URL getSite()
           
 String getSiteString()
           
 TextInputIF getTextInput()
           
 String getTitle()
           
 int getTtl()
          RSS 2.0: ttl stands for time to live.
 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()
          Hashcode, like equals, is touchy and critical for proper functioning of Hibernate.
 void notifyObserversChannelUpdated()
          Loops through and notifies each observer if a new item was detected.
 void notifyObserversItemAdded(ItemIF newItem)
          Loops through and notifies each observer if a new item was detected.
 void removeCategory(CategoryIF category)
           
 void removeItem(ItemIF item)
           
 void removeObserver(ChannelObserverIF o)
          Removes an observer from the set of observers of this object.
 void setCategories(Collection<CategoryIF> aCategories)
           
 void setCloud(CloudIF aCloud)
           
 void setCopyright(String aCopyright)
           
 void setCreator(String aCreator)
           
 void setDescription(String aDescription)
           
 void setDocs(String aDocs)
           
 void setFormat(ChannelFormat aFormat)
           
 void setFormatString(String strFormat)
           
 void setGenerator(String aGenerator)
           
 void setGroups(Set<ChannelGroup> aGroups)
           
 void setId(long id)
           
 void setImage(ImageIF anImage)
          Sets the image for this feed
 void setItems(Set<ItemIF> anItems)
           
 void setLanguage(String aLanguage)
           
 void setLastBuildDate(Date date)
           
 void setLastUpdated(Date date)
          see ChannelIF.getLastUpdated()
 void setLocation(URL location)
           
 void setLocationString(String loc)
           
 void setPubDate(Date date)
           
 void setPublisher(String aPublisher)
           
 void setRating(String aRating)
           
 void setSite(URL site)
           
 void setSiteString(String siteUrl)
           
 void setTextInput(TextInputIF aTextInput)
           
 void setTitle(String aTitle)
           
 void setTtl(int aTtl)
           
 void setUpdateBase(Date date)
          Sets the base time against which update times should be calculated
 void setUpdateFrequency(int anUpdateFrequency)
          Sets the number of times during updatePeriod that the feed should be updated
 void setUpdatePeriod(ChannelUpdatePeriod anUpdatePeriod)
          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(String title,
               String location)

Channel

public Channel(String title,
               URL location)

Channel

public Channel(org.jdom.Element channelElement)

Channel

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

Channel

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

getId

public long getId()
Specified by:
getId in interface WithIdMIF
Returns:
integer representation of identity.

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:
title.

setTitle

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

getDescription

public String getDescription()
Specified by:
getDescription in interface WithDescriptionMIF
Returns:
description.

setDescription

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

getLocationString

public String getLocationString()
Returns:
location as a string.

setLocationString

public void setLocationString(String loc)

getLocation

public URL getLocation()
Specified by:
getLocation in interface WithLocationMIF
Returns:
the location

setLocation

public void setLocation(URL location)
Specified by:
setLocation in interface WithLocationMIF
Parameters:
location - the location to set

getSiteString

public String getSiteString()
Returns:
URL of the site.

setSiteString

public void setSiteString(String siteUrl)

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:
name of creator.

setCreator

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

getPublisher

public String getPublisher()
Specified by:
getPublisher in interface ChannelIF
Returns:
publisher.

setPublisher

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

getLanguage

public String getLanguage()
Specified by:
getLanguage in interface ChannelIF
Returns:
language of channel.

setLanguage

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

getFormatString

public String getFormatString()
Returns:
format string.

setFormatString

public void setFormatString(String strFormat)

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 aFormat)
Specified by:
setFormat in interface ChannelIF

getGroups

public Set<ChannelGroup> getGroups()
Returns:
set of groups.

setGroups

public void setGroups(Set<ChannelGroup> aGroups)

getItems

public Set<ItemIF> getItems()
Specified by:
getItems in interface ChannelIF
Returns:
items of channel.

setItems

public void setItems(Set<ItemIF> anItems)

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 itemId)
Description copied from interface: ChannelIF
Returns the news item as specified by the item identifier (WithIdMIF.getId()).

Specified by:
getItem in interface ChannelIF
Parameters:
itemId - 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:
image.

setImage

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

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

getTextInput

public TextInputIF getTextInput()
Specified by:
getTextInput in interface ChannelIF
Returns:
text input.

setTextInput

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

getCopyright

public String getCopyright()
Specified by:
getCopyright in interface WithSiteMIF
Returns:
copyright note.

setCopyright

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

getRating

public String getRating()
Specified by:
getRating in interface ChannelIF
Returns:
rating.

setRating

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

getCloud

public CloudIF getCloud()
Specified by:
getCloud in interface ChannelIF
Returns:
cloud.

setCloud

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

getGenerator

public String getGenerator()
Specified by:
getGenerator in interface ChannelIF
Returns:
generator.

setGenerator

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

getDocs

public String getDocs()
Specified by:
getDocs in interface ChannelIF
Returns:
docs.

setDocs

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

getTtl

public int getTtl()
RSS 2.0: ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source

Specified by:
getTtl in interface ChannelIF
Returns:
TTL value.

setTtl

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

getCategories

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

Specified by:
getCategories in interface WithCategoriesMIF
Returns:
categories.

setCategories

public void setCategories(Collection<CategoryIF> aCategories)
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
Returns:
date of last update.

setLastUpdated

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

Specified by:
setLastUpdated in interface ChannelIF

getLastBuildDate

public Date getLastBuildDate()
RSS 0.91: The date-time the last time the content of the channel changed. RSS 2.0: The last time the content of the channel changed.

Specified by:
getLastBuildDate in interface ChannelIF
Returns:
date of last builing.

setLastBuildDate

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

getPubDate

public Date getPubDate()
Specified by:
getPubDate in interface ChannelIF
Returns:
publication date.

setPubDate

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

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
See Also:
ChannelIF.getUpdatePeriod()

setUpdatePeriod

public void setUpdatePeriod(ChannelUpdatePeriod anUpdatePeriod)
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:
anUpdatePeriod - See above

getUpdateFrequency

public int getUpdateFrequency()
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 (the update frequency).
See Also:
ChannelIF.setUpdatePeriod(de.nava.informa.core.ChannelUpdatePeriod), ChannelIF.getUpdatePeriod()

setUpdateFrequency

public void setUpdateFrequency(int anUpdateFrequency)
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:
anUpdateFrequency - 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:
update base.

setUpdateBase

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

Specified by:
setUpdateBase in interface ChannelIF
Parameters:
date - 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

toString

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

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

equals

public boolean equals(Object o)
Compare two Channels for equality. Implementing this method and hashCode correctly is CRITICAL for Hibernate to function correctly. The semantic is that two Channels arensidered the 'same' RSS Channel. They may at one point in time have different values for different properties, but are they the SAME Channel? This is a very subtle Hibernate point, WHICH I AM 90% Sure I got right. In this case, two Channels are equal specifically if their RSS URL are the same. In other words, even if the title is different or the description is different, it's still the same Channel.

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.

hashCode

public int hashCode()
Hashcode, like equals, is touchy and critical for proper functioning of Hibernate.

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

notifyObserversItemAdded

public void notifyObserversItemAdded(ItemIF newItem)
Loops through and notifies each observer if a new item was detected.

Parameters:
newItem - item added.

notifyObserversChannelUpdated

public void notifyObserversChannelUpdated()
Loops through and notifies each observer if a new item was detected.



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