*/
public void patch(List original, boolean annotate)
throws InvalidFileFormatException,
org.apache.commons.jrcs.diff.PatchFailedException
{
Revision revision = new Revision();
for (int it = 0; it < text.length; it++)
{
String cmd = text[it].toString();
java.util.StringTokenizer t = new StringTokenizer(cmd, "ad ", true);
char action;
int n;
int count;
try
{
action = t.nextToken().charAt(0);
n = Integer.parseInt(t.nextToken());
t.nextToken(); // skip the space
count = Integer.parseInt(t.nextToken());
}
catch (Exception e)
{
throw new InvalidFileFormatException(version + ":line:" + ":" + e.getMessage());
}
if (action == 'd')
{
revision.addDelta(new DeleteDelta(new Chunk(n - 1, count)));
}
else if (action == 'a')
{
revision.addDelta(new AddDelta(n, new Chunk(getTextLines(it + 1, it + 1 + count), 0, count, n - 1)));
it += count;
}
else
{
throw new InvalidFileFormatException(version.toString());
}
}
revision.applyTo(original);
}