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
public class AutoLFInputStream extends InputStream
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 Classes Modifier and Type Class Description static class
AutoLFInputStream.IsBinaryException
A special exception thrown whenAutoLFInputStream
is told to throw an exception when attempting to read a binary file.static class
AutoLFInputStream.StreamFlag
Flags for controlling auto-detection of binary vs.
-
Constructor Summary
Constructors Constructor Description AutoLFInputStream(InputStream in, boolean detectBinary)
Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)
insteadAutoLFInputStream(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static AutoLFInputStream
create(InputStream in, AutoLFInputStream.StreamFlag... flags)
Factory method for creating anAutoLFInputStream
with the specifiedflags
.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, transferTo
-
-
-
-
Constructor Detail
-
AutoLFInputStream
public AutoLFInputStream(InputStream in, Set<AutoLFInputStream.StreamFlag> flags)
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 public AutoLFInputStream(InputStream in, boolean detectBinary)
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 public AutoLFInputStream(InputStream in, boolean detectBinary, boolean abortIfBinary)
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 Detail
-
create
public static AutoLFInputStream create(InputStream in, AutoLFInputStream.StreamFlag... flags)
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
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] bs, int off, int len) throws IOException
- 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
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
-