Class Annotator


  • public class Annotator
    extends java.lang.Object
    Quick and dirty XML parser that finds the precise start and end position of all nodes in a document. Also finds all line endings, so that character offsets can be converted to line/column positions.
    Since:
    13 October, 2008
    Version:
    $Id: //open/util/resgen/src/org/eigenbase/xom/wrappers/Annotator.java#4 $
    Author:
    jhyde
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  Annotator.LocInfo  
    • Constructor Summary

      Constructors 
      Constructor Description
      Annotator​(java.lang.String xml, DOMWrapper def)
      Creates an Annotator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int getCol​(int pos)
      Returns the column that a character position falls on.
      (package private) int getLine​(int pos)
      Returns the line that a character position falls on.
      Location getLocation​(DOMWrapper wrapper)  
      (package private) java.util.List getLocInfoList()
      Returns the list of LocInfo.
      (package private) void list​(java.io.PrintWriter pw)  
      (package private) void parse​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Annotator

        Annotator​(java.lang.String xml,
                  DOMWrapper def)
        Creates an Annotator.

        For testing purposes, wrapper may be null. Parses the XML but does not build the mapping from location information to DOM nodes.

        Parameters:
        xml - XML source string
        def - Wrapper around root DOM node
    • Method Detail

      • getLocInfoList

        java.util.List getLocInfoList()
        Returns the list of LocInfo. For testing.
        Returns:
        list of LocInfo.
      • parse

        void parse​(java.lang.String s)
      • getLine

        int getLine​(int pos)
        Returns the line that a character position falls on. The first line in a document is numbered 0.
        Parameters:
        pos - Character position
        Returns:
        Line (starting from 0)
      • getCol

        int getCol​(int pos)
        Returns the column that a character position falls on. The first column in a line is numbered 0.
        Parameters:
        pos - Character position
        Returns:
        column (starting from 0)
      • list

        void list​(java.io.PrintWriter pw)