Eclipse Platform
Release 3.3

org.eclipse.compare.patch
Interface IHunk


public interface IHunk

Interface that represents a hunk. A hunk is a portion of a patch. It identifies where the hunk is to be located in the target file. One use of this interface is a means to communicate to content merge viewers that one of the sides of a compare input is a patch hunk. Clients can determine which side it is by adapting the side to this interface (see IAdaptable.

This interface is not intended to be implemented by clients but can be obtained from an IFilePatchResult

Since:
3.3

Method Summary
 String getCharset()
          Returns the name of a charset encoding to be used when decoding the contents of this hunk into characters.
 String getLabel()
          Return a label that can be used to describe the hunk.
 InputStream getOriginalContents()
          Return the original contents from which the hunk was generated.
 InputStream getPatchedContents()
          Return the contents that contain the modifications for this hunk.
 int getStartPosition()
          Return the start position of the hunk in the target file.
 

Method Detail

getLabel

public String getLabel()
Return a label that can be used to describe the hunk.

Returns:
a label that can be used to describe the hunk

getStartPosition

public int getStartPosition()
Return the start position of the hunk in the target file.

Returns:
the start position of the hunk in the target file.

getOriginalContents

public InputStream getOriginalContents()
Return the original contents from which the hunk was generated. The returned contents usually only represent a portion of the file from which the hunk was generated.

Returns:
the original contents from which the hunk was generated

getPatchedContents

public InputStream getPatchedContents()
Return the contents that contain the modifications for this hunk. The returned contents usually only represent a portion of the file that was modified.

Returns:
the contents that contain the modifications for this hunk

getCharset

public String getCharset()
                  throws CoreException
Returns the name of a charset encoding to be used when decoding the contents of this hunk into characters. Returns null if a proper encoding cannot be determined.

Note that this method does not check whether the result is a supported charset name. Callers should be prepared to handle UnsupportedEncodingException where this charset is used.

Returns:
the name of a charset, or null
Throws:
CoreException - if an error happens while determining the charset. See any refinements for more information.
See Also:
IEncodedStorage

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.