Package org.outerj.daisy.diff.html
Class TextNodeComparator
java.lang.Object
org.outerj.daisy.diff.html.TextNodeComparator
- All Implemented Interfaces:
Iterable<TextNode>
,IRangeComparator
A comparator that generates a DOM tree of sorts from handling SAX events.
Then it can be used to compute the difference between DOM trees and mark
elements accordingly.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
long
long
long
getNewID()
int
Returns the number of comparable entities.getTextNode
(int i) void
handlePossibleChangedPart
(int leftstart, int leftend, int rightstart, int rightend, TextNodeComparator leftComparator) iterator()
void
markAsDeleted
(int start, int end, TextNodeComparator oldComp, int before, int after) Marks the given range as deleted.void
markAsDeleted
(int start, int end, TextNodeComparator oldComp, int before, int after, ModificationType outputFormat) Marks the given range as deleted.void
markAsNew
(int start, int end) Marks the given range as new.void
markAsNew
(int start, int end, ModificationType outputFormat) Marks the given range as new.boolean
rangesEqual
(int i1, IRangeComparator rangeComp, int i2) Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparator
and index.void
setLastModified
(List<Modification> aLastModified) void
setStartChangedID
(long aChangedID) Used for combining multiple comparators in order to create a single output document.void
setStartDeletedID
(long aDeletedID) Used for combining multiple comparators in order to create a single output document.void
setStartNewID
(long aNewID) Used for combining multiple comparators in order to create a single output document.boolean
skipRangeComparison
(int arg0, int arg1, IRangeComparator arg2) Returns whether a comparison should be skipped because it would be too costly (or lengthy).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TextNodeComparator
-
-
Method Details
-
getBodyNode
-
getRangeCount
public int getRangeCount()Description copied from interface:IRangeComparator
Returns the number of comparable entities.- Specified by:
getRangeCount
in interfaceIRangeComparator
- Returns:
- the number of comparable entities
-
getTextNode
-
markAsNew
Marks the given range as new. In the output, the range will be formatted as specified by the anOutputFormat parameter.- Parameters:
start
-end
-outputFormat
- specifies how this range shall be formatted in the output
-
markAsNew
public void markAsNew(int start, int end) Marks the given range as new. In the output, the range will be formatted as "added".- Parameters:
start
-end
-
-
rangesEqual
Description copied from interface:IRangeComparator
Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparator
and index.- Specified by:
rangesEqual
in interfaceIRangeComparator
- Parameters:
i1
- the index of the comparable entity within thisIRangeComparator
rangeComp
- the IRangeComparator to compare this withi2
- the index of the comparable entity within the otherIRangeComparator
- Returns:
true
if the comparable entities are equal
-
skipRangeComparison
Description copied from interface:IRangeComparator
Returns whether a comparison should be skipped because it would be too costly (or lengthy).- Specified by:
skipRangeComparison
in interfaceIRangeComparator
- Parameters:
arg0
- a number on which to base the decision whether to returntrue
orfalse
arg1
- another number on which to base the decision whether to returntrue
orfalse
arg2
- the otherIRangeComparator
to compare with- Returns:
true
to avoid a too lengthy range comparison
-
handlePossibleChangedPart
public void handlePossibleChangedPart(int leftstart, int leftend, int rightstart, int rightend, TextNodeComparator leftComparator) -
markAsDeleted
public void markAsDeleted(int start, int end, TextNodeComparator oldComp, int before, int after, ModificationType outputFormat) Marks the given range as deleted. In the output, the range will be formatted as specified by the parameter anOutputFormat.- Parameters:
start
-end
-oldComp
-before
-anOutputFormat
- specifies how this range shall be formatted in the output
-
markAsDeleted
Marks the given range as deleted. In the output, the range will be formatted as "removed".- Parameters:
start
-end
-oldComp
-before
-
-
expandWhiteSpace
public void expandWhiteSpace() -
iterator
-
setStartDeletedID
public void setStartDeletedID(long aDeletedID) Used for combining multiple comparators in order to create a single output document. The IDs must be successive along the different comparators.- Parameters:
aDeletedID
-
-
setStartChangedID
public void setStartChangedID(long aChangedID) Used for combining multiple comparators in order to create a single output document. The IDs must be successive along the different comparators.- Parameters:
aDeletedID
-
-
setStartNewID
public void setStartNewID(long aNewID) Used for combining multiple comparators in order to create a single output document. The IDs must be successive along the different comparators.- Parameters:
aDeletedID
-
-
getChangedID
public long getChangedID() -
getDeletedID
public long getDeletedID() -
getNewID
public long getNewID() -
getLastModified
-
setLastModified
-