com.nwalsh.saxon
Class LineCountEmitter

java.lang.Object
  extended bycom.icl.saxon.output.Emitter
      extended bycom.nwalsh.saxon.LineCountEmitter
All Implemented Interfaces:
Result

public class LineCountEmitter
extends Emitter

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

$Id: LineCountEmitter.java,v 1.1 2001/07/16 21:23:57 nwalsh Exp $

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.

Version:
$Id: LineCountEmitter.java,v 1.1 2001/07/16 21:23:57 nwalsh Exp $
Author:
Norman Walsh ndw@nwalsh.com
See Also:
Verbatim

Field Summary
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
LineCountEmitter()
          Construct a new LineCountEmitter.
 
Method Summary
 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(String name, String data)
          Discarded.
 void reset()
          Reset the number of lines.
 void setDocumentLocator(Locator locator)
          Discarded.
 void setEscaping(boolean escaping)
          Discarded.
 void setNamePool(NamePool namePool)
          Discarded.
 void setUnparsedEntity(String name, String uri)
          Discarded.
 void setWriter(Writer writer)
          Discarded.
 void startDocument()
          Discarded.
 void startElement(int nameCode, 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 TransformerException
Process characters.

Throws:
TransformerException

comment

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

Throws:
TransformerException

endDocument

public void endDocument()
                 throws TransformerException
Discarded.

Throws:
TransformerException

endElement

public void endElement(int nameCode)
                throws TransformerException
Discarded.

Throws:
TransformerException

processingInstruction

public void processingInstruction(String name,
                                  String data)
                           throws TransformerException
Discarded.

Throws:
TransformerException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Discarded.


setEscaping

public void setEscaping(boolean escaping)
                 throws TransformerException
Discarded.

Throws:
TransformerException

setNamePool

public void setNamePool(NamePool namePool)
Discarded.


setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri)
                       throws TransformerException
Discarded.

Throws:
TransformerException

setWriter

public void setWriter(Writer writer)
Discarded.


startDocument

public void startDocument()
                   throws TransformerException
Discarded.

Throws:
TransformerException

startElement

public void startElement(int nameCode,
                         Attributes attributes,
                         int[] namespaces,
                         int nscount)
                  throws TransformerException
Discarded.

Throws:
TransformerException