org.apache.cocoon.serialization
Class ZipArchiveSerializer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.serialization.AbstractSerializer
                          |
                          +--org.apache.cocoon.serialization.ZipArchiveSerializer
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, Serializer, SitemapOutputComponent, XMLConsumer, XMLPipe, XMLProducer

public class ZipArchiveSerializer
extends AbstractSerializer

A serializer that builds Zip archives by aggregating several sources.

The input document should describe entries of the archive by means of their name (which can be a path) in the archive and the source of the entry contents. These are Cocoon sources, and as such can use any of the protocols handled by Cocoon, including "cocoon:" to include dynamically generated content in the archive.

Example :

   <zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
     <zip:entry name="foo.html" src="cocoon://dynFoo.html"/>
     <zip:entry name="images/bar.jpeg" src="bar.jpeg"/>
   </zip:archive:zip>
 

Author:
Sylvain Wallez

Field Summary
protected  byte[] buffer
          Temporary byte buffer to read source data
protected  boolean inZip
          Have we encountered the toplevel "zip" element ?
protected  SourceResolver resolver
          The resolver to get sources
static java.lang.String ZIP_NAMESPACE
          The namespace for elements handled by this serializer, "http://apache.org/cocoon/zip-archive/1.0".
protected  java.util.zip.ZipOutputStream zipOutput
          The Zip stream where entries will be written
 
Fields inherited from class org.apache.cocoon.serialization.AbstractSerializer
output
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
ZipArchiveSerializer()
           
 
Method Summary
protected  void addEntry(org.xml.sax.Attributes atts)
          Add an entry in the archive.
 void endDocument()
          Receive notification of the end of a document.
 java.lang.String getMimeType()
          Always return "application/x-zip" which is the default for Zip archives.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.serialization.AbstractSerializer
recycle, setOutputStream, shouldSetContentLength
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
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
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

ZIP_NAMESPACE

public static final java.lang.String ZIP_NAMESPACE
The namespace for elements handled by this serializer, "http://apache.org/cocoon/zip-archive/1.0".

zipOutput

protected java.util.zip.ZipOutputStream zipOutput
The Zip stream where entries will be written

inZip

protected boolean inZip
Have we encountered the toplevel "zip" element ?

resolver

protected SourceResolver resolver
The resolver to get sources

buffer

protected byte[] buffer
Temporary byte buffer to read source data
Constructor Detail

ZipArchiveSerializer

public ZipArchiveSerializer()
Method Detail

getMimeType

public java.lang.String getMimeType()
Always return "application/x-zip" which is the default for Zip archives.
Overrides:
getMimeType in class AbstractSerializer

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of a document.
Overrides:
startDocument in class AbstractXMLPipe
See Also:
ContentHandler.startDocument()

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of an element.
Overrides:
startElement in class AbstractXMLPipe
See Also:
ContentHandler.startElement(String, String, String, Attributes)

addEntry

protected void addEntry(org.xml.sax.Attributes atts)
                 throws org.xml.sax.SAXException
Add an entry in the archive.
Parameters:
atts - the attributes that describe the entry

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of a document.
Overrides:
endDocument in class AbstractXMLPipe
See Also:
ContentHandler.endDocument()


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.