net.sf.joost.emitter
Class HtmlEmitter

java.lang.Object
  extended by net.sf.joost.emitter.StxEmitterBase
      extended by net.sf.joost.emitter.StreamEmitter
          extended by net.sf.joost.emitter.HtmlEmitter
All Implemented Interfaces:
Constants, StxEmitter, ContentHandler, LexicalHandler

public class HtmlEmitter
extends StreamEmitter

This class implements an emitter for html code.

Version:
$Revision: 1.6 $ $Date: 2008/10/06 13:31:41 $
Author:
Thomas Behrends

Field Summary
private  boolean disabledOutputEscaping
           
private static HashSet emptyHTMLElements
          Empty HTML 4.01 elements according to http://www.w3.org/TR/1999/REC-html401-19991224/index/elements.html
private  boolean insideCDATA
           
private  boolean propOmitXmlDeclaration
          output property: omit-xml-declaration
private  boolean supportDisableOutputEscaping
           
 
Fields inherited from class net.sf.joost.emitter.StreamEmitter
charsetEncoder, encoding, writer
 
Fields inherited from interface net.sf.joost.Constants
DEBUG, DEFAULT_ENCODING, FEAT_NS, FEAT_NSPREFIX, FEATURE_URI_PREFIX, FUNC_NS, JOOST_EXT_NS, PR_ATTRIBUTES, PR_BUFFER, PR_CHILDREN, PR_CONTINUE, PR_ERROR, PR_SELF, PR_SIBLINGS, STX_NS
 
Constructor Summary
HtmlEmitter(Writer writer, String encoding)
          Constructor
 
Method Summary
 void characters(char[] ch, int start, int length)
          SAX2-Callback - Constructs characters.
 void comment(char[] ch, int start, int length)
          SAX2-Callback - Outputs a comment
 void endCDATA()
          Does nothing
 void endDocument()
          SAX2-Callback - Closing OutputStream.
 void endElement(String uri, String lName, String qName)
          SAX2-Callback - Outputs the element-tag.
 void processingInstruction(String target, String data)
          SAX2-Callback - Handles a PI (cares about disable-output-escaping)
 void setOmitXmlDeclaration(boolean flag)
          Defines whether the XML declaration should be omitted, default is false.
 void setSupportDisableOutputEscaping(boolean flag)
          Defines whether disable-output-escaping will be supported (means whether the corresponding processing instructions Result.PI_DISABLE_OUTPUT_ESCAPING and Result.PI_ENABLE_OUTPUT_ESCAPING will be interpreted).
 void startCDATA()
          CDATA sections will be handled like "disable-output-escaping" in HTML (which is of course a kind of a "hack" ...)
 void startDocument()
          SAX2-Callback - Outputs XML-Deklaration with encoding.
 void startElement(String uri, String lName, String qName, Attributes attrs)
          SAX2-Callback
 
Methods inherited from class net.sf.joost.emitter.StreamEmitter
encodeCharacters, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, newEmitter, newEmitter, newEmitter, newXMLEmitter, setDocumentLocator, skippedEntity, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class net.sf.joost.emitter.StxEmitterBase
getSystemId, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propOmitXmlDeclaration

private boolean propOmitXmlDeclaration
output property: omit-xml-declaration


insideCDATA

private boolean insideCDATA

supportDisableOutputEscaping

private boolean supportDisableOutputEscaping

disabledOutputEscaping

private boolean disabledOutputEscaping

emptyHTMLElements

private static final HashSet emptyHTMLElements
Empty HTML 4.01 elements according to http://www.w3.org/TR/1999/REC-html401-19991224/index/elements.html

Constructor Detail

HtmlEmitter

public HtmlEmitter(Writer writer,
                   String encoding)
Constructor

Method Detail

setOmitXmlDeclaration

public void setOmitXmlDeclaration(boolean flag)
Defines whether the XML declaration should be omitted, default is false.

Overrides:
setOmitXmlDeclaration in class StreamEmitter
Parameters:
flag - true: the XML declaration will be omitted; false: the XML declaration will be output

setSupportDisableOutputEscaping

public void setSupportDisableOutputEscaping(boolean flag)
Description copied from class: StreamEmitter
Defines whether disable-output-escaping will be supported (means whether the corresponding processing instructions Result.PI_DISABLE_OUTPUT_ESCAPING and Result.PI_ENABLE_OUTPUT_ESCAPING will be interpreted). The default is false

Overrides:
setSupportDisableOutputEscaping in class StreamEmitter
Parameters:
flag - true the PIs will be interpreted; false the PIs will be written literally

startDocument

public void startDocument()
                   throws SAXException
SAX2-Callback - Outputs XML-Deklaration with encoding.

Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
SAX2-Callback - Closing OutputStream.

Throws:
SAXException

startElement

public void startElement(String uri,
                         String lName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
SAX2-Callback

Throws:
SAXException

endElement

public void endElement(String uri,
                       String lName,
                       String qName)
                throws SAXException
SAX2-Callback - Outputs the element-tag.

Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
SAX2-Callback - Constructs characters.

Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
SAX2-Callback - Outputs a comment

Specified by:
comment in interface LexicalHandler
Overrides:
comment in class StreamEmitter
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
SAX2-Callback - Handles a PI (cares about disable-output-escaping)

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class StreamEmitter
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
CDATA sections will be handled like "disable-output-escaping" in HTML (which is of course a kind of a "hack" ...)

Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in class StreamEmitter
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Description copied from class: StreamEmitter
Does nothing

Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in class StreamEmitter
Throws:
SAXException