OpenAPI 1.0

com.aquafold.openapi.compare
Interface AQDifferences

All Superinterfaces:
Iterable<AQLineChange>

public interface AQDifferences
extends Iterable<AQLineChange>

This interface defines a set of lines produced by the comparison operation. Each line, represented by 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[].


Method Summary
 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.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

getModificationCount

int getModificationCount()
Returns a number of ADDED, DELETED, or MODIFIED lines (excluding UNCHANGED).


isDifferent

boolean isDifferent()
Returns true only if changes are present.


getModificationsOnly

AQLineChange[] getModificationsOnly()
Returns a non-null array of changes excluding UNCHANGED items.


getChanges

AQLineChange[] getChanges()
Returns a non-null array of changes, suitable for formatted output. One change item corresponds to one line of text.

Contains ADDED, DELETED, MODIFIED, and UNCHANGED lines.


toHtml

String toHtml()
Returns a string which represents a HTML-formatted representation of the changes.


toHtml

String toHtml(boolean showLegend)
Returns a string which represents a HTML-formatted representation of the changes.

Parameters:
showLegend - Set to true to display a legend.

OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.