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 TypeMethodDescriptionvoidlonglonglonggetNewID()intReturns the number of comparable entities.getTextNode(int i) voidhandlePossibleChangedPart(int leftstart, int leftend, int rightstart, int rightend, TextNodeComparator leftComparator) iterator()voidmarkAsDeleted(int start, int end, TextNodeComparator oldComp, int before, int after) Marks the given range as deleted.voidmarkAsDeleted(int start, int end, TextNodeComparator oldComp, int before, int after, ModificationType outputFormat) Marks the given range as deleted.voidmarkAsNew(int start, int end) Marks the given range as new.voidmarkAsNew(int start, int end, ModificationType outputFormat) Marks the given range as new.booleanrangesEqual(int i1, IRangeComparator rangeComp, int i2) Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.voidsetLastModified(List<Modification> aLastModified) voidsetStartChangedID(long aChangedID) Used for combining multiple comparators in order to create a single output document.voidsetStartDeletedID(long aDeletedID) Used for combining multiple comparators in order to create a single output document.voidsetStartNewID(long aNewID) Used for combining multiple comparators in order to create a single output document.booleanskipRangeComparison(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, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TextNodeComparator
-
-
Method Details
-
getBodyNode
-
getRangeCount
public int getRangeCount()Description copied from interface:IRangeComparatorReturns the number of comparable entities.- Specified by:
getRangeCountin 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:IRangeComparatorReturns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.- Specified by:
rangesEqualin interfaceIRangeComparator- Parameters:
i1- the index of the comparable entity within thisIRangeComparatorrangeComp- the IRangeComparator to compare this withi2- the index of the comparable entity within the otherIRangeComparator- Returns:
trueif the comparable entities are equal
-
skipRangeComparison
Description copied from interface:IRangeComparatorReturns whether a comparison should be skipped because it would be too costly (or lengthy).- Specified by:
skipRangeComparisonin interfaceIRangeComparator- Parameters:
arg0- a number on which to base the decision whether to returntrueorfalsearg1- another number on which to base the decision whether to returntrueorfalsearg2- the otherIRangeComparatorto compare with- Returns:
trueto 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
-