org.apache.cocoon.generation
Class StreamGenerator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.generation.AbstractGenerator
org.apache.cocoon.generation.ServiceableGenerator
org.apache.cocoon.generation.StreamGenerator
- All Implemented Interfaces:
- Disposable, Generator, LogEnabled, Poolable, Recyclable, Serviceable, SitemapModelComponent, XMLProducer
- public class StreamGenerator
- extends ServiceableGenerator
- Version:
- CVS $Id: StreamGenerator.java 153227 2005-02-10 15:00:57Z cziegeler $
- Author:
- Kinga Dziembowski
- Cocoon.sitemap.component.documentation:
- The
StreamGenerator
is a class that reads XML from a
request InputStream and generates SAX Events.
- Cocoon.sitemap.component.label:
- content
- Cocoon.sitemap.component.logger:
- sitemap.generator.stream
- Cocoon.sitemap.component.name:
- stream
- Cocoon.sitemap.component.pooling.max:
- 16
For the POST requests with a mimetype of application/x-www-form-urlencoded,
or multipart/form-data the xml data is expected to be associated with the
sitemap parameter 'form-name'.
For the POST requests with mimetypes: text/plain, text/xml,
application/xml the xml data is in the body of the POST request and
its length is specified by the value returned by getContentLength()
method. The StreamGenerator uses helper
org.apache.cocoon.util.PostInputStream class for InputStream
reading operations. At the time that Parser is reading the data
out of InputStream - Parser has no knowledge about the length of
data to be read. The only way to signal to the Parser that all
data was read from the InputStream is to control reading operation-
PostInputStream--and to return to the requestor '-1' when the
number of bytes read is equal to the getContentLength() value.
Field Summary |
static String |
FORM_NAME
The parameter holding the name associated with the xml data |
Fields inherited from interface org.apache.cocoon.generation.Generator |
ROLE |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FORM_NAME
public static final String FORM_NAME
- The parameter holding the name associated with the xml data
- See Also:
- Constant Field Values
StreamGenerator
public StreamGenerator()
recycle
public void recycle()
- Recycle this component.
All instance variables are set to
null
.
- Specified by:
recycle
in interface Recyclable
- Overrides:
recycle
in class AbstractGenerator
generate
public void generate()
throws IOException,
SAXException,
ProcessingException
- Generate XML data out of request InputStream.
- Throws:
IOException
SAXException
ProcessingException
getCharacterEncoding
public String getCharacterEncoding(Request req,
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.
extractCharset
protected String extractCharset(String contentType,
int idx)
Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.