Package org.eclipse.compare.patch
Class PatchBuilder
java.lang.Object
org.eclipse.compare.patch.PatchBuilder
Builder for creating IFilePatch2 and IHunk objects as well as building
 relationship between them.
- Since:
- org.eclipse.compare.core 3.5
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final charLine prefix used to mark an added lines.static final charLine prefix used to mark context lines.static final charLine prefix used to mark an removed lines.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic IFilePatch2addHunks(IFilePatch2 filePatch, IHunk[] toAdd) Adds IHunks to a given IFilePatch2 and performs recalculation of all hunks' after positions.static IFilePatch2createFilePatch(IPath oldPath, long oldDate, IPath newPath, long newDate, IHunk[] hunks) Creates an IFilePatch2 instance and performs recalculation of all hunks' after positions.static IHunkcreateHunk(int start, String[] lines) Creates an IHunk instance.static IFilePatch2removeHunks(IFilePatch2 filePatch, IHunk[] toRemove) Removes IHunks from a given IFilePatch2 and performs recalculation of all hunks' after positions.
- 
Field Details- 
CONTEXT_PREFIXpublic static final char CONTEXT_PREFIXLine prefix used to mark context lines.- See Also:
 
- 
ADDITION_PREFIXpublic static final char ADDITION_PREFIXLine prefix used to mark an added lines.- See Also:
 
- 
REMOVAL_PREFIXpublic static final char REMOVAL_PREFIXLine prefix used to mark an removed lines.- See Also:
 
 
- 
- 
Constructor Details- 
PatchBuilderpublic PatchBuilder()
 
- 
- 
Method Details- 
createHunkCreates an IHunk instance.- Parameters:
- start- the start position in the before file
- lines- content of the hunk. Each line starts with a control character. Their meaning is as follows:- '+': add the line
- '-': delete the line
- ' ': no change, context line
 
- Returns:
- IHunk instance
 
- 
createFilePatchpublic static IFilePatch2 createFilePatch(IPath oldPath, long oldDate, IPath newPath, long newDate, IHunk[] hunks) Creates an IFilePatch2 instance and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
- oldPath- the path of the before state of the file
- oldDate- the timestamp of the before state of the file, see also- IFilePatch2.DATE_UNKNOWN
- newPath- the path of the after state of the file
- newDate- the timestamp of the after state of the file, see also- IFilePatch2.DATE_UNKNOWN
- hunks- a set of hunks to insert into IFilePatch2
- Returns:
- IFilePatch2 instance
 
- 
addHunksAdds IHunks to a given IFilePatch2 and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
- filePatch- a file patch to add hunks to
- toAdd- a set of IHunks to add
- Returns:
- newly created file patch with added hunks
 
- 
removeHunksRemoves IHunks from a given IFilePatch2 and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
- filePatch- a file patch to add hunks to
- toRemove- a set of IHunks to add
- Returns:
- newly created file patch with removed hunks
 
 
-