mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
refactored whole tooling packages
This commit is contained in:
@@ -15,8 +15,14 @@
|
||||
*/
|
||||
package difflib;
|
||||
|
||||
import difflib.myers.Equalizer;
|
||||
import difflib.myers.MyersDiff;
|
||||
import difflib.patch.PatchFailedException;
|
||||
import difflib.patch.Delta;
|
||||
import difflib.patch.Chunk;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.ChangeDelta;
|
||||
import difflib.algorithm.DiffAlgorithm;
|
||||
import difflib.algorithm.myers.Equalizer;
|
||||
import difflib.algorithm.myers.MyersDiff;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.algorithm;
|
||||
|
||||
import difflib.patch.Patch;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* Base class for all exceptions emanating from this package.
|
||||
@@ -1,4 +1,4 @@
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -54,7 +54,7 @@
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* Thrown whenever the differencing engine cannot produce the differences between two revisions of
|
||||
@@ -1,4 +1,4 @@
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* Specifies when two compared elements in the Myers algorithm are equal.
|
||||
@@ -54,8 +54,15 @@
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
import difflib.patch.InsertDelta;
|
||||
import difflib.patch.Delta;
|
||||
import difflib.patch.Chunk;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.DeleteDelta;
|
||||
import difflib.patch.ChangeDelta;
|
||||
import difflib.algorithm.DiffAlgorithm;
|
||||
import difflib.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
@@ -54,7 +54,7 @@
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* A node in a diffpath.
|
||||
@@ -54,7 +54,7 @@
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package difflib.myers;
|
||||
package difflib.algorithm.myers;
|
||||
|
||||
/**
|
||||
* Represents a snake in a diffpath.
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content=
|
||||
"HTML Tidy for Cygwin (vers 1st February 2003), see www.w3.org">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
The {@link difflib difflib} package
|
||||
implements general operation with diff files.
|
||||
</p>
|
||||
@author <a href="mailto:dm.naumenko@gmail.com">Dmitry Naumenko</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class ChangeDelta<T> extends Delta<T> {
|
||||
* @param revised The original chunk. Must not be {@code null}.
|
||||
*/
|
||||
public ChangeDelta(Chunk<T> original, Chunk<T> revised) {
|
||||
super(TYPE.CHANGE, original, revised);
|
||||
super(DeltaType.CHANGE, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class DeleteDelta<T> extends Delta<T> {
|
||||
* @param revised The original chunk. Must not be {@code null}.
|
||||
*/
|
||||
public DeleteDelta(Chunk<T> original, Chunk<T> revised) {
|
||||
super(TYPE.DELETE, original, revised);
|
||||
super(DeltaType.DELETE, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.*;
|
||||
*/
|
||||
public abstract class Delta<T> {
|
||||
|
||||
private final TYPE deltaType;
|
||||
private final DeltaType deltaType;
|
||||
private final Chunk<T> original;
|
||||
private final Chunk<T> revised;
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class Delta<T> {
|
||||
* Specifies the type of the delta.
|
||||
*
|
||||
*/
|
||||
public static enum TYPE {
|
||||
public static enum DeltaType {
|
||||
/**
|
||||
* A change in the original.
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ public abstract class Delta<T> {
|
||||
* @param original Chunk describing the original text. Must not be {@code null}.
|
||||
* @param revised Chunk describing the revised text. Must not be {@code null}.
|
||||
*/
|
||||
public Delta(TYPE deltaType, Chunk<T> original, Chunk<T> revised) {
|
||||
public Delta(DeltaType deltaType, Chunk<T> original, Chunk<T> revised) {
|
||||
if (deltaType == null) {
|
||||
throw new IllegalArgumentException("deltaType must not be null");
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public abstract class Delta<T> {
|
||||
*/
|
||||
public abstract void restore(List<T> target);
|
||||
|
||||
public final TYPE getType() {
|
||||
public final DeltaType getType() {
|
||||
return deltaType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
/**
|
||||
* Base class for all exceptions emanating from this package.
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class InsertDelta<T> extends Delta<T> {
|
||||
* @param revised The original chunk. Must not be {@code null}.
|
||||
*/
|
||||
public InsertDelta(Chunk<T> original, Chunk<T> revised) {
|
||||
super(TYPE.INSERT, original, revised);
|
||||
super(DeltaType.INSERT, original, revised);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.patch;
|
||||
|
||||
/**
|
||||
* Thrown whenever a delta cannot be applied as a patch to a given text.
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib.rows;
|
||||
package difflib.text;
|
||||
|
||||
/**
|
||||
* Describes the diff row in form [tag, oldLine, newLine) for showing the difference between two
|
||||
@@ -13,18 +13,17 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib.rows;
|
||||
package difflib.text;
|
||||
|
||||
import difflib.ChangeDelta;
|
||||
import difflib.Chunk;
|
||||
import difflib.DeleteDelta;
|
||||
import difflib.Delta;
|
||||
import difflib.rows.DiffRow.Tag;
|
||||
import difflib.patch.ChangeDelta;
|
||||
import difflib.patch.Chunk;
|
||||
import difflib.patch.DeleteDelta;
|
||||
import difflib.patch.Delta;
|
||||
import difflib.text.DiffRow.Tag;
|
||||
import difflib.DiffUtils;
|
||||
import difflib.InsertDelta;
|
||||
import difflib.Patch;
|
||||
import difflib.StringUtils;
|
||||
import difflib.myers.Equalizer;
|
||||
import difflib.patch.InsertDelta;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.algorithm.myers.Equalizer;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -13,36 +13,13 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package difflib;
|
||||
package difflib.text;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public final class StringUtils {
|
||||
|
||||
public static <T> String join(final Iterable<T> objs, final String delimiter) {
|
||||
Iterator<T> iter = objs.iterator();
|
||||
if (!iter.hasNext()) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
|
||||
while (iter.hasNext()) {
|
||||
buffer.append(delimiter).append(String.valueOf(iter.next()));
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all tabs with 4 spaces.
|
||||
*
|
||||
* @param str The string.
|
||||
* @return
|
||||
*/
|
||||
public static String expandTabs(String str) {
|
||||
return str.replace("\t", " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all opening an closing tags with <code><</code> or <code>></code>.
|
||||
*
|
||||
@@ -54,7 +31,7 @@ public final class StringUtils {
|
||||
}
|
||||
|
||||
public static String normalize(String str) {
|
||||
return expandTabs(htmlEntites(str));
|
||||
return htmlEntites(str).replace("\t", " ");
|
||||
}
|
||||
|
||||
public static List<String> normalize(List<String> list) {
|
||||
@@ -1,5 +1,11 @@
|
||||
package diffutils;
|
||||
|
||||
import difflib.patch.InsertDelta;
|
||||
import difflib.patch.Delta;
|
||||
import difflib.patch.Chunk;
|
||||
import difflib.patch.ChangeDelta;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.DeleteDelta;
|
||||
import difflib.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package diffutils;
|
||||
|
||||
import difflib.DiffUtils;
|
||||
import difflib.Patch;
|
||||
import difflib.PatchFailedException;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.PatchFailedException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package diffutils.examples;
|
||||
|
||||
import difflib.DiffUtils;
|
||||
import difflib.Patch;
|
||||
import difflib.PatchFailedException;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.PatchFailedException;
|
||||
import diffutils.TestConstants;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package diffutils.examples;
|
||||
|
||||
import difflib.Delta;
|
||||
import difflib.patch.Delta;
|
||||
import difflib.DiffUtils;
|
||||
import difflib.Patch;
|
||||
import difflib.patch.Patch;
|
||||
import diffutils.TestConstants;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package diffutils;
|
||||
package diffutils.patch;
|
||||
|
||||
import difflib.DiffUtils;
|
||||
import difflib.Patch;
|
||||
import difflib.PatchFailedException;
|
||||
import difflib.patch.Patch;
|
||||
import difflib.patch.PatchFailedException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -1,7 +1,7 @@
|
||||
package diffutils.rows;
|
||||
|
||||
import difflib.rows.DiffRow;
|
||||
import difflib.rows.DiffRowGenerator;
|
||||
import difflib.text.DiffRow;
|
||||
import difflib.text.DiffRowGenerator;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
Reference in New Issue
Block a user