com.cloudbees.diff
Class Diff
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Difference>
com.cloudbees.diff.Diff
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<Difference>, Collection<Difference>, List<Difference>, RandomAccess
public class Diff
- extends ArrayList<Difference>
- implements Serializable
Represents a diff between two files. Entry point of the library.
- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
|
Constructor Summary |
Diff()
|
|
Method Summary |
Reader |
apply(Reader source)
Apply the difference to the specified source. |
static Diff |
diff(File f1,
File f2,
boolean ignoreWhitespace)
Computes a diff between two files. |
static Diff |
diff(List<String> lines1,
List<String> lines2,
boolean ignoreWhitespace)
Compares two "files" that are passed in as a list of lines. |
static Diff |
diff(Reader r1,
Reader r2,
boolean ignoreWhitespace)
Create the differences of the content two streams. |
String |
toUnifiedDiff(String name1,
String name2,
Reader r1,
Reader r2,
int numContextLines)
Prints the difference in the unified diff format. |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Diff
public Diff()
diff
public static Diff diff(File f1,
File f2,
boolean ignoreWhitespace)
throws IOException
- Computes a diff between two files.
- Throws:
IOException
diff
public static Diff diff(Reader r1,
Reader r2,
boolean ignoreWhitespace)
throws IOException
- Create the differences of the content two streams.
- Parameters:
r1 - the first sourcer2 - the second source to be compared with the first one.
- Throws:
IOException
diff
public static Diff diff(List<String> lines1,
List<String> lines2,
boolean ignoreWhitespace)
- Compares two "files" that are passed in as a list of lines.
toUnifiedDiff
public String toUnifiedDiff(String name1,
String name2,
Reader r1,
Reader r2,
int numContextLines)
throws IOException
- Prints the difference in the unified diff format.
- Parameters:
numContextLines - Number of context lines to generate around the diff.
- Throws:
IOException
apply
public Reader apply(Reader source)
- Apply the difference to the specified source.
- Parameters:
source - The source stream
- Returns:
- The patched stream
- Throws:
IOException - When reading from the source stream fails
ParseException - When the source does not match the patch to be applied
Copyright © 2011-2012. All Rights Reserved.