Package org.eclipse.jgit.util.io
Class AutoLFInputStream
java.lang.Object
java.io.InputStream
org.eclipse.jgit.util.io.AutoLFInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An InputStream that normalizes CRLF to LF.
Existing single CR are not changed to LF but are retained as is.
Optionally, a binary check on the first RawText.getBufferSize() bytes
is performed and in case of binary files, canonicalization is turned off (for
the complete file). If binary checking determines that the input is
CR/LF-delimited text and the stream has been created for checkout,
canonicalization is also turned off.
- Since:
- 4.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA special exception thrown whenAutoLFInputStreamis told to throw an exception when attempting to read a binary file.static enumFlags for controlling auto-detection of binary vs. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final byte[]private intprivate booleanprivate final booleanprivate final InputStreamprivate booleanSet totrueif the input was detected to be binary data.private booleanSet totrueif no CR/LF processing is to be done: if the input is binary data, or CR/LF-delimited text andAutoLFInputStream.StreamFlag.FOR_CHECKOUTwas given.private intprivate final byte[] -
Constructor Summary
ConstructorsConstructorDescriptionAutoLFInputStream(InputStream in, boolean detectBinary) Deprecated.AutoLFInputStream(InputStream in, boolean detectBinary, boolean abortIfBinary) Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)insteadAutoLFInputStream(InputStream in, Set<AutoLFInputStream.StreamFlag> flags) Creates a new InputStream, wrapping the specified stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static AutoLFInputStreamcreate(InputStream in, AutoLFInputStream.StreamFlag... flags) Factory method for creating anAutoLFInputStreamwith the specifiedflags.private booleanbooleanisBinary()Whether the stream has detected as a binary so far.intread()intread(byte[] bs, int off, int len) Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
single
private final byte[] single -
buf
private final byte[] buf -
in
-
cnt
private int cnt -
ptr
private int ptr -
passAsIs
private boolean passAsIsSet totrueif no CR/LF processing is to be done: if the input is binary data, or CR/LF-delimited text andAutoLFInputStream.StreamFlag.FOR_CHECKOUTwas given. -
isBinary
private boolean isBinarySet totrueif the input was detected to be binary data. -
detectBinary
private boolean detectBinary -
abortIfBinary
private final boolean abortIfBinary -
forCheckout
private final boolean forCheckout
-
-
Constructor Details
-
AutoLFInputStream
Creates a new InputStream, wrapping the specified stream.- Parameters:
in- raw input streamflags-AutoLFInputStream.StreamFlags controlling the stream behavior;nullis treated as an empty set- Since:
- 5.9
-
AutoLFInputStream
Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)insteadCreates a new InputStream, wrapping the specified stream.- Parameters:
in- raw input streamdetectBinary- whether binaries should be detected- Since:
- 2.0
-
AutoLFInputStream
Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)insteadCreates a new InputStream, wrapping the specified stream.- Parameters:
in- raw input streamdetectBinary- whether binaries should be detectedabortIfBinary- throw an IOException if the file is binary- Since:
- 3.3
-
-
Method Details
-
create
Factory method for creating anAutoLFInputStreamwith the specifiedflags.- Parameters:
in- raw input streamflags-AutoLFInputStream.StreamFlags controlling the stream behavior- Returns:
- a new
AutoLFInputStream - Since:
- 5.9
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
isBinary
public boolean isBinary()Whether the stream has detected as a binary so far.- Returns:
- true if the stream has detected as a binary so far.
- Since:
- 3.3
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
fillBuffer
- Throws:
IOException
-
create(InputStream, StreamFlag...)instead