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[]_bufferTemporary byte buffer to read source dataprotected int_contentDepthCurrent depth of the serialized contentprotected ServiceManager_managerThe component managerprotected SourceResolver_resolverThe resolver to get sourcesprotected ServiceSelector_selectorThe serializer component selectorprotected Serializer_serializerSerializer used when in IN_CONTENT stateprotected int_stateThe current stateprotected ZipArchiveOutputStream_zipOutputThe Zip stream where entries will be writtenstatic StringZIP_NAMESPACEThe 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 voidaddEntry(Attributes atts)Add an entry in the archive.voidcharacters(char[] buffer, int offset, int length)voiddispose()voidendDocument()voidendElement(String namespaceURI, String localName, String qName)voidendPrefixMapping(String prefix)StringgetMimeType()Returns default mime type for zip archives,application/zip.voidrecycle()voidservice(ServiceManager manager)voidstartDocument()voidstartElement(String namespaceURI, String localName, String qName, Attributes atts)voidstartPrefixMapping(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:
servicein interfaceServiceable- Throws:
ServiceException
-
getMimeType
public String getMimeType()
Returns default mime type for zip archives,application/zip. Can be overridden in the sitemap.- Specified by:
getMimeTypein interfaceSitemapOutputComponent- Overrides:
getMimeTypein classAbstractSerializer- Returns:
- application/zip
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classAbstractXMLPipe- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
Begin the scope of a prefix-URI Namespace mapping.- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin 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:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classAbstractXMLPipe- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classAbstractXMLPipe- Throws:
SAXException
-
characters
public void characters(char[] buffer, int offset, int length) throws SAXException
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin 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:
endElementin interfaceContentHandler- Overrides:
endElementin classAbstractXMLPipe- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classAbstractXMLPipe- Throws:
SAXException
-
recycle
public void recycle()
- Specified by:
recyclein interfaceRecyclable- Overrides:
recyclein classAbstractSerializer
-
dispose
public void dispose()
- Specified by:
disposein interfaceDisposable
-
-