org.eigenbase.xom.wrappers
Class Annotator

java.lang.Object
  extended by 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
Author:
jhyde
 

Nested Class Summary
(package private)  class Annotator.LocInfo
           
 
Constructor Summary
Annotator(String xml, DOMWrapper def)
          Creates an Annotator.
 
Method Summary
(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)  List getLocInfoList()
          Returns the list of LocInfo.
(package private)  void list(PrintWriter pw)
           
(package private)  void parse(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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)

SourceForge.net_Logo