org.apache.cocoon.generation
Class StreamGenerator
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLoggable
|
+--org.apache.cocoon.xml.AbstractXMLProducer
|
+--org.apache.cocoon.generation.AbstractGenerator
|
+--org.apache.cocoon.generation.ComposerGenerator
|
+--org.apache.cocoon.generation.StreamGenerator
- All Implemented Interfaces:
- org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, Generator, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, XMLProducer
- public class StreamGenerator
- extends ComposerGenerator
The StreamGenerator
is a class that reads XML from a
request InputStream and generates SAX Events.
For the POST requests with mimetype of
application/x-www-form-urlencoded the xml data is expected to be
associated with the name specified in the sitemap parameter. 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.
- Version:
- CVS $Id: StreamGenerator.java,v 1.8.2.2 2002/05/19 22:59:54 stefano Exp $
- Author:
- Kinga Dziembowski
Field Summary |
static java.lang.String |
CLASS
|
static java.lang.String |
FORM_NAME
The parameter holding the name associated with the xml data |
Fields inherited from interface org.apache.cocoon.generation.Generator |
ROLE |
Method Summary |
protected java.lang.String |
extractCharset(java.lang.String contentType,
int idx)
|
void |
generate()
Generate XML data out of request InputStream. |
java.lang.String |
getCharacterEncoding(javax.servlet.http.HttpServletRequest req,
java.lang.String contentType)
Content type HTTP header can contains character encodinf info
for ex. |
void |
recycle()
Recycle this component.
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CLASS
public static final java.lang.String CLASS
FORM_NAME
public static final java.lang.String FORM_NAME
- The parameter holding the name associated with the xml data
StreamGenerator
public StreamGenerator()
recycle
public void recycle()
- Recycle this component.
All instance variables are set to
null
.
- Overrides:
recycle
in class AbstractGenerator
generate
public void generate()
throws java.io.IOException,
org.xml.sax.SAXException,
ProcessingException
- Generate XML data out of request InputStream.
getCharacterEncoding
public java.lang.String getCharacterEncoding(javax.servlet.http.HttpServletRequest req,
java.lang.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 java.lang.String extractCharset(java.lang.String contentType,
int idx)
Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.