You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sb...@apache.org on 2002/02/23 14:39:09 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff AddDelta.java ChangeDelta.java Chunk.java DeleteDelta.java Delta.java Diff.java DifferentiationFailedException.java DiffException.java PatchFailedException.java Range.java Revision.java
sbailliez 02/02/23 05:39:09
Modified: src/java/org/apache/maven/jrcs/diff AddDelta.java
ChangeDelta.java Chunk.java DeleteDelta.java
Delta.java Diff.java
DifferentiationFailedException.java
DiffException.java PatchFailedException.java
Range.java Revision.java
Log:
Apply Turbine coding style for brackets
Revision Changes Path
1.4 +16 -8 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/AddDelta.java
Index: AddDelta.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/AddDelta.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AddDelta.java 21 Feb 2002 14:08:59 -0000 1.3
+++ AddDelta.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -56,27 +56,34 @@
import java.util.List;
-public class AddDelta extends Delta {
+public class AddDelta extends Delta
+{
- AddDelta() {
+ AddDelta()
+ {
super();
}
- public AddDelta(int origpos, Chunk rev) {
+ public AddDelta(int origpos, Chunk rev)
+ {
init(new Chunk(origpos, 0), rev);
}
- public void verify(List target) throws PatchFailedException {
- if (original.first() > target.size()) {
+ public void verify(List target) throws PatchFailedException
+ {
+ if (original.first() > target.size())
+ {
throw new PatchFailedException("original.first() > target.size()");
}
}
- public void applyTo(List target) {
+ public void applyTo(List target)
+ {
revised.applyAdd(original.first(), target);
}
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
s.append(original.anchor());
s.append("a");
s.append(revised.range());
@@ -84,7 +91,8 @@
revised.toString(s, "> ", Diff.NL);
}
- public void toRCSString(StringBuffer s, String EOL) {
+ public void toRCSString(StringBuffer s, String EOL)
+ {
s.append("a");
s.append(original.anchor());
s.append(" ");
1.4 +18 -9 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/ChangeDelta.java
Index: ChangeDelta.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/ChangeDelta.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ChangeDelta.java 21 Feb 2002 14:08:59 -0000 1.3
+++ ChangeDelta.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -56,31 +56,39 @@
import java.util.List;
-public class ChangeDelta extends Delta {
+public class ChangeDelta extends Delta
+{
- ChangeDelta() {
+ ChangeDelta()
+ {
super();
}
- public ChangeDelta(Chunk orig, Chunk rev) {
+ public ChangeDelta(Chunk orig, Chunk rev)
+ {
init(orig, rev);
}
- public void verify(List target) throws PatchFailedException {
- if (!original.verify(target)) {
+ public void verify(List target) throws PatchFailedException
+ {
+ if (!original.verify(target))
+ {
throw new PatchFailedException();
}
- if (original.first() > target.size()) {
+ if (original.first() > target.size())
+ {
throw new PatchFailedException("original.first() > target.size()");
}
}
- public void applyTo(List target) {
+ public void applyTo(List target)
+ {
original.applyDelete(target);
revised.applyAdd(original.first(), target);
}
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
original.range().toString(s);
s.append("c");
revised.range().toString(s);
@@ -91,7 +99,8 @@
revised.toString(s, "> ", "\n");
}
- public void toRCSString(StringBuffer s, String EOL) {
+ public void toRCSString(StringBuffer s, String EOL)
+ {
s.append("d");
s.append(original.extfrom());
s.append(" ");
1.4 +64 -32 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Chunk.java
Index: Chunk.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Chunk.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Chunk.java 21 Feb 2002 14:08:59 -0000 1.3
+++ Chunk.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -63,13 +63,14 @@
/**
* Produces the "Chunk" differences between two sequences
*
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Diff
*/
public class Chunk
- extends org.apache.maven.jrcs.util.ToString {
+ extends org.apache.maven.jrcs.util.ToString
+{
protected int _anchor;
@@ -77,100 +78,126 @@
protected List _chunk;
- public Chunk(int pos, int count) {
+ public Chunk(int pos, int count)
+ {
this._anchor = pos;
this._count = (count >= 0 ? count : 0);
}
- public Chunk(Object[] iseq, int pos, int count) {
+ public Chunk(Object[] iseq, int pos, int count)
+ {
this(pos, count);
_chunk = slice(iseq, pos, count);
}
- public Chunk(Object[] iseq, int pos, int count, int offset) {
+ public Chunk(Object[] iseq, int pos, int count, int offset)
+ {
this(offset, count);
_chunk = slice(iseq, pos, count);
}
- public Chunk(List iseq, int pos, int count) {
+ public Chunk(List iseq, int pos, int count)
+ {
this(pos, count);
_chunk = slice(iseq, pos, count);
}
- public Chunk(List iseq, int pos, int count, int offset) {
+ public Chunk(List iseq, int pos, int count, int offset)
+ {
this(offset, count);
_chunk = slice(iseq, pos, count);
}
- public int anchor() {
+ public int anchor()
+ {
return _anchor;
}
- public int size() {
+ public int size()
+ {
return _count;
}
- public int first() {
+ public int first()
+ {
return anchor();
}
- public int last() {
+ public int last()
+ {
return anchor() + size() - 1;
}
- public int extfrom() {
+ public int extfrom()
+ {
return _anchor + 1;
}
- public int extto() {
+ public int extto()
+ {
return _anchor + _count;
}
- public Range range() {
+ public Range range()
+ {
return new Range(first(), last());
}
- public List chunk() {
+ public List chunk()
+ {
return _chunk;
}
- public boolean verify(List target) {
- if (_chunk == null) {
+ public boolean verify(List target)
+ {
+ if (_chunk == null)
+ {
return true;
}
- if (last() > target.size()) {
+ if (last() > target.size())
+ {
return false;
}
- for (int i = 0; i < _count; i++) {
- if (!target.get(_anchor + i).equals(_chunk.get(i))) {
+ for (int i = 0; i < _count; i++)
+ {
+ if (!target.get(_anchor + i).equals(_chunk.get(i)))
+ {
return false;
}
}
return true;
}
- public void applyDelete(List target) {
- for (int i = last(); i >= first(); i--) {
+ public void applyDelete(List target)
+ {
+ for (int i = last(); i >= first(); i--)
+ {
target.remove(i);
}
}
- public void applyAdd(int start, List target) {
+ public void applyAdd(int start, List target)
+ {
Iterator i = _chunk.iterator();
- while (i.hasNext()) {
+ while (i.hasNext())
+ {
target.add(start++, i.next());
}
}
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
toString(s, "", "");
}
- public StringBuffer toString(StringBuffer s, String prefix, String postfix) {
- if (_chunk != null) {
+ public StringBuffer toString(StringBuffer s, String prefix, String postfix)
+ {
+ if (_chunk != null)
+ {
Iterator i = _chunk.iterator();
- while (i.hasNext()) {
+ while (i.hasNext())
+ {
s.append(prefix);
s.append(i.next());
s.append(postfix);
@@ -179,15 +206,20 @@
return s;
}
- public static List slice(List seq, int pos, int count) {
- if (count <= 0) {
+ public static List slice(List seq, int pos, int count)
+ {
+ if (count <= 0)
+ {
return new ArrayList(seq.subList(pos, pos));
- } else {
+ }
+ else
+ {
return new ArrayList(seq.subList(pos, pos + count));
}
}
- public static List slice(Object[] seq, int pos, int count) {
+ public static List slice(Object[] seq, int pos, int count)
+ {
return slice(Arrays.asList(seq), pos, count);
}
}
1.4 +16 -8 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DeleteDelta.java
Index: DeleteDelta.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DeleteDelta.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DeleteDelta.java 21 Feb 2002 14:08:59 -0000 1.3
+++ DeleteDelta.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -58,27 +58,34 @@
import java.util.List;
-public class DeleteDelta extends Delta {
+public class DeleteDelta extends Delta
+{
- DeleteDelta() {
+ DeleteDelta()
+ {
super();
}
- public DeleteDelta(Chunk orig) {
+ public DeleteDelta(Chunk orig)
+ {
init(orig, null);
}
- public void verify(List target) throws PatchFailedException {
- if (!original.verify(target)) {
+ public void verify(List target) throws PatchFailedException
+ {
+ if (!original.verify(target))
+ {
throw new PatchFailedException();
}
}
- public void applyTo(List target) {
+ public void applyTo(List target)
+ {
original.applyDelete(target);
}
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
s.append(original.range());
s.append("d");
s.append(revised.extto());
@@ -86,7 +93,8 @@
original.toString(s, "< ", Diff.NL);
}
- public void toRCSString(StringBuffer s, String EOL) {
+ public void toRCSString(StringBuffer s, String EOL)
+ {
s.append("d");
s.append(original.extfrom());
s.append(" ");
1.4 +33 -15 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Delta.java
Index: Delta.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Delta.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Delta.java 21 Feb 2002 14:08:59 -0000 1.3
+++ Delta.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -65,7 +65,8 @@
*/
public abstract class Delta
- extends org.apache.maven.jrcs.util.ToString {
+ extends org.apache.maven.jrcs.util.ToString
+{
protected Chunk original;
@@ -75,26 +76,34 @@
static Class[][] DeltaClass;
- static {
+ static
+ {
DeltaClass = new Class[2][2];
- try {
+ try
+ {
DeltaClass[0][0] = org.apache.maven.jrcs.diff.ChangeDelta.class;
DeltaClass[0][1] = org.apache.maven.jrcs.diff.AddDelta.class;
DeltaClass[1][0] = org.apache.maven.jrcs.diff.DeleteDelta.class;
DeltaClass[1][1] = org.apache.maven.jrcs.diff.ChangeDelta.class;
- } catch (Throwable o) {
+ }
+ catch (Throwable o)
+ {
}
}
- public static Delta newDelta(Chunk orig, Chunk rev) {
+ public static Delta newDelta(Chunk orig, Chunk rev)
+ {
Class c = DeltaClass[orig.size() > 0 ? 1 : 0]
[rev.size() > 0 ? 1 : 0];
Delta result;
- try {
+ try
+ {
result = (Delta) c.newInstance();
- } catch (Throwable e) {
+ }
+ catch (Throwable e)
+ {
System.err.println(e);
return null;
}
@@ -103,16 +112,19 @@
}
- protected Delta() {
+ protected Delta()
+ {
}
- protected Delta(Chunk orig, Chunk rev) {
+ protected Delta(Chunk orig, Chunk rev)
+ {
init(orig, rev);
}
- protected void init(Chunk orig, Chunk rev) {
+ protected void init(Chunk orig, Chunk rev)
+ {
original = orig;
revised = rev;
}
@@ -120,18 +132,23 @@
public abstract void verify(List target) throws PatchFailedException;
- public final void patch(List target) throws PatchFailedException {
+ public final void patch(List target) throws PatchFailedException
+ {
verify(target);
- try {
+ try
+ {
applyTo(target);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
throw new PatchFailedException(e.getMessage());
}
}
public abstract void applyTo(List target);
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
original.range().toString(s);
s.append("x");
revised.range().toString(s);
@@ -144,7 +161,8 @@
public abstract void toRCSString(StringBuffer s, String EOL);
- public String toRCSString(String EOL) {
+ public String toRCSString(String EOL)
+ {
StringBuffer s = new StringBuffer();
toRCSString(s, EOL);
return s.toString();
1.4 +102 -50 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Diff.java
Index: Diff.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Diff.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Diff.java 21 Feb 2002 14:08:59 -0000 1.3
+++ Diff.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -70,12 +70,13 @@
/**
* Produces the "delta" differences between two sequences
*
- * @version $Revision: 1.3 $ $Date: 2002/02/21 14:08:59 $
+ * @version $Revision: 1.4 $ $Date: 2002/02/23 13:39:09 $
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Delta
*/
-public class Diff {
+public class Diff
+{
public static final String NL = "\n";
@@ -88,28 +89,38 @@
Object[] orig;
- public Diff(Object[] o) {
- if (o == null) {
+ public Diff(Object[] o)
+ {
+ if (o == null)
+ {
throw new IllegalArgumentException();
}
orig = o;
}
public static Revision diff(Object[] orig, Object[] rev)
- throws DifferentiationFailedException {
- if (orig == null || rev == null) {
+ throws DifferentiationFailedException
+ {
+ if (orig == null || rev == null)
+ {
throw new IllegalArgumentException();
}
return new Diff(orig).diff(rev);
}
- public static boolean compare(Object[] orig, Object[] rev) {
- if (orig.length != rev.length) {
+ public static boolean compare(Object[] orig, Object[] rev)
+ {
+ if (orig.length != rev.length)
+ {
return false;
- } else {
- for (int i = 0; i < orig.length; i++) {
- if (!orig[i].equals(rev[i])) {
+ }
+ else
+ {
+ for (int i = 0; i < orig.length; i++)
+ {
+ if (!orig[i].equals(rev[i]))
+ {
return false;
}
}
@@ -117,14 +128,17 @@
}
}
- protected int scan(int[] ndx, int i, int target) {
- while (ndx[i] < target) {
+ protected int scan(int[] ndx, int i, int target)
+ {
+ while (ndx[i] < target)
+ {
i++;
}
return i;
}
- public Revision diff(Object[] rev) throws DifferentiationFailedException {
+ public Revision diff(Object[] rev) throws DifferentiationFailedException
+ {
Map eqs = buildEqSet(orig, rev);
int[] indx = buildIndex(eqs, orig, NOT_FOUND_i);
int[] jndx = buildIndex(eqs, rev, NOT_FOUND_j);
@@ -135,26 +149,33 @@
int j = 0;
// skip matching
- for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++) {/* void */
+ for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
+ {/* void */
}
- while (indx[i] != jndx[j]) { // only equal if both == EOS
+ while (indx[i] != jndx[j])
+ { // only equal if both == EOS
// they are different
int ia = i;
int ja = j;
// size of this delta
- do {
- while (jndx[j] < 0 || jndx[j] < indx[i]) {
- j++;
+ do
+ {
+ while (jndx[j] < 0 || jndx[j] < indx[i])
+ {
+ j++;
}
- while (indx[i] < 0 || indx[i] < jndx[j]) {
- i++;
+ while (indx[i] < 0 || indx[i] < jndx[j])
+ {
+ i++;
}
- } while (indx[i] != jndx[j]);
+ }
+ while (indx[i] != jndx[j]);
// they are equal, reverse any exedent matches
- while (i > ia && j > ja && indx[i - 1] == jndx[j - 1]) {
+ while (i > ia && j > ja && indx[i - 1] == jndx[j - 1])
+ {
--i;
--j;
//System.err.println("************* reversing "+ i);
@@ -163,27 +184,35 @@
deltas.addDelta(Delta.newDelta(new Chunk(orig, ia, i - ia),
new Chunk(rev, ja, j - ja)));
// skip matching
- for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++) {/* void */
+ for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
+ {/* void */
}
}
- try {
- if (!compare(deltas.patch(orig), rev)) {
+ try
+ {
+ if (!compare(deltas.patch(orig), rev))
+ {
throw new DifferentiationFailedException();
}
- } catch (DiffException e) {
+ }
+ catch (DiffException e)
+ {
throw new DifferentiationFailedException(e.getMessage());
}
return deltas;
}
- protected Map buildEqSet(Object[] orig, Object[] rev) {
+ protected Map buildEqSet(Object[] orig, Object[] rev)
+ {
Set items = new HashSet(Arrays.asList(orig));
items.retainAll(Arrays.asList(rev));
Map eqs = new HashMap();
- for (int i = 0; i < orig.length; i++) {
- if (items.contains(orig[i])) {
+ for (int i = 0; i < orig.length; i++)
+ {
+ if (items.contains(orig[i]))
+ {
eqs.put(orig[i], new Integer(i));
items.remove(orig[i]);
}
@@ -191,13 +220,18 @@
return eqs;
}
- protected int[] buildIndex(Map eqs, Object[] seq, int NF) {
+ protected int[] buildIndex(Map eqs, Object[] seq, int NF)
+ {
int[] result = new int[seq.length + 1];
- for (int i = 0; i < seq.length; i++) {
+ for (int i = 0; i < seq.length; i++)
+ {
Integer value = (Integer) eqs.get(seq[i]);
- if (value == null || value.intValue() < 0) {
+ if (value == null || value.intValue() < 0)
+ {
result[i] = NF;
- } else {
+ }
+ else
+ {
result[i] = value.intValue();
}
}
@@ -205,28 +239,36 @@
return result;
}
- public static Object[] stringToArray(String value) {
+ public static Object[] stringToArray(String value)
+ {
BufferedReader reader = new BufferedReader(new StringReader(value));
List l = new LinkedList();
String s;
- try {
- while ((s = reader.readLine()) != null) {
+ try
+ {
+ while ((s = reader.readLine()) != null)
+ {
l.add(s);
}
- } catch (java.io.IOException e) {
+ }
+ catch (java.io.IOException e)
+ {
}
return l.toArray();
}
- public static String arrayToString(Object[] o) {
+ public static String arrayToString(Object[] o)
+ {
return arrayToString(o, Diff.NL);
}
- public static String arrayToString(Object[] o, String EOL) {
+ public static String arrayToString(Object[] o, String EOL)
+ {
StringBuffer buf = new StringBuffer();
- for (int i = 0; i < o.length - 1; i++) {
+ for (int i = 0; i < o.length - 1; i++)
+ {
buf.append(o[i]);
buf.append(EOL);
}
@@ -235,23 +277,30 @@
}
- public static Object[] randomEdit(Object[] text) {
+ public static Object[] randomEdit(Object[] text)
+ {
return randomEdit(text, text.length);
}
- public static Object[] randomEdit(Object[] text, long seed) {
+ public static Object[] randomEdit(Object[] text, long seed)
+ {
List result = new ArrayList(Arrays.asList(text));
Random r = new Random(seed);
int nops = r.nextInt(10);
- for (int i = 0; i < nops; i++) {
+ for (int i = 0; i < nops; i++)
+ {
boolean del = r.nextBoolean();
int pos = r.nextInt(result.size() + 1);
int len = Math.min(result.size() - pos, 1 + r.nextInt(4));
- if (del && result.size() > 0) { // delete
+ if (del && result.size() > 0)
+ { // delete
result.subList(pos, pos + len).clear();
- } else {
- for (int k = 0; k < len; k++, pos++) {
+ }
+ else
+ {
+ for (int k = 0; k < len; k++, pos++)
+ {
result.add(pos, "[" + i + "] random edit[" + i + "][" + i + "]");
}
}
@@ -260,16 +309,19 @@
}
- public static Object[] shuffle(Object[] text) {
+ public static Object[] shuffle(Object[] text)
+ {
return randomEdit(text, text.length);
}
- public static Object[] shuffle(Object[] text, long seed) {
+ public static Object[] shuffle(Object[] text, long seed)
+ {
List result = new ArrayList(Arrays.asList(text));
Random r = new Random(seed);
int nops = r.nextInt(10);
- for (int i = 0; i < nops; i++) {
+ for (int i = 0; i < nops; i++)
+ {
int p1 = r.nextInt(result.size());
int p2 = r.nextInt(result.size());
Object tmp = result.get(p1);
1.4 +6 -3 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DifferentiationFailedException.java
Index: DifferentiationFailedException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DifferentiationFailedException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DifferentiationFailedException.java 21 Feb 2002 14:08:59 -0000 1.3
+++ DifferentiationFailedException.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -54,12 +54,15 @@
* <http://www.apache.org/>.
*/
-public class DifferentiationFailedException extends DiffException {
+public class DifferentiationFailedException extends DiffException
+{
- public DifferentiationFailedException() {
+ public DifferentiationFailedException()
+ {
}
- public DifferentiationFailedException(String msg) {
+ public DifferentiationFailedException(String msg)
+ {
super(msg);
}
}
1.4 +6 -3 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DiffException.java
Index: DiffException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DiffException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DiffException.java 21 Feb 2002 14:08:59 -0000 1.3
+++ DiffException.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -54,12 +54,15 @@
* <http://www.apache.org/>.
*/
-public class DiffException extends Exception {
+public class DiffException extends Exception
+{
- public DiffException() {
+ public DiffException()
+ {
}
- public DiffException(String msg) {
+ public DiffException(String msg)
+ {
super(msg);
}
}
1.4 +6 -3 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/PatchFailedException.java
Index: PatchFailedException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/PatchFailedException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PatchFailedException.java 21 Feb 2002 14:08:59 -0000 1.3
+++ PatchFailedException.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -54,12 +54,15 @@
* <http://www.apache.org/>.
*/
-public class PatchFailedException extends DiffException {
+public class PatchFailedException extends DiffException
+{
- public PatchFailedException() {
+ public PatchFailedException()
+ {
}
- public PatchFailedException(String msg) {
+ public PatchFailedException(String msg)
+ {
super(msg);
}
}
1.4 +19 -9 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Range.java
Index: Range.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Range.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Range.java 21 Feb 2002 14:08:59 -0000 1.3
+++ Range.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -64,38 +64,48 @@
* @see org.apache.maven.jrcs.diff.Diff
*/
public class Range
- extends ToString {
+ extends ToString
+{
int _from;
int _to;
- public Range(int from, int to) {
+ public Range(int from, int to)
+ {
_from = from;
_to = to;
}
- public int from() {
+ public int from()
+ {
return _from;
}
- public int to() {
+ public int to()
+ {
return _to;
}
- public int length() {
+ public int length()
+ {
return 1 + _to - _from;
}
- public void toString(StringBuffer s, String separ) {
- if (_from == _to) {
+ public void toString(StringBuffer s, String separ)
+ {
+ if (_from == _to)
+ {
s.append(Integer.toString(1 + _from));
- } else {
+ }
+ else
+ {
s.append(Integer.toString(1 + _from));
s.append(separ);
s.append(Integer.toString(1 + _to));
}
}
- public void toString(StringBuffer s) {
+ public void toString(StringBuffer s)
+ {
toString(s, ",");
}
}
1.4 +34 -17 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Revision.java
Index: Revision.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Revision.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Revision.java 21 Feb 2002 14:08:59 -0000 1.3
+++ Revision.java 23 Feb 2002 13:39:09 -0000 1.4
@@ -65,19 +65,24 @@
public class Revision
- extends ToString {
+ extends ToString
+{
List deltas_ = new LinkedList();
- public Revision() {
+ public Revision()
+ {
}
- public synchronized void addDelta(Delta delta) {
- if (delta == null) {
+ public synchronized void addDelta(Delta delta)
+ {
+ if (delta == null)
+ {
throw new IllegalArgumentException("new delta is null");
}
- if (deltas_.size() > 0) {
+ if (deltas_.size() > 0)
+ {
Delta prev = (Delta) deltas_.get(deltas_.size() - 1);
/*!!!
@@ -93,53 +98,65 @@
deltas_.add(delta);
}
- public Delta getDelta(int i) {
+ public Delta getDelta(int i)
+ {
return (Delta) deltas_.get(i);
}
- public int size() {
+ public int size()
+ {
return deltas_.size();
}
- public Object[] patch(Object[] src) throws PatchFailedException {
+ public Object[] patch(Object[] src) throws PatchFailedException
+ {
List target = new ArrayList(Arrays.asList(src));
applyTo(target);
return target.toArray();
}
- public synchronized void applyTo(List target) throws PatchFailedException {
+ public synchronized void applyTo(List target) throws PatchFailedException
+ {
ListIterator i = deltas_.listIterator(deltas_.size());
- while (i.hasPrevious()) {
+ while (i.hasPrevious())
+ {
Delta delta = (Delta) i.previous();
delta.patch(target);
}
}
- public synchronized void toString(StringBuffer s) {
+ public synchronized void toString(StringBuffer s)
+ {
Iterator i = deltas_.iterator();
- while (i.hasNext()) {
+ while (i.hasNext())
+ {
((Delta) i.next()).toString(s);
}
}
- public synchronized void toRCSString(StringBuffer s, String EOL) {
+ public synchronized void toRCSString(StringBuffer s, String EOL)
+ {
Iterator i = deltas_.iterator();
- while (i.hasNext()) {
+ while (i.hasNext())
+ {
((Delta) i.next()).toRCSString(s, EOL);
}
}
- public void toRCSString(StringBuffer s) {
+ public void toRCSString(StringBuffer s)
+ {
toRCSString(s, Diff.NL);
}
- public String toRCSString(String EOL) {
+ public String toRCSString(String EOL)
+ {
StringBuffer s = new StringBuffer();
toRCSString(s, EOL);
return s.toString();
}
- public String toRCSString() {
+ public String toRCSString()
+ {
return toRCSString(Diff.NL);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>