edu.byu.deg.ontos
Class DOMString

java.lang.Object
  extended byedu.byu.deg.ontos.DOMString
All Implemented Interfaces:
CharSequence

public class DOMString
extends Object
implements CharSequence

Wraps a dom tree so it can be matched with regular expressions like a string. Still needs to implement getXPathFor() method.


Field Summary
(package private)  int baseOffset
           
(package private)  int lastIndex
           
(package private)  String lastString
           
(package private)  int length
           
(package private)  ArrayList nodes
           
(package private)  int nodesIndexed
           
(package private)  int[] offsets
           
(package private)  int remainder
           
(package private)  ArrayList strings
           
 
Constructor Summary
DOMString(Node rootNode)
          Creates a new instance of DOMString
 
Method Summary
 char charAt(int offset)
          Method to retrieve a character from the virtual string
 int getEndOf(Node node)
          Returns the ending character offset of the given DOM node.
 Node getFirstText()
          Returns the earliest DOM node in the document, or null if the document is empty.
 int getLastRemainder()
          Returns the index of the offset within the String or Node returned by the last getNodeFor(int) or getStringAt(int) method call.
 Node getNodeFor(int offset)
          Returns the Node which contains the text at the given offset.
 int getRelativeStartOfLastString()
           
 int getStartOf(Node node)
          Returns the starting character offset of the given DOM node.
 String getStringAt(int offset)
          Returns the String which contains the text at the given offset.
 String getXPathFor(int offset)
          Calculates the XPath of the node at the given offset.
 int length()
          Method to return the length of the virtual string
 CharSequence subSequence(int start, int end)
          Returns a DOMString representing the given subsequence.
 DOMString subString(int start)
          Returns a DOMString beginning at the given offset and continuing to the end of this DOMString
 DOMString subString(int start, int end)
          Returns a DOMString representing the given subsequence.
 String toString()
          Returns a string representation of the contents of the DOMString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

offsets

int[] offsets

nodes

ArrayList nodes

strings

ArrayList strings

length

int length

nodesIndexed

int nodesIndexed

remainder

int remainder

lastIndex

int lastIndex

baseOffset

int baseOffset

lastString

String lastString
Constructor Detail

DOMString

public DOMString(Node rootNode)
Creates a new instance of DOMString

Parameters:
rootNode - The DOM tree root to wrap
Method Detail

getStartOf

public int getStartOf(Node node)
Returns the starting character offset of the given DOM node.

Parameters:
node - A node in the DOM tree.
Returns:
The 0-based starting offset of the node in question, relative to the start of the document.

getEndOf

public int getEndOf(Node node)
Returns the ending character offset of the given DOM node.

Parameters:
node - A node in the DOM tree.
Returns:
The 0-based ending offset of the node in question, relative to the start of the document.

charAt

public char charAt(int offset)
Method to retrieve a character from the virtual string

Specified by:
charAt in interface CharSequence
Parameters:
offset - offset of the char to return
Returns:
the char at the given offset

length

public int length()
Method to return the length of the virtual string

Specified by:
length in interface CharSequence
Returns:
the length of the virtual string contained in the DOMString

subSequence

public CharSequence subSequence(int start,
                                int end)
Returns a DOMString representing the given subsequence.

Specified by:
subSequence in interface CharSequence
Parameters:
start - starting offset of the new DOMString
end - ending offset of the new DOMString
Returns:
A new DOMString containing the given subsequence

subString

public DOMString subString(int start,
                           int end)
Returns a DOMString representing the given subsequence.

Parameters:
start - starting offset of the new DOMString
end - ending offset of the new DOMString
Returns:
A new DOMString containing the given subsequence

subString

public DOMString subString(int start)
Returns a DOMString beginning at the given offset and continuing to the end of this DOMString

Parameters:
start - starting offset of the new DOMString
Returns:
A new DOMString containing the given subsequence

getNodeFor

public Node getNodeFor(int offset)
Returns the Node which contains the text at the given offset.

Parameters:
offset - the offset
Returns:
The Node

getXPathFor

public String getXPathFor(int offset)
Calculates the XPath of the node at the given offset. Not yet implemented.

Parameters:
offset - the offset
Returns:
A String representing the location of the offset in the DOM tree

getLastRemainder

public int getLastRemainder()
Returns the index of the offset within the String or Node returned by the last getNodeFor(int) or getStringAt(int) method call.

Returns:
Returns the last remainder

getStringAt

public String getStringAt(int offset)
Returns the String which contains the text at the given offset.

Parameters:
offset - the offset
Returns:
the string that contains the text at the offset

toString

public String toString()
Returns a string representation of the contents of the DOMString

Specified by:
toString in interface CharSequence
Returns:
the string

getFirstText

public Node getFirstText()
Returns the earliest DOM node in the document, or null if the document is empty.

Returns:
The first node in the document.

getRelativeStartOfLastString

public int getRelativeStartOfLastString()
Returns: