public class Edit extends Object
An edit covers the modified region only. It does not cover a common region.
Regions should be specified using 0 based notation, so add 1 to the start and end marks for line numbers in a file.
An edit where beginA == endA && beginB < endB
is an insert edit, that
is sequence B inserted the elements in region [beginB, endB)
at
beginA
.
An edit where beginA < endA && beginB == endB
is a delete edit, that
is sequence B has removed the elements between [beginA, endA)
.
An edit where beginA < endA && beginB < endB
is a replace edit, that
is sequence B has replaced the range of elements between
[beginA, endA)
with those found in [beginB, endB)
.
Modifier and Type | Class and Description |
---|---|
static class |
Edit.Type
Type of edit
|
Constructor and Description |
---|
Edit(int as,
int bs)
Create a new empty edit.
|
Edit(int as,
int ae,
int bs,
int be)
Create a new edit.
|
Modifier and Type | Method and Description |
---|---|
Edit |
after(Edit cut)
Construct a new edit representing the region after cut.
|
Edit |
before(Edit cut)
Construct a new edit representing the region before cut.
|
boolean |
equals(Object o) |
void |
extendA()
Increase
getEndA() by 1. |
void |
extendB()
Increase
getEndB() by 1. |
int |
getBeginA() |
int |
getBeginB() |
int |
getEndA() |
int |
getEndB() |
int |
getLengthA() |
int |
getLengthB() |
Edit.Type |
getType() |
int |
hashCode() |
boolean |
isEmpty() |
void |
swap()
Swap A and B, so the edit goes the other direction.
|
String |
toString() |
public Edit(int as, int bs)
as
- beginA: start and end of region in sequence A; 0 based.bs
- beginB: start and end of region in sequence B; 0 based.public Edit(int as, int ae, int bs, int be)
as
- beginA: start of region in sequence A; 0 based.ae
- endA: end of region in sequence A; must be >= as.bs
- beginB: start of region in sequence B; 0 based.be
- endB: end of region in sequence B; must be > = bs.public final Edit.Type getType()
public final boolean isEmpty()
public final int getBeginA()
public final int getEndA()
public final int getBeginB()
public final int getEndB()
public final int getLengthA()
public final int getLengthB()
public final Edit before(Edit cut)
cut
- the cut point. The beginning A and B points are used as the
end points of the returned edit.this
edit that occurs
before cut
starts.public final Edit after(Edit cut)
cut
- the cut point. The ending A and B points are used as the
starting points of the returned edit.this
edit that occurs
after cut
ends.public void extendA()
getEndA()
by 1.public void extendB()
getEndB()
by 1.public void swap()
Copyright © 2017 Eclipse JGit Project. All rights reserved.