Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Diff Utils library is an OpenSource library for performing the comparison / diff operations between texts or some kind of data: 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.

License

NotificationsYou must be signed in to change notification settings

java-diff-utils/java-diff-utils

Repository files navigation

Status

Build StatusCodacy BadgeMaven 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.

Examples

Lookhere 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 theExamples page:

Producing a one liner including all difference information.

This is a testsenctencefor diffutils.

Producing a side by side view of computed differences.

originalnew
This is a testsenctence.This is a testfor 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 ascci. 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

Algoritms

  • 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.

Changelog

  • Version 4.0-SNAPSHOT
    • moved to organisationjava-diff-utils
    • changed groupid toio.github.java-diff-utils and artifact id tojava-diff-utils
  • Version 3.0
    • changed generation of inline diffes, if there are different linefeeds within one diff, then these are excludedfrom the diff block.
    • Due to licensing issues Delta.java and DiffAlgorithm.java were removed.
  • Version 2.3-SNAPSHOT
    • Introduced a process listener to diff algorithms. For long runningdiffs one could implement some progress information.
    • automatic module name for JDK 9 and higher usage
  • Version 2.2
    • released at maven central
    • included checkstyle source code conventions
    • groupid changed tocom.github.wumpz, due to maven central releasing
    • allow configurable splitting of lines to define the blocks to compare (words, characters, phrases).
  • Version 2.0
    • switch to maven and removed other artifacts
    • changed groupid tocom.github.java-diff-utils due to different forks at github
    • updated maven plugins
    • JDK 1.8 compatibility, sorry if you have to stick with older versions
    • support for inline merge
    • restructured packages heavily
    • changed API
    • changed Algorithm to provide only cursor positions
    • integrated JGit (Eclipse Licensed) to provide HistogramDiff to gain speed for large datasets
    • removed all kinds of helper classes in favour of new JDK 8 function classes like Predicate
  • Version 1.2
    • JDK 1.5 compatibility
    • Ant build script
    • Generate output in unified diff format (thanks for Bill James)

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.

publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,BiPredicate<T,T>equalizer)throwsDiffException {if (equalizer !=null) {returnDiffUtils.diff(original,revised,newMyersDiff<>(equalizer));}returnDiffUtils.diff(original,revised,newMyersDiff<>());}

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>com.github.wumpz</groupId>    <artifactId>diffutils</artifactId>    <version>3.0</version></dependency>

Attention. We changed groupid and artifactid. Starting with version 4 you have to use:

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

or using gradle:

// https://mvnrepository.com/artifact/com.github.wumpz/diffutilscompile group: 'com.github.wumpz', name: 'diffutils', version: '2.2'

About

Diff Utils library is an OpenSource library for performing the comparison / diff operations between texts or some kind of data: 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.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors34


    [8]ページ先頭

    ©2009-2025 Movatter.jp