public class PatchEntry extends Object implements Iterable<Difference>
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private List<Difference> |
diffs |
private static int |
margin |
private static int |
MARGIN
Chunk size for context length.
|
private static Pattern |
newlinePattern |
private static Pattern |
patchPattern |
private int |
sourceLength |
private int |
sourceStart |
private int |
targetLength |
private int |
targetStart |
Constructor and Description |
---|
PatchEntry() |
PatchEntry(String patchText) |
Modifier and Type | Method and Description |
---|---|
void |
addContext(String text) |
void |
addDifference(Difference diff) |
void |
adjustSourceLength(int adjustment) |
void |
adjustSourceStart(int adjustment) |
void |
adjustTargetLength(int adjustment) |
void |
adjustTargetStart(int adjustment) |
private String |
decode(String str)
Undo encoding
|
private String |
encode(String str)
This algorithm allows for \n to be included in a difference.
|
PatchEntry |
fromText(String input)
Parse a textual representation of a patch entry and populate this patch
entry.
|
private String |
getCoordinates(int start,
int length) |
int |
getDifferenceCount() |
Difference |
getFirstDifference() |
Difference |
getLastDifference() |
static int |
getMargin() |
int |
getSourceLength() |
int |
getSourceStart() |
String |
getSourceText() |
int |
getTargetLength() |
int |
getTargetStart() |
String |
getTargetText() |
boolean |
hasDifferences() |
Iterator<Difference> |
iterator() |
Difference |
removeFirstDifference() |
protected void |
setDifferences(List<Difference> newDiffs) |
static void |
setMargin(int newMargin) |
void |
setSourceLength(int length) |
void |
setSourceStart(int start) |
void |
setTargetLength(int length) |
void |
setTargetStart(int start) |
String |
toString() |
private static final int MARGIN
private static int margin
private static Pattern newlinePattern
private static Pattern patchPattern
private List<Difference> diffs
private int sourceStart
private int targetStart
private int sourceLength
private int targetLength
public PatchEntry()
public PatchEntry(String patchText)
public int getSourceStart()
public void setSourceStart(int start)
start
- the sourceStart to setpublic void adjustSourceStart(int adjustment)
adjustment
- the adjustment to sourceStartpublic int getTargetStart()
public void setTargetStart(int start)
start
- the targetStart to setpublic void adjustTargetStart(int adjustment)
adjustment
- the adjustment to targetStartpublic int getSourceLength()
public void setSourceLength(int length)
length
- the sourceLength to setpublic void adjustSourceLength(int adjustment)
adjustment
- the adjustment to sourceLengthpublic int getTargetLength()
public void setTargetLength(int length)
length
- the targetLength to setpublic void adjustTargetLength(int adjustment)
adjustment
- the adjustment to targetLengthpublic PatchEntry fromText(String input)
input
- Text representation of this patch entrypublic String getSourceText()
public String getTargetText()
public void addContext(String text)
public void addDifference(Difference diff)
public int getDifferenceCount()
public boolean hasDifferences()
public Iterator<Difference> iterator()
iterator
in interface Iterable<Difference>
public Difference getFirstDifference()
public Difference removeFirstDifference()
public Difference getLastDifference()
protected void setDifferences(List<Difference> newDiffs)
public static void setMargin(int newMargin)
newMargin
- the margin to setpublic static int getMargin()
private String getCoordinates(int start, int length)
private String encode(String str)
str
- the unencoded string