org.apache.cocoon.generation
Class CalendarGenerator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.generation.AbstractGenerator
              extended by org.apache.cocoon.generation.ServiceableGenerator
                  extended by org.apache.cocoon.generation.CalendarGenerator
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, LogEnabled, Serviceable, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer

public class CalendarGenerator
extends ServiceableGenerator
implements CacheableProcessingComponent

Version:
CVS $Id: CalendarGenerator.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  AttributesImpl attributes
          Convenience object, so we don't need to create an AttributesImpl for every element.
protected  List cacheKeyParList
          The cache key needs to be generated for the configuration of this generator, so storing the parameters for generateKey().
protected static String CALENDAR_NODE_NAME
          Node and attribute names
protected static String DATE_ATTR_NAME
           
protected  DateFormat dateFormatter
          The format for dates
protected static String DAY_NODE_NAME
           
protected  Locale locale
          The current locale
protected  int month
          The month to generate the calendar for
protected static String MONTH_ATTR_NAME
           
protected  DateFormat monthFormatter
          The format for month names
protected static DecimalFormat monthNumberFormatter
          Formatter for month number
protected static String NEXT_MONTH_ATTR_NAME
           
protected static String NEXT_YEAR_ATTR_NAME
           
protected static String NUMBER_ATTR_NAME
           
protected  boolean padWeeks
          Do we need to pad out the first and last weeks?
protected static String PREFIX
          The namespace prefix for this namespace.
protected static String PREV_MONTH_ATTR_NAME
           
protected static String PREV_YEAR_ATTR_NAME
           
protected static String URI
          The URI of the namespace of this generator.
protected static String WEEK_NODE_NAME
           
protected static String WEEKDAY_ATTR_NAME
           
protected  String[] weekdays
           
protected  int year
          The year to generate the calendar for
protected static String YEAR_ATTR_NAME
           
 
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
CalendarGenerator()
           
 
Method Summary
protected  void addContent(Calendar date, Locale locale)
          Add content to a <day> element.
 void generate()
          Generate XML data.
 Serializable getKey()
          Generate the unique key.
 SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recycle resources
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Set the request parameters.
 
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose, service
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

URI

protected static final String URI
The URI of the namespace of this generator.

See Also:
Constant Field Values

PREFIX

protected static final String PREFIX
The namespace prefix for this namespace.

See Also:
Constant Field Values

CALENDAR_NODE_NAME

protected static final String CALENDAR_NODE_NAME
Node and attribute names

See Also:
Constant Field Values

WEEK_NODE_NAME

protected static final String WEEK_NODE_NAME
See Also:
Constant Field Values

DAY_NODE_NAME

protected static final String DAY_NODE_NAME
See Also:
Constant Field Values

MONTH_ATTR_NAME

protected static final String MONTH_ATTR_NAME
See Also:
Constant Field Values

YEAR_ATTR_NAME

protected static final String YEAR_ATTR_NAME
See Also:
Constant Field Values

DATE_ATTR_NAME

protected static final String DATE_ATTR_NAME
See Also:
Constant Field Values

NUMBER_ATTR_NAME

protected static final String NUMBER_ATTR_NAME
See Also:
Constant Field Values

WEEKDAY_ATTR_NAME

protected static final String WEEKDAY_ATTR_NAME
See Also:
Constant Field Values

PREV_MONTH_ATTR_NAME

protected static final String PREV_MONTH_ATTR_NAME
See Also:
Constant Field Values

PREV_YEAR_ATTR_NAME

protected static final String PREV_YEAR_ATTR_NAME
See Also:
Constant Field Values

NEXT_MONTH_ATTR_NAME

protected static final String NEXT_MONTH_ATTR_NAME
See Also:
Constant Field Values

NEXT_YEAR_ATTR_NAME

protected static final String NEXT_YEAR_ATTR_NAME
See Also:
Constant Field Values

monthNumberFormatter

protected static final DecimalFormat monthNumberFormatter
Formatter for month number


attributes

protected AttributesImpl attributes
Convenience object, so we don't need to create an AttributesImpl for every element.


cacheKeyParList

protected List cacheKeyParList
The cache key needs to be generated for the configuration of this generator, so storing the parameters for generateKey().


year

protected int year
The year to generate the calendar for


month

protected int month
The month to generate the calendar for


dateFormatter

protected DateFormat dateFormatter
The format for dates


monthFormatter

protected DateFormat monthFormatter
The format for month names


locale

protected Locale locale
The current locale


padWeeks

protected boolean padWeeks
Do we need to pad out the first and last weeks?


weekdays

protected String[] weekdays
Constructor Detail

CalendarGenerator

public CalendarGenerator()
Method Detail

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Set the request parameters. Must be called before the generate method.

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractGenerator
Parameters:
resolver - the SourceResolver object
objectModel - a Map containing model object
src - the source URI (ignored)
par - configuration parameters
Throws:
ProcessingException
SAXException
IOException

generate

public void generate()
              throws SAXException,
                     ProcessingException
Generate XML data.

Specified by:
generate in interface Generator
Throws:
SAXException - if an error occurs while outputting the document
ProcessingException

addContent

protected void addContent(Calendar date,
                          Locale locale)
                   throws SAXException
Add content to a <day> element. This method is intended to be overridden by subclasses that want to add content to one or more days of the calendar.

Parameters:
date - The date corresponding to the current element.
locale - The current locale.
Throws:
SAXException - if an error occurs while outputting the document

getKey

public Serializable getKey()
Description copied from interface: CacheableProcessingComponent
Generate the unique key. This key must be unique inside the space of this component. This method must be invoked before the getValidity() method.

Specified by:
getKey in interface CacheableProcessingComponent
Returns:
The generated key or null if the component is currently not cacheable.

getValidity

public SourceValidity getValidity()
Description copied from interface: CacheableProcessingComponent
Generate the validity object. Before this method can be invoked the getKey() method must be invoked.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

recycle

public void recycle()
Recycle resources

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractGenerator
See Also:
Recyclable.recycle()


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.