APIdia Launch Partner
Top Description Inners Constructors Methods
jdk.internal.org.jline.utils

public Class DiffHelper

extends Object
Class Inheritance
Imports
java.util.LinkedList, .List

Class containing the diff method. This diff is ANSI aware and will correctly handle text attributes so that any text in a Diff object is a valid ansi string.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DiffHelper.Diff

Class representing one diff operation.

public static enum
DiffHelper.Operation

The data structure representing a diff is a Linked list of Diff objects: {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), Diff(Operation.EQUAL, " world.")} which means: delete "Hello", add "Goodbye" and keep " world."

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static List<DiffHelper.Diff>

Returns:

a list of Diff
diff
(AttributedString
the old line
text1
,
AttributedString
the new line
text2
)

Compute a list of difference between two lines.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DiffHelperback to summary
public DiffHelper()

Method Detail

diffback to summary
public static List<DiffHelper.Diff> diff(AttributedString text1, AttributedString text2)

Compute a list of difference between two lines. The result will contain at most 4 Diff objects, as the method aims to return the common prefix, inserted text, deleted text and common suffix. The computation is done on characters and their attributes expressed as ansi sequences.

Parameters
text1:AttributedString

the old line

text2:AttributedString

the new line

Returns:List<DiffHelper.Diff>

a list of Diff

jdk.internal.org.jline.utils back to summary

public Class DiffHelper.Diff

extends Object
Class Inheritance

Class representing one diff operation.

Field Summary

Modifier and TypeField and Description
public final DiffHelper.Operation
operation

One of: INSERT, DELETE or EQUAL.

public final AttributedString
text

The text associated with this diff operation.

Constructor Summary

AccessConstructor and Description
public
Diff(DiffHelper.Operation
One of INSERT, DELETE or EQUAL.
operation
,
AttributedString
The text being applied.
text
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

text version.
toString
()

Overrides java.lang.Object.toString.

Display a human-readable version of this Diff.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

operationback to summary
public final DiffHelper.Operation operation

One of: INSERT, DELETE or EQUAL.

textback to summary
public final AttributedString text

The text associated with this diff operation.

Constructor Detail

Diffback to summary
public Diff(DiffHelper.Operation operation, AttributedString text)

Constructor. Initializes the diff with the provided values.

Parameters
operation:DiffHelper.Operation

One of INSERT, DELETE or EQUAL.

text:AttributedString

The text being applied.

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Display a human-readable version of this Diff.

Returns:String

text version.

jdk.internal.org.jline.utils back to summary

public final Enum DiffHelper.Operation

extends Enum<DiffHelper.Operation>
Class Inheritance

The data structure representing a diff is a Linked list of Diff objects: {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), Diff(Operation.EQUAL, " world.")} which means: delete "Hello", add "Goodbye" and keep " world."

Field Summary

Modifier and TypeField and Description
public static final DiffHelper.Operation
public static final DiffHelper.Operation
public static final DiffHelper.Operation

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DiffHelper.Operation
public static DiffHelper.Operation[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DELETEback to summary
public static final DiffHelper.Operation DELETE
EQUALback to summary
public static final DiffHelper.Operation EQUAL
INSERTback to summary
public static final DiffHelper.Operation INSERT

Constructor Detail

Operationback to summary
private Operation()

Method Detail

valueOfback to summary
public static DiffHelper.Operation valueOf(String name)
valuesback to summary
public static DiffHelper.Operation[] values()