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
Afficher le fichier Open project: red-gate/ngit Class Usage Examples

Méthodes publiques

Свойство Type Description
EMPTY_TEXT RawText

Protected Properties

Свойство Type Description
content byte[]
lines NGit.Util.IntList

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode Description
GetEnd ( int i ) : int
GetStart ( int i ) : int

Method Details

Decode() protected méthode

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.
Résultat string

GetLineDelimiter() public méthode

Get the line delimiter for the first line.
Get the line delimiter for the first line.
public GetLineDelimiter ( ) : string
Résultat string

GetString() public méthode

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. ///
Résultat string

GetString() public méthode

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. ///
Résultat string

IsBinary() public static méthode

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.
Résultat bool

IsBinary() public static méthode

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.
Résultat bool

IsBinary() public static méthode

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. ///
Résultat bool

IsMissingNewlineAtEnd() public méthode

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

RawText() public méthode

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.
Résultat NGit.Diff

RawText() public méthode

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. ///
Résultat NGit.Diff

Size() public méthode

public Size ( ) : int
Résultat int

WriteLine() public méthode

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. ///
Résultat void

Property Details

EMPTY_TEXT public_oe static_oe property

A Rawtext of length 0
public static RawText,NGit.Diff EMPTY_TEXT
Résultat RawText

content protected_oe property

The file content for this sequence.
The file content for this sequence.
protected byte[] content
Résultat byte[]

lines protected_oe property

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