java-diff-utils

The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.

Лицензия

Лицензия

Группа

Группа

com.github.wumpz
Идентификатор

Идентификатор

diffutils
Последняя версия

Последняя версия

3.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

java-diff-utils
The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
Ссылка на сайт

Ссылка на сайт

https://github.com/wumpz/java-diff-utils
Организация-разработчик

Организация-разработчик

java-diff-utils
Система контроля версий

Система контроля версий

https://github.com/wumpz/java-diff-utils.git

Скачать diffutils

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.wumpz/diffutils/ -->
<dependency>
    <groupId>com.github.wumpz</groupId>
    <artifactId>diffutils</artifactId>
    <version>3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.wumpz/diffutils/
implementation 'com.github.wumpz:diffutils:3.0'
// https://jarcasting.com/artifacts/com.github.wumpz/diffutils/
implementation ("com.github.wumpz:diffutils:3.0")
'com.github.wumpz:diffutils:jar:3.0'
<dependency org="com.github.wumpz" name="diffutils" rev="3.0">
  <artifact name="diffutils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.wumpz', module='diffutils', version='3.0')
)
libraryDependencies += "com.github.wumpz" % "diffutils" % "3.0"
[com.github.wumpz/diffutils "3.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.eclipse.jgit : org.eclipse.jgit jar 4.4.1.201607150455-r

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

java-diff-utils

Status

Build Status Codacy Badge Maven Central

Intro

Diff Utils library is an OpenSource library for performing the comparison operations between texts: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future displaying (like side-by-side view) and so on.

Main reason to build this library was the lack of easy-to-use libraries with all the usual stuff you need while working with diff files. Originally it was inspired by JRCS library and it's nice design of diff module.

This is originally a fork of java-diff-utils from Google Code Archive.

API

Javadocs of the actual release version: JavaDocs java-diff-utils

Examples

Look here to find more helpful informations and examples.

These two outputs are generated using this java-diff-utils. The source code can also be found at the Examples page:

Producing a one liner including all difference information.

This is a test senctencefor diffutils.

Producing a side by side view of computed differences.

original new
This is a test senctence. This is a test for diffutils.
This is the second line. This is the second line.
And here is the finish.

Main Features

  • computing the difference between two texts.
  • capable to hand more than plain ascii. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
  • patch and unpatch the text with the given patch
  • parsing the unified diff format
  • producing human-readable differences
  • inline difference construction
  • Algorithms:
    • Myer
    • HistogramDiff using JGit Library

Algorithms

  • Myer's diff
  • HistogramDiff

But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future.

Source Code conventions

Recently a checkstyle process was integrated into the build process. java-diff-utils follows the sun java format convention. There are no TABs allowed. Use spaces.

public static <T> Patch<T> diff(List<T> original, List<T> revised,
    BiPredicate<T, T> equalizer) throws DiffException {
    if (equalizer != null) {
        return DiffUtils.diff(original, revised,
        new MyersDiff<>(equalizer));
    }
    return DiffUtils.diff(original, revised, new MyersDiff<>());
}

This is a valid piece of source code:

  • blocks without braces are not allowed
  • after control statements (if, while, for) a whitespace is expected
  • the opening brace should be in the same line as the control statement

To Install

Just add the code below to your maven dependencies:

<dependency>
    <groupId>io.github.java-diff-utils</groupId>
    <artifactId>java-diff-utils</artifactId>
    <version>4.5</version>
</dependency>

or using gradle:

// https://mvnrepository.com/artifact/io.github.java-diff-utils/java-diff-utils
implementation "io.github.java-diff-utils:java-diff-utils:4.5"

Версии библиотеки

Версия
3.0
2.2