|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.jgit.diff.RawText
public class RawText
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".
| Field Summary | |
|---|---|
protected byte[] |
content
The file content for this sequence. |
protected IntList |
hashes
Hash code for each line, for fast equality elimination. |
protected IntList |
lines
Map of line number to starting position within content. |
| Constructor Summary | |
|---|---|
RawText(byte[] input)
Create a new sequence from an existing content byte array. |
|
| Method Summary | |
|---|---|
boolean |
equals(int i,
Sequence other,
int j)
Determine if the i-th member is equal to the j-th member. |
protected int |
hashLine(byte[] raw,
int ptr,
int end)
Compute a hash code for a single line. |
boolean |
isMissingNewlineAtEnd()
Determine if the file ends with a LF ('\n'). |
int |
size()
|
void |
writeLine(java.io.OutputStream out,
int i)
Write a specific line to the output stream, without its trailing LF. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final byte[] content
protected final IntList lines
content.
protected final IntList hashes
| Constructor Detail |
|---|
public RawText(byte[] input)
The entire array (indexes 0 through length-1) is used as the content.
input - the content array. The array is never modified, so passing
through cached arrays is safe.| Method Detail |
|---|
public int size()
size in interface Sequence
public boolean equals(int i,
Sequence other,
int j)
Sequence
Implementations must ensure equals(thisIdx,other,otherIdx)
returns the same as other.equals(otherIdx,this,thisIdx).
equals in interface Sequencei - index within this sequence; must be in the range
[ 0, this.size() ).other - another sequence; must be the same implementation class, that
is this.getClass() == other.getClass().j - index within other sequence; must be in the range
[ 0, other.size() ).
public void writeLine(java.io.OutputStream out,
int i)
throws java.io.IOException
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.
out - stream to copy the line data onto.i - index of the line to extract. Note this is 0-based, so line
number 1 is actually index 0.
java.io.IOException - the stream write operation failed.public boolean isMissingNewlineAtEnd()
protected int hashLine(byte[] raw,
int ptr,
int end)
raw - the raw file content.ptr - first byte of the content line to hash.end - 1 past the last byte of the content line.
[ptr, end) of raw.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||