Package org.eclipse.jgit.patch
Class Patch
- java.lang.Object
-
- org.eclipse.jgit.patch.Patch
-
public class Patch extends Object
A parsed collection ofFileHeader
s from a unified diff patch file
-
-
Constructor Summary
Constructors Constructor Description Patch()
Create an empty patch.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addError(FormatError err)
Add a formatting error to this patch script.void
addFile(FileHeader fh)
Add a single file to this patch.List<FormatError>
getErrors()
Get collection of formatting errors.List<? extends FileHeader>
getFiles()
Get list of files described in the patch, in occurrence order.void
parse(byte[] buf, int ptr, int end)
Parse a patch stored in a byte[].void
parse(InputStream is)
Parse a patch received from an InputStream.
-
-
-
Method Detail
-
addFile
public void addFile(FileHeader fh)
Add a single file to this patch.Typically files should be added by parsing the text through one of this class's parse methods.
- Parameters:
fh
- the header of the file.
-
getFiles
public List<? extends FileHeader> getFiles()
Get list of files described in the patch, in occurrence order.- Returns:
- list of files described in the patch, in occurrence order.
-
addError
public void addError(FormatError err)
Add a formatting error to this patch script.- Parameters:
err
- the error description.
-
getErrors
public List<FormatError> getErrors()
Get collection of formatting errors.- Returns:
- collection of formatting errors, if any.
-
parse
public void parse(InputStream is) throws IOException
Parse a patch received from an InputStream.Multiple parse calls on the same instance will concatenate the patch data, but each parse input must start with a valid file header (don't split a single file across parse calls).
- Parameters:
is
- the stream to read the patch data from. The stream is read until EOF is reached.- Throws:
IOException
- there was an error reading from the input stream.
-
parse
public void parse(byte[] buf, int ptr, int end)
Parse a patch stored in a byte[].Multiple parse calls on the same instance will concatenate the patch data, but each parse input must start with a valid file header (don't split a single file across parse calls).
- Parameters:
buf
- the buffer to parse.ptr
- starting position to parse from.end
- 1 past the last position to end parsing. The total length to be parsed isend - ptr
.
-
-