Package org.ametys.core.cocoon
Class ZipArchiveNGSerializer
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.xml.AbstractXMLPipe
-
- org.apache.cocoon.serialization.AbstractSerializer
-
- org.ametys.core.cocoon.ZipArchiveNGSerializer
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,LogEnabled
,Serviceable
,Serializer
,SitemapOutputComponent
,XMLConsumer
,XMLPipe
,XMLProducer
,XMLConsumer
,ContentHandler
,LexicalHandler
public class ZipArchiveNGSerializer extends AbstractSerializer implements Disposable, Serviceable
ZIP archive serializer that makes use of apache commons compress ZipArchiveOutputStream instead of JavaSE's ZipOutputStream. It's based on cocoon's ZipArchiveSerializer.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
_buffer
Temporary byte buffer to read source dataprotected int
_contentDepth
Current depth of the serialized contentprotected ServiceManager
_manager
The component managerprotected SourceResolver
_resolver
The resolver to get sourcesprotected ServiceSelector
_selector
The serializer component selectorprotected Serializer
_serializer
Serializer used when in IN_CONTENT stateprotected int
_state
The current stateprotected ZipArchiveOutputStream
_zipOutput
The Zip stream where entries will be writtenstatic String
ZIP_NAMESPACE
The namespace for elements handled by this serializer, "http://apache.org/cocoon/zip-archive/1.0".-
Fields inherited from class org.apache.cocoon.serialization.AbstractSerializer
output
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
-
-
Constructor Summary
Constructors Constructor Description ZipArchiveNGSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addEntry(Attributes atts)
Add an entry in the archive.void
characters(char[] buffer, int offset, int length)
void
dispose()
void
endDocument()
void
endElement(String namespaceURI, String localName, String qName)
void
endPrefixMapping(String prefix)
String
getMimeType()
Returns default mime type for zip archives,application/zip
.void
recycle()
void
service(ServiceManager manager)
void
startDocument()
void
startElement(String namespaceURI, String localName, String qName, Attributes atts)
void
startPrefixMapping(String prefix, String uri)
Begin the scope of a prefix-URI Namespace mapping.-
Methods inherited from class org.apache.cocoon.serialization.AbstractSerializer
setOutputStream, shouldSetContentLength
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
comment, endCDATA, endDTD, endEntity, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startEntity
-
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.xml.sax.ContentHandler
ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity
-
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 String ZIP_NAMESPACE
The namespace for elements handled by this serializer, "http://apache.org/cocoon/zip-archive/1.0".- See Also:
- Constant Field Values
-
_manager
protected ServiceManager _manager
The component manager
-
_selector
protected ServiceSelector _selector
The serializer component selector
-
_zipOutput
protected ZipArchiveOutputStream _zipOutput
The Zip stream where entries will be written
-
_state
protected int _state
The current state
-
_resolver
protected SourceResolver _resolver
The resolver to get sources
-
_buffer
protected byte[] _buffer
Temporary byte buffer to read source data
-
_serializer
protected Serializer _serializer
Serializer used when in IN_CONTENT state
-
_contentDepth
protected int _contentDepth
Current depth of the serialized content
-
-
Constructor Detail
-
ZipArchiveNGSerializer
public ZipArchiveNGSerializer()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getMimeType
public String getMimeType()
Returns default mime type for zip archives,application/zip
. Can be overridden in the sitemap.- Specified by:
getMimeType
in interfaceSitemapOutputComponent
- Overrides:
getMimeType
in classAbstractSerializer
- Returns:
- application/zip
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classAbstractXMLPipe
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
Begin the scope of a prefix-URI Namespace mapping.- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classAbstractXMLPipe
- Parameters:
prefix
- The Namespace prefix being declared.uri
- The Namespace URI the prefix is mapped to.- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classAbstractXMLPipe
- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classAbstractXMLPipe
- Throws:
SAXException
-
characters
public void characters(char[] buffer, int offset, int length) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classAbstractXMLPipe
- Throws:
SAXException
-
addEntry
protected void addEntry(Attributes atts) throws SAXException
Add an entry in the archive.- Parameters:
atts
- the attributes that describe the entry- Throws:
SAXException
- if an error occurred
-
endElement
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classAbstractXMLPipe
- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classAbstractXMLPipe
- Throws:
SAXException
-
recycle
public void recycle()
- Specified by:
recycle
in interfaceRecyclable
- Overrides:
recycle
in classAbstractSerializer
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
-