C# Класс 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".

Наследование: NGit.Diff.Sequence
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
EMPTY_TEXT RawText

Защищенные свойства (Protected)

Свойство Тип Описание
content byte[]
lines NGit.Util.IntList

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
GetEnd ( int i ) : int
GetStart ( int i ) : int

Описание методов

Decode() защищенный Метод

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.
Результат string

GetLineDelimiter() публичный Метод

Get the line delimiter for the first line.
Get the line delimiter for the first line.
public GetLineDelimiter ( ) : string
Результат string

GetString() публичный Метод

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. ///
Результат string

GetString() публичный Метод

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. ///
Результат string

IsBinary() публичный статический Метод

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.
Результат bool

IsBinary() публичный статический Метод

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.
Результат bool

IsBinary() публичный статический Метод

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. ///
Результат bool

IsMissingNewlineAtEnd() публичный Метод

Determine if the file ends with a LF ('\n').
Determine if the file ends with a LF ('\n').
public IsMissingNewlineAtEnd ( ) : bool
Результат bool

RawText() публичный Метод

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.
Результат NGit.Diff

RawText() публичный Метод

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. ///
Результат NGit.Diff

Size() публичный Метод

public Size ( ) : int
Результат int

WriteLine() публичный Метод

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. ///
Результат void

Описание свойств

EMPTY_TEXT публичное статическое свойство

A Rawtext of length 0
public static RawText,NGit.Diff EMPTY_TEXT
Результат RawText

content защищенное свойство

The file content for this sequence.
The file content for this sequence.
protected byte[] content
Результат byte[]

lines защищенное свойство

Map of line number to starting position within content .
protected IntList,NGit.Util lines
Результат NGit.Util.IntList