org.apache.cocoon.generation.asciiart
Class AsciiArtSVGGenerator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.generation.AbstractGenerator
              extended by org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator
All Implemented Interfaces:
Poolable, Recyclable, Component, LogEnabled, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer

public class AsciiArtSVGGenerator
extends AbstractGenerator
implements CacheableProcessingComponent

A simple AsciiArt text SVG XML generator.

Since:
Cocoon 2.1, 22 December 2002
Version:
CVS $Id: AsciiArtSVGGenerator.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Bernhard Huber

Field Summary
protected  Source inputSource
          The input source
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
AsciiArtSVGGenerator()
           
 
Method Summary
protected  void addAttribute(String nodeName, String nodeValue)
          Adds a feature to the Attribute attribute of the MailXMLSerializer object
protected  void characters(String s)
          SAX character helper
protected  void endElement(String nodeName)
          SAX endElement helper
 void generate()
          Generate XML data.
protected  void generateSVGLineElements()
          Generate SVG path elements.
protected  void generateSVGTextElements()
          Generate SVG text elements.
 Serializable getKey()
          Generate the unique key.
 SourceValidity getValidity()
          Generate the validity object.
protected  String[] readAsciiArt()
          Read the ascii art from the input source.
 void recycle()
          Recycle this component.
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Setup the AsciiArtSVG generator.
protected  void startElement(String nodeName, Attributes attributes)
          SAX startElement helper
 
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.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

inputSource

protected Source inputSource
The input source

Constructor Detail

AsciiArtSVGGenerator

public AsciiArtSVGGenerator()
Method Detail

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Setup the AsciiArtSVG generator. Try to get the last modification date of the source for caching.

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractGenerator
Parameters:
resolver - Cocoon's resolver
objectModel - Cocoon's objectModel
src - generator's src attribute
par - sitemap parameters
Throws:
ProcessingException - setup fails
SAXException - sax generation fails
IOException - general io fails

recycle

public void recycle()
Recycle this component. All instance variables are set to null.

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractGenerator

getKey

public Serializable getKey()
Generate the unique key. This key must be unique inside the space of this component.

Specified by:
getKey in interface CacheableProcessingComponent
Returns:
The generated key hashes the src

getValidity

public SourceValidity getValidity()
Generate the validity object.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

generate

public void generate()
              throws IOException,
                     SAXException,
                     ProcessingException
Generate XML data.

Specified by:
generate in interface Generator
Throws:
IOException
SAXException
ProcessingException

readAsciiArt

protected String[] readAsciiArt()
                         throws IOException
Read the ascii art from the input source.

Returns:
String[] describing the ascii art
Throws:
IOException - reading the ascii art fails

generateSVGLineElements

protected void generateSVGLineElements()
                                throws SAXException
Generate SVG path elements. The SVG path elements are generated from ascii art lines.

Throws:
SAXException - iff SAX generation fails.

generateSVGTextElements

protected void generateSVGTextElements()
                                throws SAXException
Generate SVG text elements. The SVG text elements are generated from ascii art string.

Throws:
SAXException - iff SAX generation fails.

startElement

protected void startElement(String nodeName,
                            Attributes attributes)
                     throws SAXException
SAX startElement helper

Parameters:
nodeName - name of the element's name
attributes - of the node
Throws:
SAXException - iff SAX generation fails

characters

protected void characters(String s)
                   throws SAXException
SAX character helper

Parameters:
s - Description of the Parameter
Throws:
SAXException - iff SAX generation fails

endElement

protected void endElement(String nodeName)
                   throws SAXException
SAX endElement helper

Parameters:
nodeName - name of the element's name
Throws:
SAXException - iff SAX generation fails

addAttribute

protected void addAttribute(String nodeName,
                            String nodeValue)
Adds a feature to the Attribute attribute of the MailXMLSerializer object

Parameters:
nodeName - name of the attriute's name
nodeValue - value of the attribute


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.