|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object patch.PatchUtils
public class PatchUtils
This Library implements a simple patch algorithm which is able to process
the output of diff in normal format.
This class implements the algorithm.
The Method you're probably looking for is PatchUtils.patch(diff, target).
Example usage in comparison to GNU patch:
GNU patch: "patch target < diff"
jPatchLib: "PatchUtils.patch(diff, target"
see http://www.gnu.org/software/diffutils/manual/html_mono/diff.html#Normal
Copyright (c) 2007 Dominik Schulz This file is part of jPatchLib. jPatchLib is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. jPatchLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with jPatchLib; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Constructor Summary | |
---|---|
PatchUtils()
|
Method Summary | |
---|---|
private static java.lang.String[] |
add(int line,
java.lang.String[] insertion,
java.lang.String[] baseText,
int offset)
Apply an add chunk. |
static java.lang.String[] |
applyChunks(java.lang.String[] targetSrc,
Chunk[] chunks)
Apply the chunks from the chunks array to the target. |
private static java.lang.String[] |
change(int fromLine,
int toLine,
int to1,
int to2,
java.lang.String[] changeTo,
java.lang.String[] baseText,
int offset)
This applys a chunk of the type change. |
private static java.lang.String[] |
delete(int fromLine,
int toLine,
java.lang.String[] baseText,
int offset)
This applys a chunk of the type delete |
static Chunk[] |
getChunks(java.lang.String[] patchSrc)
Get the single chunks from the patch. |
static java.lang.String |
patch(java.lang.String patchText,
java.lang.String targetText)
This is like the patch utility from GNU diff/patch. |
static boolean |
startWithNumber(java.lang.String str)
Checks if the string starts with a number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PatchUtils()
Method Detail |
---|
public static boolean startWithNumber(java.lang.String str)
str
- the string to be checked
public static Chunk[] getChunks(java.lang.String[] patchSrc)
patchSrc
- the patch as a string array
public static java.lang.String[] applyChunks(java.lang.String[] targetSrc, Chunk[] chunks)
targetSrc
- the target to be patchedchunks
- the chunks to apply
public static java.lang.String patch(java.lang.String patchText, java.lang.String targetText)
patchText
- The output from difftargetText
- The text on which the diff will be applied
private static java.lang.String[] delete(int fromLine, int toLine, java.lang.String[] baseText, int offset)
fromLine
- the first line to deletetoLine
- the last line to deletebaseText
- the text to be patchedoffset
- the offset. see ... uhm, somewhere else
private static java.lang.String[] change(int fromLine, int toLine, int to1, int to2, java.lang.String[] changeTo, java.lang.String[] baseText, int offset)
fromLine
- toLine
- to1
- to2
- changeTo
- baseText
- offset
-
private static java.lang.String[] add(int line, java.lang.String[] insertion, java.lang.String[] baseText, int offset)
line
- insertion
- baseText
- offset
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |