cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/formatter AbstractFormatter.java FO2PDFFormatter.java Formatter.java HTMLFormatter.java TextFormatter.java XMLFormatter.java VRMLFormatter.java WMLFormatter.java
Date Tue, 04 Apr 2000 11:11:18 GMT
stefano     00/04/04 04:11:18

  Modified:    src/org/apache/cocoon/formatter AbstractFormatter.java
                        FO2PDFFormatter.java Formatter.java
                        HTMLFormatter.java TextFormatter.java
                        XMLFormatter.java
  Removed:     src/org/apache/cocoon/formatter VRMLFormatter.java
                        WMLFormatter.java
  Log:
  non needed anymore
  
  Revision  Changes    Path
  1.3       +100 -12   xml-cocoon/src/org/apache/cocoon/formatter/AbstractFormatter.java
  
  Index: AbstractFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/AbstractFormatter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractFormatter.java	2000/02/13 18:29:20	1.2
  +++ AbstractFormatter.java	2000/04/04 11:11:16	1.3
  @@ -1,4 +1,4 @@
  -/*-- $Id: AbstractFormatter.java,v 1.2 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: AbstractFormatter.java,v 1.3 2000/04/04 11:11:16 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -50,26 +50,114 @@
    */
   package org.apache.cocoon.formatter;
   
  +import java.io.*;
   import java.util.*;
  +import org.w3c.dom.*;
   import org.apache.xml.serialize.*;
  +import org.apache.cocoon.framework.*;
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.2 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/04 11:11:16 $
    */
   
  -public abstract class AbstractFormatter implements Formatter {
  +public abstract class AbstractFormatter implements Configurable, Formatter, Status {
  + 
  +    protected String statusMessage = "Abstract Formatter";
  +    protected String MIMEtype;
  +    protected String encoding;
  +    protected String doctypePublic;
  +    protected String doctypeSystem;
  +    protected String indent;
  +    protected String lineWidth;
  +    protected String preserveSpace;
  +    protected OutputFormat format;
  +        
  +    public void init(Configurations conf) {
  +
  +        String mt = (String) conf.get("MIME-type");
  +        if (mt != null) {
  +            this.MIMEtype = mt;
  +        }
  +
  +        format = new OutputFormat();
  +        format.setPreserveSpace(true);
  +
  +        encoding = (String) conf.get("encoding");
  +        if (encoding != null) {
  +            format.setEncoding(encoding);
  +        }
  +
  +        doctypePublic = (String) conf.get("doctype-public");
  +        doctypeSystem = (String) conf.get("doctype-system");
  +        if (doctypeSystem != null) {
  +            format.setDoctype(doctypePublic, doctypeSystem);
  +        }
   
  -    public OutputFormat getFormat(Dictionary p) {
  -        String style = (String) p.get("style");
  -        OutputFormat format = new OutputFormat();
  -        if ((style != null) && (style.equals("compact"))) {
  -            format.setIndenting(false);
  -        } else {
  +        indent = (String) conf.get("indent");
  +        if (indent != null) {
               format.setIndenting(true);
  -            format.setIndent(1);
  -            format.setLineWidth(120);
  +            format.setIndent(Integer.parseInt(indent));
  +        }
  +
  +        preserveSpace = (String) conf.get("preserve-space");
  +        if (preserveSpace!= null) {
  +            format.setPreserveSpace(Boolean.getBoolean(preserveSpace));
           }
  -        return format;
  +        
  +        lineWidth = (String) conf.get("line-width");
  +        if (lineWidth != null) {
  +            format.setLineWidth(Integer.parseInt(lineWidth));
  +        }        
       }
  +
  +    public String getEncoding() {
  +        return encoding;
  +    }
  +
  +    public String getMIMEType() {
  +        return MIMEtype;
  +    }
  +    
  +    public String getStatus() {
  +        StringBuffer message = new StringBuffer();
  +        message.append(statusMessage);
  +        message.append("<br>");
  +        if (MIMEtype != null) {
  +            message.append("[ MIME type:  ");
  +            message.append(MIMEtype);
  +            message.append(" ]<br>");
  +        }
  +        if (encoding != null) {
  +            message.append("[ Encoding:  ");
  +            message.append(encoding);
  +            message.append(" ]<br>");
  +        }
  +        if (doctypeSystem != null) {
  +            message.append("[ Doctype:  ");
  +            if (doctypePublic != null) {
  +                message.append(doctypePublic);
  +                message.append(" ");
  +            }
  +            message.append(doctypeSystem);
  +            message.append(" ]<br>");
  +        }
  +        if (preserveSpace != null) {
  +            message.append("[ Preserve Space:  ");
  +            message.append(preserveSpace);
  +            message.append(" ]<br>");
  +        }
  +        if (indent != null) {
  +            message.append("[ Indent:  ");
  +            message.append(indent);
  +            message.append(" ]<br>");
  +        }
  +        if (lineWidth != null) {
  +            message.append("[ Line Width:  ");
  +            message.append(lineWidth);
  +            message.append(" ]<br>");
  +        }
  +        message.append("<br>");
  +        return message.toString();
  +    }       
   }
  
  
  
  1.3       +13 -13    xml-cocoon/src/org/apache/cocoon/formatter/FO2PDFFormatter.java
  
  Index: FO2PDFFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/FO2PDFFormatter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FO2PDFFormatter.java	2000/02/13 18:29:20	1.2
  +++ FO2PDFFormatter.java	2000/04/04 11:11:16	1.3
  @@ -1,4 +1,4 @@
  -/*-- $Id: FO2PDFFormatter.java,v 1.2 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: FO2PDFFormatter.java,v 1.3 2000/04/04 11:11:16 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -54,18 +54,26 @@
   import java.util.*;
   import org.w3c.dom.*;
   import org.apache.fop.apps.*;
  -import org.apache.cocoon.formatter.*;
   import org.apache.cocoon.framework.*;
   
   /**
  - * This class wraps around FOP classes to perform XSL:FO to PDF formatting.
  + * This class wraps around FOP to perform XSL:FO to PDF formatting.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.2 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/04 11:11:16 $
    */
   
  -public class FO2PDFFormatter implements Formatter, Status {
  +public class FO2PDFFormatter extends AbstractFormatter {
    
  +    public FO2PDFFormatter() {
  +        super.MIMEtype = "application/pdf";
  +        super.statusMessage = org.apache.fop.apps.Version.getVersion() + " formatter";
  +    }
  +        
  +    public void init(Configurations conf) {
  +        super.init(conf);
  +    }
  +
       public void format(Document document, Writer writer, Dictionary parameters) throws
Exception {
           Driver driver = new Driver();
           driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", org.apache.fop.apps.Version.getVersion());
  @@ -75,13 +83,5 @@
           driver.buildFOTree(document);
           driver.format();
           driver.render();
  -    }
  -    
  -    public String getMIMEType() {
  -        return "application/pdf";
  -    }
  -    
  -    public String getStatus() {
  -        return org.apache.fop.apps.Version.getVersion() + " formatter";
       }
   }
  
  
  
  1.5       +7 -2      xml-cocoon/src/org/apache/cocoon/formatter/Formatter.java
  
  Index: Formatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/Formatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Formatter.java	2000/02/13 18:29:20	1.4
  +++ Formatter.java	2000/04/04 11:11:16	1.5
  @@ -1,4 +1,4 @@
  -/*-- $Id: Formatter.java,v 1.4 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: Formatter.java,v 1.5 2000/04/04 11:11:16 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -59,7 +59,7 @@
    * into streams.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.4 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/04 11:11:16 $
    */
   
   public interface Formatter {
  @@ -68,6 +68,11 @@
        * Prints the give document into a page.
        */
       public void format(Document document, Writer writer, Dictionary parameters) throws
Exception;
  +
  +    /**
  +     * Returns the encoding used by this formatter for output.
  +     */
  +    public String getEncoding();
       
       /**
        * Returns the MIME type used by this formatter for output.
  
  
  
  1.5       +25 -24    xml-cocoon/src/org/apache/cocoon/formatter/HTMLFormatter.java
  
  Index: HTMLFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/HTMLFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HTMLFormatter.java	2000/02/13 18:29:20	1.4
  +++ HTMLFormatter.java	2000/04/04 11:11:16	1.5
  @@ -1,4 +1,4 @@
  -/*-- $Id: HTMLFormatter.java,v 1.4 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: HTMLFormatter.java,v 1.5 2000/04/04 11:11:16 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -57,34 +57,35 @@
   import org.apache.cocoon.framework.*;
   
   /**
  + * This formatter is used to serialize HTML content. The difference between
  + * this formatter and the XMLFormatter is that while the XML formatter doesn't
  + * have any semantic information about the document type being formatted,
  + * this class handles tags like <em>&lt;br/&gt;</em> and transforms
them to
  + * HTML that non-XML-aware browsers can understand. Can be imagined as 
  + * an XHTML->HTML adaptor, so use the XML formatter to print XHTML, not this
  + * class.
  + *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.4 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/04 11:11:16 $
    */
   
  -public class HTMLFormatter extends AbstractFormatter implements Status {
  +public class HTMLFormatter extends AbstractFormatter {
   
  -    private SerializerFactory factory;
  -        
  +    SerializerFactory factory;
  +
       public HTMLFormatter () {
           this.factory = SerializerFactory.getSerializerFactory(Method.HTML);
  -    }
  -
  -    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  -        OutputFormat format = super.getFormat(p);
  +        super.MIMEtype = "text/html";
  +        super.statusMessage = "HTML Formatter";
  +    }       
  +        
  +    public void init(Configurations conf) {
  +        super.init(conf);
           format.setMethod(Method.HTML);
           format.setOmitXMLDeclaration(true);
  -        format.setPreserveSpace(true);
  -        format.setDoctype("-//W3C//DTD HTML 4.0//EN", "http://www.w3.org/TR/REC-html40/strict.dtd");
  -        format.setVersion("4.0");
  -        Serializer serializer = factory.makeSerializer(writer, format);
  -        serializer.asDOMSerializer().serialize(document);
  -    }
  -
  -    public String getMIMEType() {
  -        return "text/html";
  -    }
  -    
  -    public String getStatus() {
  -        return "HTML Formatter";
  -    }
  -}
  \ No newline at end of file
  +    }       
  +        
  +    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  +        factory.makeSerializer(writer, format).asDOMSerializer().serialize(document);
  +    }       
  +}        
  \ No newline at end of file
  
  
  
  1.5       +13 -15    xml-cocoon/src/org/apache/cocoon/formatter/TextFormatter.java
  
  Index: TextFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/TextFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TextFormatter.java	2000/02/13 18:29:20	1.4
  +++ TextFormatter.java	2000/04/04 11:11:16	1.5
  @@ -1,4 +1,4 @@
  -/*-- $Id: TextFormatter.java,v 1.4 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: TextFormatter.java,v 1.5 2000/04/04 11:11:16 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -57,32 +57,30 @@
   import org.apache.cocoon.framework.*;
   
   /**
  + * This formatter is used to serialize non-marked-up results, such as 
  + * plain text outputs, VRML, CSS, etc..
  + *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.4 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/04 11:11:16 $
    */
   
  -public class TextFormatter extends AbstractFormatter implements Status {
  +public class TextFormatter extends AbstractFormatter {
   
  -    private SerializerFactory factory;
  +    SerializerFactory factory;
           
       public TextFormatter () {
           this.factory = SerializerFactory.getSerializerFactory(Method.TEXT);
  +        super.MIMEtype = "text/plain";
  +        super.statusMessage = "Text Formatter";
       }
   
  -    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  -        OutputFormat format = super.getFormat(p);
  +    public void init(Configurations conf) {
  +        super.init(conf);
           format.setMethod(Method.TEXT);
           format.setOmitXMLDeclaration(true);
  -        format.setPreserveSpace(true);
  -        Serializer serializer = this.factory.makeSerializer(writer, format);
  -        serializer.asDOMSerializer().serialize(document);
       }
   
  -    public String getMIMEType() {
  -        return "text/plain";
  -    }
  -    
  -    public String getStatus() {
  -        return "Text Formatter";
  +    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  +        factory.makeSerializer(writer, format).asDOMSerializer().serialize(document);
       }
   }
  
  
  
  1.5       +10 -16    xml-cocoon/src/org/apache/cocoon/formatter/XMLFormatter.java
  
  Index: XMLFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/XMLFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLFormatter.java	2000/02/13 18:29:20	1.4
  +++ XMLFormatter.java	2000/04/04 11:11:17	1.5
  @@ -1,4 +1,4 @@
  -/*-- $Id: XMLFormatter.java,v 1.4 2000/02/13 18:29:20 stefano Exp $ -- 
  +/*-- $Id: XMLFormatter.java,v 1.5 2000/04/04 11:11:17 stefano Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -58,32 +58,26 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.4 $ $Date: 2000/02/13 18:29:20 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/04 11:11:17 $
    */
   
  -public class XMLFormatter extends AbstractFormatter implements Status {
  +public class XMLFormatter extends AbstractFormatter {
   
  -    private SerializerFactory factory;
  +    SerializerFactory factory;
           
       public XMLFormatter () {
           this.factory = SerializerFactory.getSerializerFactory(Method.XML);
  +        super.MIMEtype = "text/xml";
  +        super.statusMessage = "XML Formatter";
       }
   
  -    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  -        OutputFormat format = super.getFormat(p);
  +    public void init(Configurations conf) {
  +        super.init(conf);
           format.setMethod(Method.XML);
           format.setOmitXMLDeclaration(false);
  -        format.setPreserveSpace(true);
  -        format.setVersion("1.0");
  -        Serializer serializer = this.factory.makeSerializer(writer, format);
  -        serializer.asDOMSerializer().serialize(document);
       }
   
  -    public String getMIMEType() {
  -        return "text/xml";
  -    }
  -    
  -    public String getStatus() {
  -        return "XML Formatter";
  +    public void format(Document document, Writer writer, Dictionary p) throws Exception
{
  +        factory.makeSerializer(writer, format).asDOMSerializer().serialize(document);
       }
   }
  
  
  

Mime
View raw message