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 class
A special exception thrown whenAutoLFInputStream
is told to throw an exception when attempting to read a binary file.static enum
Flags for controlling auto-detection of binary vs. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final byte[]
private int
private boolean
private final boolean
private final InputStream
private boolean
Set totrue
if the input was detected to be binary data.private boolean
Set totrue
if no CR/LF processing is to be done: if the input is binary data, or CR/LF-delimited text andAutoLFInputStream.StreamFlag.FOR_CHECKOUT
was given.private int
private 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 TypeMethodDescriptionvoid
close()
static AutoLFInputStream
create
(InputStream in, AutoLFInputStream.StreamFlag... flags) Factory method for creating anAutoLFInputStream
with the specifiedflags
.private boolean
boolean
isBinary()
Whether the stream has detected as a binary so far.int
read()
int
read
(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 totrue
if no CR/LF processing is to be done: if the input is binary data, or CR/LF-delimited text andAutoLFInputStream.StreamFlag.FOR_CHECKOUT
was given. -
isBinary
private boolean isBinarySet totrue
if 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.StreamFlag
s controlling the stream behavior;null
is 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 anAutoLFInputStream
with the specifiedflags
.- Parameters:
in
- raw input streamflags
-AutoLFInputStream.StreamFlag
s controlling the stream behavior- Returns:
- a new
AutoLFInputStream
- Since:
- 5.9
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
fillBuffer
- Throws:
IOException
-
create(InputStream, StreamFlag...)
instead