Class Annotator

java.lang.Object
org.eigenbase.xom.wrappers.Annotator

public class Annotator extends 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
  • Constructor Details

    • Annotator

      Annotator(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 Details

    • getLocation

      public Location getLocation(DOMWrapper wrapper)
    • getLocInfoList

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

      void parse(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(PrintWriter pw)