C# Class NGit.Diff.RawText

A Sequence supporting UNIX formatted text in byte[] format.
A Sequence supporting UNIX formatted text in byte[] format.

Elements of the sequence are the lines of the file, as delimited by the UNIX newline character ('\n'). The file content is treated as 8 bit binary text, with no assumptions or requirements on character encoding.

Note that the first line of the file is element 0, as defined by the Sequence interface API. Traditionally in a text editor a patch file the first line is line number 1. Callers may need to subtract 1 prior to invoking methods if they are converting from "line number" to "element index".

Inheritance: NGit.Diff.Sequence
Exibir arquivo Open project: red-gate/ngit Class Usage Examples

Public Properties

Property Type Description
EMPTY_TEXT RawText

Protected Properties

Property Type Description
content byte[]
lines NGit.Util.IntList

Public Methods

Method Description
GetLineDelimiter ( ) : string

Get the line delimiter for the first line.

Get the line delimiter for the first line.

GetString ( int i ) : string

Get the text for a single line.

Get the text for a single line.

GetString ( int begin, int end, bool dropLF ) : string

Get the text for a region of lines.

Get the text for a region of lines.

IsBinary ( InputStream raw ) : bool

Determine heuristically whether the bytes contained in a stream represents binary (as opposed to text) content.

Determine heuristically whether the bytes contained in a stream represents binary (as opposed to text) content. Note: Do not further use this stream after having called this method! The stream may not be fully read and will be left at an unknown position after consuming an unknown number of bytes. The caller is responsible for closing the stream.

IsBinary ( byte raw ) : bool

Determine heuristically whether a byte array represents binary (as opposed to text) content.

Determine heuristically whether a byte array represents binary (as opposed to text) content.

IsBinary ( byte raw, int length ) : bool

Determine heuristically whether a byte array represents binary (as opposed to text) content.

Determine heuristically whether a byte array represents binary (as opposed to text) content.

IsMissingNewlineAtEnd ( ) : bool

Determine if the file ends with a LF ('\n').

Determine if the file ends with a LF ('\n').

RawText ( FilePath file ) : NGit.Diff

Create a new sequence from a file.

Create a new sequence from a file.

The entire file contents are used.

RawText ( byte input ) : NGit.Diff

Create a new sequence from an existing content byte array.

Create a new sequence from an existing content byte array.

The entire array (indexes 0 through length-1) is used as the content.

Size ( ) : int
WriteLine ( OutputStream @out, int i ) : void

Write a specific line to the output stream, without its trailing LF.

Write a specific line to the output stream, without its trailing LF.

The specified line is copied as-is, with no character encoding translation performed.

If the specified line ends with an LF ('\n'), the LF is not copied. It is up to the caller to write the LF, if desired, between output lines.

Protected Methods

Method Description
Decode ( int start, int end ) : string

Decode a region of the text into a String.

Decode a region of the text into a String. The default implementation of this method tries to guess the character set by considering UTF-8, the platform default, and falling back on ISO-8859-1 if neither of those can correctly decode the region given.

Private Methods

Method Description
GetEnd ( int i ) : int
GetStart ( int i ) : int

Method Details

Decode() protected method

Decode a region of the text into a String.
Decode a region of the text into a String. The default implementation of this method tries to guess the character set by considering UTF-8, the platform default, and falling back on ISO-8859-1 if neither of those can correctly decode the region given.
protected Decode ( int start, int end ) : string
start int first byte of the content to decode.
end int one past the last byte of the content to decode.
return string

GetLineDelimiter() public method

Get the line delimiter for the first line.
Get the line delimiter for the first line.
public GetLineDelimiter ( ) : string
return string

GetString() public method

Get the text for a single line.
Get the text for a single line.
public GetString ( int i ) : string
i int /// index of the line to extract. Note this is 0-based, so line /// number 1 is actually index 0. ///
return string

GetString() public method

Get the text for a region of lines.
Get the text for a region of lines.
public GetString ( int begin, int end, bool dropLF ) : string
begin int /// index of the first line to extract. Note this is 0-based, so /// line number 1 is actually index 0. ///
end int index of one past the last line to extract.
dropLF bool /// if true the trailing CRLF or LF ('\n' or '\r\n') of the last returned line is /// dropped, if present. ///
return string

IsBinary() public static method

Determine heuristically whether the bytes contained in a stream represents binary (as opposed to text) content.
Determine heuristically whether the bytes contained in a stream represents binary (as opposed to text) content. Note: Do not further use this stream after having called this method! The stream may not be fully read and will be left at an unknown position after consuming an unknown number of bytes. The caller is responsible for closing the stream.
if input stream could not be read
public static IsBinary ( InputStream raw ) : bool
raw Sharpen.InputStream input stream containing the raw file content.
return bool

IsBinary() public static method

Determine heuristically whether a byte array represents binary (as opposed to text) content.
Determine heuristically whether a byte array represents binary (as opposed to text) content.
public static IsBinary ( byte raw ) : bool
raw byte the raw file content.
return bool

IsBinary() public static method

Determine heuristically whether a byte array represents binary (as opposed to text) content.
Determine heuristically whether a byte array represents binary (as opposed to text) content.
public static IsBinary ( byte raw, int length ) : bool
raw byte the raw file content.
length int /// number of bytes in /// raw /// to evaluate. This should be /// raw.length /// unless /// raw /// was over-allocated by /// the caller. ///
return bool

IsMissingNewlineAtEnd() public method

Determine if the file ends with a LF ('\n').
Determine if the file ends with a LF ('\n').
public IsMissingNewlineAtEnd ( ) : bool
return bool

RawText() public method

Create a new sequence from a file.
Create a new sequence from a file.

The entire file contents are used.

if Exceptions occur while reading the file ///
public RawText ( FilePath file ) : NGit.Diff
file Sharpen.FilePath the text file.
return NGit.Diff

RawText() public method

Create a new sequence from an existing content byte array.
Create a new sequence from an existing content byte array.

The entire array (indexes 0 through length-1) is used as the content.

public RawText ( byte input ) : NGit.Diff
input byte /// the content array. The array is never modified, so passing /// through cached arrays is safe. ///
return NGit.Diff

Size() public method

public Size ( ) : int
return int

WriteLine() public method

Write a specific line to the output stream, without its trailing LF.
Write a specific line to the output stream, without its trailing LF.

The specified line is copied as-is, with no character encoding translation performed.

If the specified line ends with an LF ('\n'), the LF is not copied. It is up to the caller to write the LF, if desired, between output lines.

the stream write operation failed.
public WriteLine ( OutputStream @out, int i ) : void
@out Sharpen.OutputStream
i int /// index of the line to extract. Note this is 0-based, so line /// number 1 is actually index 0. ///
return void

Property Details

EMPTY_TEXT public_oe static_oe property

A Rawtext of length 0
public static RawText,NGit.Diff EMPTY_TEXT
return RawText

content protected_oe property

The file content for this sequence.
The file content for this sequence.
protected byte[] content
return byte[]

lines protected_oe property

Map of line number to starting position within content .
protected IntList,NGit.Util lines
return NGit.Util.IntList