org.apache.cocoon.generation
Class RequestAttributeGenerator

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

public class RequestAttributeGenerator
extends ServiceableGenerator

The RequestAttributeGenerator is a class that reads XML from a request attribute and generates SAX Events.

The response encoding is taken as the encoding of the xml-data.

Version:
CVS $Id: RequestAttributeGenerator.java 30941 2004-07-29 19:56:58Z vgritsenko $
Author:
Kinga Dziembowski, Bernhard Huber
Cocoon.sitemap.component.label:
content
Cocoon.sitemap.component.logger:
sitemap.generator.req-attr
Cocoon.sitemap.component.name:
req-attr
Cocoon.sitemap.component.parameter:
attribute-name type="String" description="Specifies name of request attribute holding xml data. This xml data will be sent into the cocoon pipeline." required="no" default="org.apache.cocoon.xml-data"

Field Summary
static String REQUEST_ATTRIBUTE_NAME
          The config parameter for specifying name of the request attribute, holding the name associated with the xml data, ie attribute-name .
static String REQUEST_ATTRIBUTE_NAME_DEFAULT
          The default name of the request attribute name, storing xml-data, ie.
 
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
RequestAttributeGenerator()
           
 
Method Summary
protected  String extractCharset(String contentType, int idx)
          Description of the Method
 void generate()
          Generate XML data out of request attribute, and send it into cocoon pipeline.
protected  String getCharacterEncoding(Response res, String contentType)
          Content type HTTP header can contains character encodinf info for ex.
 
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose, service
 
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
 
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

REQUEST_ATTRIBUTE_NAME

public static final String REQUEST_ATTRIBUTE_NAME
The config parameter for specifying name of the request attribute, holding the name associated with the xml data, ie attribute-name .

See Also:
Constant Field Values

REQUEST_ATTRIBUTE_NAME_DEFAULT

public static final String REQUEST_ATTRIBUTE_NAME_DEFAULT
The default name of the request attribute name, storing xml-data, ie. org.apache.cocoon.xml-data.

See Also:
Constant Field Values
Constructor Detail

RequestAttributeGenerator

public RequestAttributeGenerator()
Method Detail

generate

public void generate()
              throws SAXException,
                     ProcessingException
Generate XML data out of request attribute, and send it into cocoon pipeline.

Throws:
SAXException - Description of Exception
ProcessingException - Description of Exception

getCharacterEncoding

protected String getCharacterEncoding(Response res,
                                      String contentType)
Content type HTTP header can contains character encodinf info for ex. Content-Type: text/xml; charset=UTF-8 If the servlet is following spec 2.3 and higher the servlet API can be used to retrieve character encoding part of Content-Type header. Some containers can choose to not unpack charset info - the spec is not strong about it. in any case this method can be used as a latest resource to retrieve the passed charset value. null is returned. It is very common mistake to send : Content-Type: text/xml; charset="UTF-8". Some containers are not filtering this mistake and the processing results in exception.. The getCharacterEncoding() compensates for above mistake.

Parameters:
contentType - value associated with Content-Type HTTP header.
res - Description of Parameter
Returns:
The characterEncoding value

extractCharset

protected String extractCharset(String contentType,
                                int idx)
Description of the Method

Parameters:
contentType - Description of Parameter
idx - Description of Parameter
Returns:
Description of the Returned Value


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.