Package com.jalios.util
Class RssChannel
- java.lang.Object
-
- com.jalios.util.RssChannel
-
public class RssChannel extends java.lang.Object
This class implements a RSS Channel parser/container.
-
-
Constructor Summary
Constructors Constructor Description RssChannel(java.io.File file)
Create a new RssChannel.RssChannel(java.io.File file, java.util.Set<RssEventListener> eventListeners)
Create a new RssChannel.RssChannel(java.lang.String url, long ufreq)
Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, int timeout)
Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, int timeout, java.util.Set<RssEventListener> eventListeners)
Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, java.util.Set<RssEventListener> eventListeners)
Create a new RssChannel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListener(RssEventListener listener)
AddRssEventListener
void
addListeners(java.util.Set<RssEventListener> listeners)
AddRssEventListener
list to existing listenersstatic java.util.Date
convertDate(java.lang.String date)
static java.lang.String
generateID(java.lang.String id, int maxLength)
compute a id from parameter.java.util.Date
getBuildDate()
java.lang.String
getCopyright()
Get the value of copyright.java.lang.String
getDescription()
Get the value of description.java.lang.String
getDocs()
Get the value of docs.java.lang.String
getId()
java.lang.String
getImageDescription()
Get the value of imageDescription.int
getImageHeight()
Get the value of imageHeight.java.lang.String
getImageLink()
Get the value of imageLink.java.lang.String
getImageTitle()
Get the value of imageTitle.java.lang.String
getImageUrl()
Get the value of imageUrl.int
getImageWidth()
Get the value of imageWidth.java.util.List<RssItem>
getItemList()
Retrieve the list of RssItem of this feed.java.lang.String
getLanguage()
Get the value of language.java.lang.String
getLastBuildDate()
Deprecated.java.util.Date
getLastUpdate()
Retrieve the Date at which this RssChannel was last build and parsed.java.lang.String
getLink()
Get the value of link.java.util.Set<RssEventListener>
getListeners()
returns theRssEventListener
Setjava.lang.String
getManagingEditor()
Get the value of managingEditor.java.util.Date
getNextUpdate()
Retrieve the Date at which this RssChannel should be left and parsed again.java.lang.String
getPubDate()
Deprecated.java.util.Date
getPublicationDate()
java.lang.String
getRating()
Get the value of rating.java.lang.String
getSource()
Retrieve the source of this RssChannel (used only for debugging purpose).java.lang.String
getTextinputDescription()
Get the value of textinputDescription.java.lang.String
getTextinputLink()
Get the value of textinputLink.java.lang.String
getTextinputName()
Get the value of textinputName.java.lang.String
getTextinputTitle()
Get the value of textinputTitle.java.lang.String
getTitle()
Retrieve the title of this RSS.long
getTtl()
Retrieve the number of minutes indicating how long this channel can be cached before being refreshed from the source.long
getUfreq()
Retrieve the update frequency of this RssChannel.java.lang.String
getVersion()
Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).java.lang.String
getWebMaster()
Get the value of webMaster.boolean
needToRefresh()
Determine if the channel must be refreshedvoid
removeListener(RssEventListener listener)
RemoveRssEventListener
from existing listenervoid
removeListeners(java.util.List<RssEventListener> listeners)
RemoveRssEventListener
from listener listvoid
setBuildDate(java.util.Date buildDate)
void
setCopyright(java.lang.String v)
Set the value of copyright.void
setDescription(java.lang.String v)
Set the value of description.void
setDocs(java.lang.String v)
Set the value of docs.void
setId(java.lang.String id)
void
setImageDescription(java.lang.String v)
Set the value of imageDescription.void
setImageHeight(int v)
Set the value of imageHeight.void
setImageHeightStr(java.lang.String heightStr)
Set the value of imageHeight.void
setImageLink(java.lang.String val)
Set the value of imageLink.void
setImageTitle(java.lang.String v)
Set the value of imageTitle.void
setImageUrl(java.lang.String v)
Set the value of imageUrl.void
setImageWidth(int v)
Set the value of imageWidth.void
setImageWidthStr(java.lang.String widthStr)
Set the value of imageWidth.void
setItemList(java.util.List<RssItem> list)
Set the list of RssItem of this feed.void
setLanguage(java.lang.String v)
Set the value of language.void
setLastBuildDate(java.lang.String v)
Deprecated.void
setLink(java.lang.String v)
Set the value of link.void
setListeners(java.util.Set<RssEventListener> listeners)
void
setManagingEditor(java.lang.String v)
Set the value of managingEditor.void
setPubDate(java.lang.String v)
Deprecated.void
setPublicationDate(java.util.Date publicationDate)
void
setRating(java.lang.String v)
Set the value of rating.void
setTextinputDescription(java.lang.String v)
Set the value of textinputDescription.void
setTextinputLink(java.lang.String v)
Set the value of textinputLink.void
setTextinputName(java.lang.String v)
Set the value of textinputName.void
setTextinputTitle(java.lang.String v)
Set the value of textinputTitle.void
setTitle(java.lang.String title)
Set the title of this RSS.void
setTtl(long ttl)
Set the time to live of this RssChannelvoid
setTtl(java.lang.String ttlStr)
Set the time to live of this RssChannelvoid
setUfreq(long ufreq)
Set the update frequency of this RssChannel.void
setVersion(java.lang.String version)
Set the RSS version of this channel.void
setWebMaster(java.lang.String v)
Set the value of webMaster.java.lang.String
toString()
-
-
-
Constructor Detail
-
RssChannel
public RssChannel(java.lang.String url, long ufreq) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
url
- the URL of the RSS channel (a remote location using http or https)ufreq
- the update frequency, in minutes- Throws:
RssException
- if an error occured while getting or parsing the RSS
-
RssChannel
public RssChannel(java.lang.String url, long ufreq, int timeout) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
url
- the URL of the RSS channel (a remote location using http or https)ufreq
- the update frequency, in minutestimeout
- the time (in milliseconds) to wait for a connection to become available. Default value is 3000 (3 seconds). Default value will be used if zero or a negative value is specified.- Throws:
RssException
- if an error occured while getting or parsing the RSS
-
RssChannel
public RssChannel(java.io.File file) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
file
- the RSS XML file to read- Throws:
RssException
- if an error occured while reading or parsing the RSS
-
RssChannel
public RssChannel(java.lang.String url, long ufreq, java.util.Set<RssEventListener> eventListeners) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
url
- the URL of the RSS channel (a remote location using http or https)ufreq
- the update frequency, in minuteseventListeners
- Set ofRssEventListener
- Throws:
RssException
- if an error occured while getting or parsing the RSS- Since:
- JCMS 6.3
-
RssChannel
public RssChannel(java.lang.String url, long ufreq, int timeout, java.util.Set<RssEventListener> eventListeners) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
url
- the URL of the RSS channel (a remote location using http or https)ufreq
- the update frequency, in minutestimeout
- the time (in milliseconds) to wait for a connection to become available. Default value is 3000 (3 seconds). Default value will be used if zero or a negative value is specified.eventListeners
- Set ofRssEventListener
- Throws:
RssException
- if an error occured while getting or parsing the RSS- Since:
- JCMS 6.3
-
RssChannel
public RssChannel(java.io.File file, java.util.Set<RssEventListener> eventListeners) throws RssException
Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.- Parameters:
file
- the RSS XML file to readeventListeners
- Set ofRssEventListener
- Throws:
RssException
- if an error occured while reading or parsing the RSS- Since:
- JCMS 6.3
-
-
Method Detail
-
needToRefresh
public boolean needToRefresh()
Determine if the channel must be refreshed- Returns:
- true if the channel must be refreshed
-
getLastUpdate
public java.util.Date getLastUpdate()
Retrieve the Date at which this RssChannel was last build and parsed.- Returns:
- the last update Date.
-
getNextUpdate
public java.util.Date getNextUpdate()
Retrieve the Date at which this RssChannel should be left and parsed again.- Returns:
- the next update Date == last update + (ttl || ufreq).
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getVersion
public java.lang.String getVersion()
Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).- Returns:
- the rss version.
-
setVersion
public void setVersion(java.lang.String version)
Set the RSS version of this channel.- Parameters:
version
- the rss version (such as 0.91, 1.0 for rdf, 2.0, ...)
-
getTitle
public java.lang.String getTitle()
Retrieve the title of this RSS.- Returns:
- the rss' title.
-
setTitle
public void setTitle(java.lang.String title)
Set the title of this RSS.- Parameters:
title
- the new title value
-
getLink
public java.lang.String getLink()
Get the value of link.- Returns:
- Value of link.
-
setLink
public void setLink(java.lang.String v)
Set the value of link.- Parameters:
v
- Value to assign to link.
-
getDescription
public java.lang.String getDescription()
Get the value of description.- Returns:
- Value of description.
-
setDescription
public void setDescription(java.lang.String v)
Set the value of description.- Parameters:
v
- Value to assign to description.
-
getRating
public java.lang.String getRating()
Get the value of rating.- Returns:
- Value of rating.
-
setRating
public void setRating(java.lang.String v)
Set the value of rating.- Parameters:
v
- Value to assign to rating.
-
getLanguage
public java.lang.String getLanguage()
Get the value of language.- Returns:
- Value of language.
-
setLanguage
public void setLanguage(java.lang.String v)
Set the value of language.- Parameters:
v
- Value to assign to language.
-
getCopyright
public java.lang.String getCopyright()
Get the value of copyright.- Returns:
- Value of copyright.
-
setCopyright
public void setCopyright(java.lang.String v)
Set the value of copyright.- Parameters:
v
- Value to assign to copyright.
-
getManagingEditor
public java.lang.String getManagingEditor()
Get the value of managingEditor.- Returns:
- Value of managingEditor.
-
setManagingEditor
public void setManagingEditor(java.lang.String v)
Set the value of managingEditor.- Parameters:
v
- Value to assign to managingEditor.
-
getWebMaster
public java.lang.String getWebMaster()
Get the value of webMaster.- Returns:
- Value of webMaster.
-
setWebMaster
public void setWebMaster(java.lang.String v)
Set the value of webMaster.- Parameters:
v
- Value to assign to webMaster.
-
getImageTitle
public java.lang.String getImageTitle()
Get the value of imageTitle.- Returns:
- Value of imageTitle.
-
setImageTitle
public void setImageTitle(java.lang.String v)
Set the value of imageTitle.- Parameters:
v
- Value to assign to imageTitle.
-
getImageUrl
public java.lang.String getImageUrl()
Get the value of imageUrl.- Returns:
- Value of imageUrl.
-
setImageUrl
public void setImageUrl(java.lang.String v)
Set the value of imageUrl.- Parameters:
v
- Value to assign to imageUrl.
-
getImageLink
public java.lang.String getImageLink()
Get the value of imageLink.- Returns:
- Value of imageLink.
-
setImageLink
public void setImageLink(java.lang.String val)
Set the value of imageLink.- Parameters:
val
- Value to assign to imageLink.
-
setImageWidthStr
public void setImageWidthStr(java.lang.String widthStr)
Set the value of imageWidth.- Parameters:
widthStr
- Value to assign to imageWidth.
-
getImageWidth
public int getImageWidth()
Get the value of imageWidth.- Returns:
- Value of imageWidth.
-
setImageWidth
public void setImageWidth(int v)
Set the value of imageWidth.- Parameters:
v
- Value to assign to imageWidth.
-
setImageHeightStr
public void setImageHeightStr(java.lang.String heightStr)
Set the value of imageHeight.- Parameters:
heightStr
- Value to assign to imageHeight.
-
getImageHeight
public int getImageHeight()
Get the value of imageHeight.- Returns:
- Value of imageHeight.
-
setImageHeight
public void setImageHeight(int v)
Set the value of imageHeight.- Parameters:
v
- Value to assign to imageHeight.
-
getImageDescription
public java.lang.String getImageDescription()
Get the value of imageDescription.- Returns:
- Value of imageDescription.
-
setImageDescription
public void setImageDescription(java.lang.String v)
Set the value of imageDescription.- Parameters:
v
- Value to assign to imageDescription.
-
getTextinputTitle
public java.lang.String getTextinputTitle()
Get the value of textinputTitle.- Returns:
- Value of textinputTitle.
-
setTextinputTitle
public void setTextinputTitle(java.lang.String v)
Set the value of textinputTitle.- Parameters:
v
- Value to assign to textinputTitle.
-
getTextinputDescription
public java.lang.String getTextinputDescription()
Get the value of textinputDescription.- Returns:
- Value of textinputDescription.
-
setTextinputDescription
public void setTextinputDescription(java.lang.String v)
Set the value of textinputDescription.- Parameters:
v
- Value to assign to textinputDescription.
-
getTextinputName
public java.lang.String getTextinputName()
Get the value of textinputName.- Returns:
- Value of textinputName.
-
setTextinputName
public void setTextinputName(java.lang.String v)
Set the value of textinputName.- Parameters:
v
- Value to assign to textinputName.
-
getTextinputLink
public java.lang.String getTextinputLink()
Get the value of textinputLink.- Returns:
- Value of textinputLink.
-
setTextinputLink
public void setTextinputLink(java.lang.String v)
Set the value of textinputLink.- Parameters:
v
- Value to assign to textinputLink.
-
getPubDate
@Deprecated public java.lang.String getPubDate()
Deprecated.Get the value of pubDate. This method is deprecated. getPublicationDate must be use instead This method returns date in ISO 8601 format- Returns:
- Value of pubDate.
-
setPubDate
@Deprecated public void setPubDate(java.lang.String v)
Deprecated.Set the value of pubDate. This methos is deprecated and setPublication(Date date) must be use instead- Parameters:
v
- Value to assign to pubDate.
-
getLastBuildDate
@Deprecated public java.lang.String getLastBuildDate()
Deprecated.Get the value of lastBuildDate.This method is deprecated. getBuildDate must be use instead This method returns date in ISO 8601 format- Returns:
- Value of lastBuildDate.
-
setLastBuildDate
@Deprecated public void setLastBuildDate(java.lang.String v)
Deprecated.Set the value of lastBuildDate. This methos is deprecated and setBuildDate(Date date) must be use instead- Parameters:
v
- Value to assign to lastBuildDate.
-
getBuildDate
public java.util.Date getBuildDate()
- Returns:
- the buildDate
-
setBuildDate
public void setBuildDate(java.util.Date buildDate)
- Parameters:
buildDate
- the buildDate to set
-
getDocs
public java.lang.String getDocs()
Get the value of docs.- Returns:
- Value of docs.
-
setDocs
public void setDocs(java.lang.String v)
Set the value of docs.- Parameters:
v
- Value to assign to docs.
-
getItemList
public java.util.List<RssItem> getItemList()
Retrieve the list of RssItem of this feed.- Returns:
- a list of RssItem, never return null.
-
setItemList
public void setItemList(java.util.List<RssItem> list)
Set the list of RssItem of this feed.- Parameters:
list
- a list list of RssItem, must not be null
-
getTtl
public long getTtl()
Retrieve the number of minutes indicating how long this channel can be cached before being refreshed from the source.- Returns:
- the "time to live" in minutes.
-
setTtl
public void setTtl(long ttl)
Set the time to live of this RssChannel- Parameters:
ttl
- time to live in minutes.
-
setTtl
public void setTtl(java.lang.String ttlStr)
Set the time to live of this RssChannel- Parameters:
ttlStr
- time to live in minutes.
-
getUfreq
public long getUfreq()
Retrieve the update frequency of this RssChannel.- Returns:
- the update frequency in minutes.
-
setUfreq
public void setUfreq(long ufreq)
Set the update frequency of this RssChannel.- Parameters:
ufreq
- the new update frequency value, in minutes.
-
getSource
public java.lang.String getSource()
Retrieve the source of this RssChannel (used only for debugging purpose).- Returns:
- source of the channel (url or file path)
-
getPublicationDate
public java.util.Date getPublicationDate()
- Returns:
- the publicationDate
-
setPublicationDate
public void setPublicationDate(java.util.Date publicationDate)
- Parameters:
publicationDate
- the publicationDate to set
-
getId
public java.lang.String getId()
- Returns:
- the id
-
setId
public void setId(java.lang.String id)
- Parameters:
id
- the id to set
-
convertDate
public static java.util.Date convertDate(java.lang.String date)
-
getListeners
public java.util.Set<RssEventListener> getListeners()
returns theRssEventListener
Set- Returns:
- the list
- Since:
- JCMS 9.0.1
-
setListeners
public void setListeners(java.util.Set<RssEventListener> listeners)
- Parameters:
listeners
- theRssEventListener
Set to set- Since:
- JCMS 9.0.1
-
addListeners
public void addListeners(java.util.Set<RssEventListener> listeners)
AddRssEventListener
list to existing listeners- Parameters:
listeners
- the Set- Since:
- JCMS 6.3
-
removeListeners
public void removeListeners(java.util.List<RssEventListener> listeners)
RemoveRssEventListener
from listener list- Parameters:
listeners
- theRssEventListener
to remove- Since:
- JCMS 6.3
-
addListener
public void addListener(RssEventListener listener)
AddRssEventListener
- Parameters:
listener
- theRssEventListener
- Since:
- JCMS 6.3
-
removeListener
public void removeListener(RssEventListener listener)
RemoveRssEventListener
from existing listener- Parameters:
listener
- theRssEventListener
- Since:
- JCMS 6.3
-
generateID
public static java.lang.String generateID(java.lang.String id, int maxLength)
compute a id from parameter. If the id length is less than maxLength parameter, the id is returned. Else the id is truncated and an MD5sum of id is added to the length of the string- Parameters:
id
- the string which should be an idmaxLength
- the max length of the id- Returns:
- the computed id
-
-