sk.uniba.euromath.document
Class IdDomMapper

java.lang.Object
  extended by sk.uniba.euromath.document.IdDomMapper

public final class IdDomMapper
extends Object

Contains functions that maps nodes from 'ID' level to 'DOM' level and backwards.

Author:
Martin Vysny

Field Summary
(package private)  DomCore doc
          The document reference.
 
Constructor Summary
IdDomMapper(DomCore doc)
          Package-internal constructor.
 
Method Summary
 DomPointer getEndBoundary(Element parent, int index)
          Returns the pointer pointing after the last DOM-level node that makes up the ID-level index.
 DomPointer getEndBoundary(Node node)
          Returns the pointer pointing after the last DOM-level node that makes up the ID-level index where given node belongs.
static int getIdIndexFromNode(Node node)
          Determines the index of the node in the ID-level document.
 Node getNextIdNode(Node node)
          Returns next node that is not part of ID-level node which contains given node.
 Node getNextNode(Node node)
          Returns next non-entity node sibling.
 DomPointer getNextNodePtr(DomPointer ptr)
          Returns next non-entity node.
 Node getNodeFromIdIndex(Node parent, int index)
          Computes and returns the node in DOM level that would have given index in ID level.
 NodeListID getNodeList(Node node)
          Provides mapping functions more specific to given node.
static Node getPrevIdNode(Node node)
          Returns previous node that is not part of ID-level node which contains given node.
static Node getPrevNode(Node node)
          Returns previous non-entity node.
 DomPointer getStartBoundary(Element parent, int index)
          Returns the pointer pointing onto the first DOM-level node that makes up the ID-level index.
 DomPointer getStartBoundary(Node node)
          Returns the pointer pointing onto the first DOM-level node that makes up the ID-level index where given node belongs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

final DomCore doc
The document reference.

Constructor Detail

IdDomMapper

IdDomMapper(DomCore doc)
Package-internal constructor.

Parameters:
doc - the document instance.
Method Detail

getNodeFromIdIndex

public Node getNodeFromIdIndex(Node parent,
                               int index)
Computes and returns the node in DOM level that would have given index in ID level.

Parameters:
parent - the DOM-level node. It may be element or document node.
index - the index of the node in ID level.
Returns:
DOM-level node with ID-level index index. If the ID-level index spans over multiple DOM-level nodes then the first DOM-level node is returned. If the index is invalid then null is returned.

getIdIndexFromNode

public static int getIdIndexFromNode(Node node)
Determines the index of the node in the ID-level document.

Parameters:
node - the node from DOM-level document. In case of entity reference the function shall check for ID-level index of first id-capable node contained in this entity reference.
Returns:
the index of the node in the ID-level document. Note that when the node is a text then the index may identify multiple consecutive text nodes including given node. If an empty entity is given then -1 is returned.

getPrevNode

public static Node getPrevNode(Node node)
Returns previous non-entity node. It does not go into nor outside elements. If there is no previous node then the result is null.

Parameters:
node - the node.
Returns:
previous node or null.

getNextNode

public Node getNextNode(Node node)
Returns next non-entity node sibling. It does not go into nor outside elements. If there is no next node then returns null.

Parameters:
node - the node.
Returns:
next node or null.

getNextIdNode

public Node getNextIdNode(Node node)
Returns next node that is not part of ID-level node which contains given node. If there is no next node then returns null.

Parameters:
node - the DOM-level node
Returns:
if node is not textual then this function is equivalent to getNextNode function, otherwise it search for first non-text DOM-level node.

getPrevIdNode

public static Node getPrevIdNode(Node node)
Returns previous node that is not part of ID-level node which contains given node. If there is no previous node then returns null.

Parameters:
node - the DOM-level node
Returns:
if node is not textual then this function is equivalent to getPrevNode function, otherwise it search for first non-text DOM-level node.

getNextNodePtr

public DomPointer getNextNodePtr(DomPointer ptr)
Returns next non-entity node. It does not go into elements. If there is no next node then returns null.

Parameters:
ptr - the pointer to node.
Returns:
pointer to next node or null.

getStartBoundary

public DomPointer getStartBoundary(Element parent,
                                   int index)
Returns the pointer pointing onto the first DOM-level node that makes up the ID-level index.

Parameters:
parent - the parent from the DOM-level.
index - the index of an ID-level node.
Returns:
farest previous node with same type not separated from this node by a node with different type. Entity reference node types are ignored and text is considered to have same node type as cdata.

getStartBoundary

public DomPointer getStartBoundary(Node node)
Returns the pointer pointing onto the first DOM-level node that makes up the ID-level index where given node belongs.

Parameters:
node - the DOM-level node
Returns:
farest previous node with same type not separated from this node by a node with different type. Entity reference node types are ignored and text is considered to have same node type as cdata.

getEndBoundary

public DomPointer getEndBoundary(Element parent,
                                 int index)
Returns the pointer pointing after the last DOM-level node that makes up the ID-level index.

Parameters:
parent - the parent from the DOM-level.
index - the index of the ID-level node.
Returns:
nearest next node with different type not separated from this node by a node with different type. Entity reference node types are ignored and text is considered to have same node type as cdata. If no such node exists then the pointer shall point to the end of the child sequence of the parent element.

getEndBoundary

public DomPointer getEndBoundary(Node node)
Returns the pointer pointing after the last DOM-level node that makes up the ID-level index where given node belongs.

Parameters:
node - the DOM-level node
Returns:
nearest next node with different type not separated from this node by a node with different type. Entity reference node types are ignored and text is considered to have same node type as cdata. If no such node exists then the pointer shall point to the end of the child sequence of the parent element.

getNodeList

public NodeListID getNodeList(Node node)
Provides mapping functions more specific to given node.

Parameters:
node - the node
Returns:
a node list grouping DOM-level snodes in same ID-level index.


Copyright 2003-2003-2006 null. All Rights Reserved.