org.nuiton.rss
Class RSSGenerator

java.lang.Object
  extended by org.nuiton.rss.RSSGenerator

public class RSSGenerator
extends Object

generator of rss feeds to be stored in a file

Author:
tony

Field Summary
static DateFormat DATE_PARSER
          date formater use to save date in feed and entries
protected  EnumMap<Field,String> feedProperties
          dictonnary of field <-> property for feed
protected  FeedType format
          feed format to use *
protected  File generatorDirectory
          directory where feeds are stored
protected  EnumMap<Field,String> itemProperties
          dictonnary of field <-> property for entry
protected  int nbItems
          number of feed to use by default
 
Constructor Summary
protected RSSGenerator()
           
protected RSSGenerator(EnumMap<Field,String> feedProperties, EnumMap<Field,String> itemProperties, File generatorDirectory, FeedType format, int nbItems)
           
protected RSSGenerator(File generatorDirectory)
           
 
Method Summary
protected  FileLock acquireLock(File f)
           
 void addItemToFeedFile(URL url, int nbEntries, Map<Field,Object> values)
          Add a item to an existing feed file.
 void createFeedFile(URL url, FeedType type, Map<Field,Object> values)
           
 void deleteFeedFile(URL toURL)
           
 File getFeedFile(String name)
           
protected  File getFile(URL url)
          Obtain the file from his url location.
 FeedType getFormat()
           
 File getGeneratorDirectory()
           
 int getNbItems()
           
protected  File getWriteFileLock(File f)
           
static RSSGenerator newDefaultInstance()
           
static RSSGenerator newDefaultInstance(File generatorDirectory)
           
protected  void releaseLock(File f, FileLock lock)
           
 EnumSet<Field> updateFeedFile(URL url, Map<Field,Object> values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_PARSER

public static final DateFormat DATE_PARSER
date formater use to save date in feed and entries


feedProperties

protected final EnumMap<Field,String> feedProperties
dictonnary of field <-> property for feed


itemProperties

protected final EnumMap<Field,String> itemProperties
dictonnary of field <-> property for entry


generatorDirectory

protected final File generatorDirectory
directory where feeds are stored


format

protected final FeedType format
feed format to use *


nbItems

protected final int nbItems
number of feed to use by default

Constructor Detail

RSSGenerator

protected RSSGenerator()

RSSGenerator

protected RSSGenerator(EnumMap<Field,String> feedProperties,
                       EnumMap<Field,String> itemProperties,
                       File generatorDirectory,
                       FeedType format,
                       int nbItems)

RSSGenerator

protected RSSGenerator(File generatorDirectory)
Method Detail

newDefaultInstance

public static RSSGenerator newDefaultInstance(File generatorDirectory)
                                       throws Exception
Parameters:
generatorDirectory - generator directory
Returns:
une nouvelle instance de RssHelper en utilisant les implantations definies dans RSSGeneratorConfig.
Throws:
Exception - pour tout pb lors de l'instanciation des objects

newDefaultInstance

public static RSSGenerator newDefaultInstance()
                                       throws Exception
Returns:
une nouvelle instance de RssHelper en utilisant les implantations definies dans RSSGeneratorConfig.
Throws:
Exception - pour tout pb lors de l'instanciation des objects

createFeedFile

public void createFeedFile(URL url,
                           FeedType type,
                           Map<Field,Object> values)
                    throws IOException,
                           com.sun.syndication.io.FeedException,
                           ParseException
Parameters:
url - location where to create the file
type - fromat of feed to create
values - properties of the feed
Throws:
ParseException - if pb while parsing date
IOException - if io pb
com.sun.syndication.io.FeedException - if pb while creating feed

addItemToFeedFile

public void addItemToFeedFile(URL url,
                              int nbEntries,
                              Map<Field,Object> values)
                       throws IOException,
                              com.sun.syndication.io.FeedException,
                              ParseException
Add a item to an existing feed file.

Parameters:
url - location of feed to used
nbEntries - number of maximum entries to be written in feed file
values - dictionnary of properties to write
Throws:
com.sun.syndication.io.FeedException - if feed pb
IOException - if io pb
ParseException - if dateparser pb

deleteFeedFile

public void deleteFeedFile(URL toURL)

updateFeedFile

public EnumSet<Field> updateFeedFile(URL url,
                                     Map<Field,Object> values)
                              throws IOException,
                                     com.sun.syndication.io.FeedException,
                                     ParseException
Parameters:
url -
values -
Returns:
the set of modified fields.
Throws:
IOException
com.sun.syndication.io.FeedException
ParseException

getFormat

public FeedType getFormat()

getFeedFile

public File getFeedFile(String name)

getNbItems

public int getNbItems()

getFile

protected File getFile(URL url)
                throws IllegalStateException
Obtain the file from his url location.

Parameters:
url - location of the file
Returns:
the file
Throws:
IllegalStateException - if uri is not sytax valid

acquireLock

protected FileLock acquireLock(File f)
                        throws IOException
Throws:
IOException

getWriteFileLock

protected File getWriteFileLock(File f)

releaseLock

protected void releaseLock(File f,
                           FileLock lock)
                    throws IOException
Throws:
IOException

getGeneratorDirectory

public File getGeneratorDirectory()


Copyright © 2008-2012 CodeLutin. All Rights Reserved.