1 16 17 package org.apache.cocoon.generation; 18 19 import de.tivano.flash.swf.parser.SWFReader; 20 import de.tivano.flash.swf.parser.SWFVerboseDefineFont2Reader; 21 import de.tivano.flash.swf.parser.SWFVerboseDefineFontReader; 22 23 import org.apache.avalon.framework.parameters.Parameters; 24 import org.apache.cocoon.ProcessingException; 25 import org.apache.cocoon.environment.SourceResolver; 26 import org.apache.excalibur.source.SourceException; 27 import org.xml.sax.InputSource ; 28 import org.xml.sax.SAXException ; 29 30 import java.io.IOException ; 31 import java.util.Map ; 32 33 39 public class SWFGenerator extends FileGenerator { 40 41 private boolean pVerbose = false; 42 private SWFReader parser; 43 44 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 45 throws ProcessingException, SAXException , IOException { 46 super.setup(resolver, objectModel, src, par); 47 parser = new SWFReader(); 48 if (pVerbose) { 49 parser.registerTagReader(48, new SWFVerboseDefineFont2Reader()); 50 parser.registerTagReader(10, new SWFVerboseDefineFontReader()); 51 } 52 } 53 54 public void generate() 55 throws IOException , SAXException , ProcessingException { 56 57 try { 58 if (this.getLogger().isDebugEnabled()) { 59 this.getLogger().debug("processing file " + super.source); 60 this.getLogger().debug("file resolved to " + this.inputSource.getURI()); 61 } 62 63 this.parser.setContentHandler(super.xmlConsumer); 64 this.parser.parse(new InputSource (this.inputSource.getInputStream())); 65 66 } catch (SourceException e) { 67 throw new ProcessingException("Could not read resource " 68 + this.inputSource.getURI(), e); 69 } catch (SAXException e) { 70 final Exception cause = e.getException(); 71 if( cause != null ) { 72 this.getLogger().debug("Got SAXException; Rethrowing cause exception", e); 73 if ( cause instanceof ProcessingException ) 74 throw (ProcessingException)cause; 75 if ( cause instanceof IOException ) 76 throw (IOException )cause; 77 if ( cause instanceof SAXException ) 78 throw (SAXException )cause; 79 throw new ProcessingException("Could not read resource " 80 + this.inputSource.getURI(), cause); 81 } 82 throw e; 83 } 84 } 85 86 } 87 | Popular Tags |