LineCountEmitter
Date: 2016-07-03

com.nwalsh.saxon

## Class LineCountEmitter

- java.lang.Object
- - com.icl.saxon.output.Emitter
  - - com.nwalsh.saxon.LineCountEmitter

- All Implemented Interfaces:
    javax.xml.transform.Result

      public class LineCountEmitter
      extends com.icl.saxon.output.Emitter

  Saxon extension to count the lines in a result tree fragment.

  $Id: LineCountEmitter.java 5907 2006-04-27 08:26:47Z xmldoc $

  Copyright (C) 2000 Norman Walsh.

  This class provides a Saxon 6.* implementation to count the number of lines in a result tree fragment.

  The general design is this: the stylesheets construct a result tree fragment for some verbatim environment. That result tree fragment is "replayed" through the LineCountEmitter; the LineCountEmitter watches characters go by and counts the number of line feeds that it sees. That number is then returned.

  Change Log:

  1.0

    Initial release.

  See Also:
    `Verbatim`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `numLines` The number of lines seen.

    - ### Fields inherited from class com.icl.saxon.output.Emitter

      `locator, namePool, outputProperties, outputStream, systemId, writer`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LineCountEmitter()` Construct a new LineCountEmitter.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(char[] chars, int start, int len)` Process characters.
    `void` | `comment(char[] chars, int start, int length)` Discarded.
    `void` | `endDocument()` Discarded.
    `void` | `endElement(int nameCode)` Discarded.
    `int` | `lineCount()` Return the number of lines.
    `void` | `processingInstruction(java.lang.String name, java.lang.String data)` Discarded.
    `void` | `reset()` Reset the number of lines.
    `void` | `setDocumentLocator(org.xml.sax.Locator locator)` Discarded.
    `void` | `setEscaping(boolean escaping)` Discarded.
    `void` | `setNamePool(com.icl.saxon.om.NamePool namePool)` Discarded.
    `void` | `setUnparsedEntity(java.lang.String name, java.lang.String uri)` Discarded.
    `void` | `setWriter(java.io.Writer writer)` Discarded.
    `void` | `startDocument()` Discarded.
    `void` | `startElement(int nameCode, org.xml.sax.Attributes attributes, int[] namespaces, int nscount)` Discarded.

    - ### Methods inherited from class com.icl.saxon.output.Emitter

      `getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, setOutputProperties, setOutputStream, setSystemId, usesWriter`

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

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

- - ### Field Detail

    - #### numLines

          protected int numLines

      The number of lines seen.

  - ### Constructor Detail

    - #### LineCountEmitter

          public LineCountEmitter()

      Construct a new LineCountEmitter.

  - ### Method Detail

    - #### reset

          public void reset()

      Reset the number of lines.

    - #### lineCount

          public int lineCount()

      Return the number of lines.

    - #### characters

          public void characters(char[] chars,
                        int start,
                        int len)
                          throws javax.xml.transform.TransformerException

      Process characters.
      Specified by:
        `characters` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### comment

          public void comment(char[] chars,
                     int start,
                     int length)
                       throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `comment` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### endDocument

          public void endDocument()
                           throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `endDocument` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### endElement

          public void endElement(int nameCode)
                          throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `endElement` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### processingInstruction

          public void processingInstruction(java.lang.String name,
                                   java.lang.String data)
                                     throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `processingInstruction` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### setDocumentLocator

          public void setDocumentLocator(org.xml.sax.Locator locator)

      Discarded.
      Overrides:
        `setDocumentLocator` in class `com.icl.saxon.output.Emitter`

    - #### setEscaping

          public void setEscaping(boolean escaping)
                           throws javax.xml.transform.TransformerException

      Discarded.
      Overrides:
        `setEscaping` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### setNamePool

          public void setNamePool(com.icl.saxon.om.NamePool namePool)

      Discarded.
      Overrides:
        `setNamePool` in class `com.icl.saxon.output.Emitter`

    - #### setUnparsedEntity

          public void setUnparsedEntity(java.lang.String name,
                               java.lang.String uri)
                                 throws javax.xml.transform.TransformerException

      Discarded.
      Overrides:
        `setUnparsedEntity` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### setWriter

          public void setWriter(java.io.Writer writer)

      Discarded.
      Overrides:
        `setWriter` in class `com.icl.saxon.output.Emitter`

    - #### startDocument

          public void startDocument()
                             throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `startDocument` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### startElement

          public void startElement(int nameCode,
                          org.xml.sax.Attributes attributes,
                          int[] namespaces,
                          int nscount)
                            throws javax.xml.transform.TransformerException

      Discarded.
      Specified by:
        `startElement` in class `com.icl.saxon.output.Emitter`
      Throws:
        `javax.xml.transform.TransformerException`