LibreOffice Module xmerge (master) 1
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
org.openoffice.xmerge.merger.diff.NodeIterator Class Referenceabstract

This is an implementation of the Iterator interface. More...

Inheritance diagram for org.openoffice.xmerge.merger.diff.NodeIterator:
[legend]
Collaboration diagram for org.openoffice.xmerge.merger.diff.NodeIterator:
[legend]

Public Member Functions

 NodeIterator (ConverterCapabilities cc, Node node)
 Standard constructor. More...
 
Object next ()
 Move to next element in the sequence. More...
 
Object previous ()
 
Object start ()
 Move to the beginning of the sequence. More...
 
Object end ()
 
Object currentElement ()
 Return the current element Object content. More...
 
int elementCount ()
 Return the total element count in the sequence. More...
 
boolean equivalent (Object obj1, Object obj2)
 A method to allow the difference algorithm to test whether the obj1 and obj2 in the Iterator are considered equal. More...
 
void refresh ()
 A method to force the Iterator to traverse the tree again to refresh the content. More...
 
Object next ()
 Move to next element in the sequence. More...
 
Object start ()
 Move to the beginning of the sequence. More...
 
Object currentElement ()
 Return the current element Object content. More...
 
int elementCount ()
 Return the total element count in the sequence. More...
 
boolean equivalent (Object obj1, Object obj2)
 A method to allow the difference algorithm to test whether the obj1 and obj2 in the Iterator are considered equal. More...
 
void refresh ()
 A method to force the Iterator to traverse the tree again to refresh the content. More...
 

Protected Member Functions

boolean compareNode (Node node1, Node node2)
 Used to compare two Node objects (type/name/value) and all their children Node objects. More...
 
boolean childrenEqual (Node node1, Node node2)
 Compare the children of two Node objects. More...
 
abstract boolean nodeSupported (Node node)
 Check whether a Node is supported. More...
 

Private Member Functions

boolean attributesEqual (Node node1, Node node2)
 Compare attributes of two Node objects. More...
 
void markTree (Node node)
 

Private Attributes

List< NodenodeList = null
 
int currentPosition = 0
 
final Node root
 
final ConverterCapabilities cc_
 

Detailed Description

This is an implementation of the Iterator interface.

It will traverse the tree and find Node sequences.

Note: Once the XML Tree is parsed, then the Iterator will be a snapshot of that tree. That means even the tree is modified later, then the cached paragraph Node list will not be updated accordingly. For this reason and for performance reasons this Iterator does not support any operation methods such as insert, remove or replace. The main purpose of this Iterator is to be used with difference, not with merge.

Definition at line 44 of file NodeIterator.java.

Constructor & Destructor Documentation

◆ NodeIterator()

org.openoffice.xmerge.merger.diff.NodeIterator.NodeIterator ( ConverterCapabilities  cc,
Node  node 
)
inline

Member Function Documentation

◆ attributesEqual()

boolean org.openoffice.xmerge.merger.diff.NodeIterator.attributesEqual ( Node  node1,
Node  node2 
)
inlineprivate

Compare attributes of two Node objects.

This method can be intentionally overridden by any class that extends from NodeIterator so that it can have its own attribute comparison.

Parameters
node1The first Node to compare.
node2The second Node to compare.
Returns
true if attributes are equal, false otherwise.

Definition at line 246 of file NodeIterator.java.

References org.openoffice.xmerge.ConverterCapabilities.canConvertAttribute(), org.openoffice.xmerge.merger.diff.NodeIterator.cc_, equal(), i, org.openoffice.xmerge.util.Debug.INFO, org.openoffice.xmerge.util.Debug.log(), and String.

Referenced by org.openoffice.xmerge.merger.diff.NodeIterator.compareNode().

◆ childrenEqual()

boolean org.openoffice.xmerge.merger.diff.NodeIterator.childrenEqual ( Node  node1,
Node  node2 
)
inlineprotected

Compare the children of two Node objects.

This method can be intentionally overridden by any class that extend from NodeIterator so that it can have its own children comparison if necessary.

Parameters
node1The first Node to compare.
node2The second Node to compare.
Returns
true if children are equal, false otherwise.

Reimplemented in org.openoffice.xmerge.merger.diff.CellNodeIterator.

Definition at line 203 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.compareNode(), equal(), and i.

Referenced by org.openoffice.xmerge.merger.diff.NodeIterator.compareNode().

◆ compareNode()

boolean org.openoffice.xmerge.merger.diff.NodeIterator.compareNode ( Node  node1,
Node  node2 
)
inlineprotected

Used to compare two Node objects (type/name/value) and all their children Node objects.

Parameters
node1The first Node to compare.
node2The second Node to compare.
Returns
true if Node is equal, false otherwise.

Definition at line 138 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.attributesEqual(), org.openoffice.xmerge.merger.diff.NodeIterator.childrenEqual(), and equal().

Referenced by org.openoffice.xmerge.merger.diff.NodeIterator.childrenEqual(), and org.openoffice.xmerge.merger.diff.NodeIterator.equivalent().

◆ currentElement()

Object org.openoffice.xmerge.merger.diff.NodeIterator.currentElement ( )
inline

◆ elementCount()

int org.openoffice.xmerge.merger.diff.NodeIterator.elementCount ( )
inline

Return the total element count in the sequence.

Returns
The total element count.

Implements org.openoffice.xmerge.merger.Iterator.

Definition at line 105 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.nodeList.

◆ end()

Object org.openoffice.xmerge.merger.diff.NodeIterator.end ( )
inline

◆ equivalent()

boolean org.openoffice.xmerge.merger.diff.NodeIterator.equivalent ( Object  obj1,
Object  obj2 
)
inline

A method to allow the difference algorithm to test whether the obj1 and obj2 in the Iterator are considered equal.

As not every Object in the Iterator can implement its own equal method, with this equivalent method, we can allow flexibility for the Iterator to choose a custom way to compare two objects. Two objects can even be compared based on the position in the Iterator rather than by the content via this option.

Parameters
obj1The first Object
obj2The second Object.
Returns
true if equal, false otherwise.

Implements org.openoffice.xmerge.merger.Iterator.

Definition at line 109 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.compareNode(), equal(), org.openoffice.xmerge.util.Debug.ERROR, org.openoffice.xmerge.util.Resources.getInstance(), org.openoffice.xmerge.util.Resources.getString(), org.openoffice.xmerge.util.Debug.log(), and String.

◆ markTree()

void org.openoffice.xmerge.merger.diff.NodeIterator.markTree ( Node  node)
inlineprivate

◆ next()

Object org.openoffice.xmerge.merger.diff.NodeIterator.next ( )
inline

Move to next element in the sequence.

Returns
The Object of the next element in the sequence. If there is no next element, then return null.

Implements org.openoffice.xmerge.merger.Iterator.

Definition at line 64 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.currentElement(), org.openoffice.xmerge.merger.diff.NodeIterator.currentPosition, org.openoffice.xmerge.merger.diff.NodeIterator.nodeList, and Object.

Referenced by org.openoffice.xmerge.merger.diff.CharacterParser.parseNodes().

◆ nodeSupported()

abstract boolean org.openoffice.xmerge.merger.diff.NodeIterator.nodeSupported ( Node  node)
abstractprotected

Check whether a Node is supported.

This method can be intentionally overridden by any class that extends from NodeIterator so that it can specify which Node to support.

Parameters
nodeNode to check.
Returns
true if Node is supported, false otherwise.

Reimplemented in org.openoffice.xmerge.merger.diff.CellNodeIterator, org.openoffice.xmerge.merger.diff.ParaNodeIterator, org.openoffice.xmerge.merger.diff.RowIterator, and org.openoffice.xmerge.merger.diff.TextNodeIterator.

Referenced by org.openoffice.xmerge.merger.diff.NodeIterator.markTree().

◆ previous()

Object org.openoffice.xmerge.merger.diff.NodeIterator.previous ( )
inline

◆ refresh()

void org.openoffice.xmerge.merger.diff.NodeIterator.refresh ( )
inline

A method to force the Iterator to traverse the tree again to refresh the content.

It is used mainly for Iterator objects which take a snapshot instead of dynamically traversing the tree. The current position will be set to the beginning.

Implements org.openoffice.xmerge.merger.Iterator.

Definition at line 123 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.currentPosition, org.openoffice.xmerge.merger.diff.NodeIterator.markTree(), org.openoffice.xmerge.merger.diff.NodeIterator.nodeList, and org.openoffice.xmerge.merger.diff.NodeIterator.root.

◆ start()

Object org.openoffice.xmerge.merger.diff.NodeIterator.start ( )
inline

Move to the beginning of the sequence.

Returns
The Object of the first element in the sequence. If it is empty, then return null.

Implements org.openoffice.xmerge.merger.Iterator.

Definition at line 82 of file NodeIterator.java.

References org.openoffice.xmerge.merger.diff.NodeIterator.currentElement(), org.openoffice.xmerge.merger.diff.NodeIterator.currentPosition, and Object.

Referenced by org.openoffice.xmerge.merger.diff.CharacterParser.parseNodes().

Member Data Documentation

◆ cc_

final ConverterCapabilities org.openoffice.xmerge.merger.diff.NodeIterator.cc_
private

◆ currentPosition

int org.openoffice.xmerge.merger.diff.NodeIterator.currentPosition = 0
private

◆ nodeList

List<Node> org.openoffice.xmerge.merger.diff.NodeIterator.nodeList = null
private

◆ root

final Node org.openoffice.xmerge.merger.diff.NodeIterator.root
private

The documentation for this class was generated from the following file: