public interface AQDifferences extends Iterable<AQLineChange>
AQLineChange
instance, can be either an added line, a deleted line,
a modified line, or an unchanged line.
For example, the following script compares two text strings:
String 1:
1 2 3 deleted 4
String 2:
1 modified 2 4 5 added
Script:
var comp = aqua.compare.newComparator(); var diff = comp.compare("1\n2\n3 deleted\n4\n","1 Modified\n2\n4\n5 added\n"); var changes = diff.getChanges(); for(var i=0; i < changes.length; i++) { print(changes[i]); }Output:
MODIFIED[1]->[1 Modified] UNCHANGED[2]==[2] DELETED[3 deleted] UNCHANGED[4]==[4] ADDED[5 added]To visually see what lines have been added/modified/deleted and to better understand the change algorithm and its output, use the toHTML(true) method call and display the result in a browser. Each table row in the HTML output corresponds to a row in AQLineChange[].
Modifier and Type | Method and Description |
---|---|
AQLineChange[] |
getChanges()
Returns a non-null array of changes,
suitable for formatted output.
|
int |
getModificationCount()
Returns a number of ADDED, DELETED, or MODIFIED lines (excluding UNCHANGED).
|
AQLineChange[] |
getModificationsOnly()
Returns a non-null array of changes excluding UNCHANGED items.
|
boolean |
isDifferent()
Returns true only if changes are present.
|
String |
toHtml()
Returns a string which represents a HTML-formatted representation of the changes.
|
String |
toHtml(boolean showLegend)
Returns a string which represents a HTML-formatted representation of the changes.
|
forEach, iterator, spliterator
int getModificationCount()
boolean isDifferent()
AQLineChange[] getModificationsOnly()
AQLineChange[] getChanges()
Contains ADDED, DELETED, MODIFIED, and UNCHANGED lines.
String toHtml()
String toHtml(boolean showLegend)
showLegend
- Set to true to display a legend.
Copyright © 2017 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.