Writer (NekoHTML 1.9.20 Implementation)
Date: 2014-02-13

org.cyberneko.html.filters

## Class Writer

- java.lang.Object
- - org.cyberneko.html.filters.DefaultFilter
  - - org.cyberneko.html.filters.Writer

- All Implemented Interfaces:
    HTMLComponent

      public class Writer
      extends DefaultFilter

  An HTML writer written as a filter. Besides serializing the HTML event stream, the writer also passes the document events to the next stage in the pipeline. This allows applications to insert writer filters between other custom filters for debugging purposes.

  Since an HTML document may have specified its encoding using the <META> tag and http-equiv/content attributes, the writer will automatically change any character set specified in this tag to match the encoding of the output stream. Therefore, the character encoding name used to construct the writer should be an official IANA encoding name and not a Java encoding name.

  Note: The modified character set in the <META> tag is not propagated to the next stage in the pipeline. The changed value is only output to the stream; the original value is sent to the next stage in the pipeline.

  Version:
    $Id: Writer.java,v 1.7 2005/02/14 04:01:33 andyc Exp $
  Author:
    Andy Clark

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `AUGMENTATIONS` Augmentations feature identifier.
    `protected int` | `fElementDepth` Element depth.
    `protected java.lang.String` | `fEncoding` The encoding.
    `protected static java.lang.String` | `FILTERS` Filters property identifier.
    `protected boolean` | `fNormalize` Normalize character content.
    `protected boolean` | `fPrintChars` Print characters.
    `protected java.io.PrintWriter` | `fPrinter` The print writer used for serializing the document with the appropriate character encoding.
    `protected boolean` | `fSeenHttpEquiv` Seen http-equiv directive.
    `protected boolean` | `fSeenRootElement` Seen root element.
    `static java.lang.String` | `NOTIFY_CHAR_REFS` Notify character entity references.
    `static java.lang.String` | `NOTIFY_HTML_BUILTIN_REFS` Notify built-in entity references.

    - ### Fields inherited from class org.cyberneko.html.filters.DefaultFilter

      `fDocumentHandler, fDocumentSource`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Writer()` Constructs a writer filter that prints to standard out.
    `Writer(java.io.OutputStream outputStream, java.lang.String encoding)` Constructs a writer filter using the specified output stream and encoding.
    `Writer(java.io.Writer writer, java.lang.String encoding)` Constructs a writer filter using the specified Java writer and encoding.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(XMLString text, Augmentations augs)` Characters.
    `void` | `comment(XMLString text, Augmentations augs)` Comment.
    `void` | `emptyElement(QName element, XMLAttributes attributes, Augmentations augs)` Empty element.
    `void` | `endElement(QName element, Augmentations augs)` End element.
    `void` | `endGeneralEntity(java.lang.String name, Augmentations augs)` End general entity.
    `static void` | `main(java.lang.String[] argv)` Main.
    `protected void` | `printAttributeValue(java.lang.String text)` Print attribute value.
    `protected void` | `printCharacters(XMLString text, boolean normalize)` Print characters.
    `protected void` | `printEndElement(QName element)` Print end element.
    `protected void` | `printEntity(java.lang.String name)` Print entity.
    `protected void` | `printStartElement(QName element, XMLAttributes attributes)` Print start element.
    `void` | `startDocument(XMLLocator locator, java.lang.String encoding, Augmentations augs)` Start document.
    `void` | `startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs)` Start document.
    `void` | `startElement(QName element, XMLAttributes attributes, Augmentations augs)` Start element.
    `void` | `startGeneralEntity(java.lang.String name, XMLResourceIdentifier id, java.lang.String encoding, Augmentations augs)` Start general entity.

    - ### Methods inherited from class org.cyberneko.html.filters.DefaultFilter

      `doctypeDecl, endCDATA, endDocument, endPrefixMapping, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, ignorableWhitespace, merge, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, startPrefixMapping, textDecl, xmlDecl`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NOTIFY_CHAR_REFS

          public static final java.lang.String NOTIFY_CHAR_REFS

      Notify character entity references.
      See Also:
        Constant Field Values

    - #### NOTIFY_HTML_BUILTIN_REFS

          public static final java.lang.String NOTIFY_HTML_BUILTIN_REFS

      Notify built-in entity references.
      See Also:
        Constant Field Values

    - #### AUGMENTATIONS

          protected static final java.lang.String AUGMENTATIONS

      Augmentations feature identifier.
      See Also:
        Constant Field Values

    - #### FILTERS

          protected static final java.lang.String FILTERS

      Filters property identifier.
      See Also:
        Constant Field Values

    - #### fEncoding

          protected java.lang.String fEncoding

      The encoding.

    - #### fPrinter

          protected java.io.PrintWriter fPrinter

      The print writer used for serializing the document with the appropriate character encoding.

    - #### fSeenRootElement

          protected boolean fSeenRootElement

      Seen root element.

    - #### fSeenHttpEquiv

          protected boolean fSeenHttpEquiv

      Seen http-equiv directive.

    - #### fElementDepth

          protected int fElementDepth

      Element depth.

    - #### fNormalize

          protected boolean fNormalize

      Normalize character content.

    - #### fPrintChars

          protected boolean fPrintChars

      Print characters.

  - ### Constructor Detail

    - #### Writer

          public Writer()

      Constructs a writer filter that prints to standard out.

    - #### Writer

          public Writer(java.io.OutputStream outputStream,
                java.lang.String encoding)
                 throws java.io.UnsupportedEncodingException

      Constructs a writer filter using the specified output stream and encoding.
      Parameters:
        `outputStream` - The output stream to write to.
        `encoding` - The encoding to be used for the output. The encoding name should be an official IANA encoding name.
      Throws:
        `java.io.UnsupportedEncodingException`

    - #### Writer

          public Writer(java.io.Writer writer,
                java.lang.String encoding)

      Constructs a writer filter using the specified Java writer and encoding.
      Parameters:
        `writer` - The Java writer to write to.
        `encoding` - The encoding to be used for the output. The encoding name should be an official IANA encoding name.

  - ### Method Detail

    - #### startDocument

          public void startDocument(XMLLocator locator,
                           java.lang.String encoding,
                           NamespaceContext nscontext,
                           Augmentations augs)
                             throws XNIException

      Start document.
      Overrides:
        `startDocument` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### startDocument

          public void startDocument(XMLLocator locator,
                           java.lang.String encoding,
                           Augmentations augs)
                             throws XNIException

      Start document.
      Overrides:
        `startDocument` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### comment

          public void comment(XMLString text,
                     Augmentations augs)
                       throws XNIException

      Comment.
      Overrides:
        `comment` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### startElement

          public void startElement(QName element,
                          XMLAttributes attributes,
                          Augmentations augs)
                            throws XNIException

      Start element.
      Overrides:
        `startElement` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### emptyElement

          public void emptyElement(QName element,
                          XMLAttributes attributes,
                          Augmentations augs)
                            throws XNIException

      Empty element.
      Overrides:
        `emptyElement` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### characters

          public void characters(XMLString text,
                        Augmentations augs)
                          throws XNIException

      Characters.
      Overrides:
        `characters` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### endElement

          public void endElement(QName element,
                        Augmentations augs)
                          throws XNIException

      End element.
      Overrides:
        `endElement` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### startGeneralEntity

          public void startGeneralEntity(java.lang.String name,
                                XMLResourceIdentifier id,
                                java.lang.String encoding,
                                Augmentations augs)
                                  throws XNIException

      Start general entity.
      Overrides:
        `startGeneralEntity` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### endGeneralEntity

          public void endGeneralEntity(java.lang.String name,
                              Augmentations augs)
                                throws XNIException

      End general entity.
      Overrides:
        `endGeneralEntity` in class `DefaultFilter`
      Throws:
        `XNIException`

    - #### printAttributeValue

          protected void printAttributeValue(java.lang.String text)

      Print attribute value.

    - #### printCharacters

          protected void printCharacters(XMLString text,
                             boolean normalize)

      Print characters.

    - #### printStartElement

          protected void printStartElement(QName element,
                               XMLAttributes attributes)

      Print start element.

    - #### printEndElement

          protected void printEndElement(QName element)

      Print end element.

    - #### printEntity

          protected void printEntity(java.lang.String name)

      Print entity.

    - #### main

          public static void main(java.lang.String[] argv)
                           throws java.lang.Exception

      Main.
      Throws:
        `java.lang.Exception`

(C) Copyright 2002-2014, Andy Clark, Marc Guillemot. All rights reserved.