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 8kB 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
  • Field Details

    • single

      private final byte[] single
    • buf

      private final byte[] buf
    • in

      private final InputStream in
    • cnt

      private int cnt
    • ptr

      private int ptr
    • passAsIs

      private boolean passAsIs
      Set to true if no CR/LF processing is to be done: if the input is binary data, or CR/LF-delimited text and AutoLFInputStream.StreamFlag.FOR_CHECKOUT was given.
    • isBinary

      private boolean isBinary
      Set to true 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

      public AutoLFInputStream(InputStream in, Set<AutoLFInputStream.StreamFlag> flags)
      Creates a new InputStream, wrapping the specified stream.
      Parameters:
      in - raw input stream
      flags - AutoLFInputStream.StreamFlags 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, use create(InputStream, StreamFlag...) instead
      Creates a new InputStream, wrapping the specified stream.
      Parameters:
      in - raw input stream
      detectBinary - whether binaries should be detected
      Since:
      2.0
    • AutoLFInputStream

      @Deprecated public AutoLFInputStream(InputStream in, boolean detectBinary, boolean abortIfBinary)
      Deprecated.
      since 5.9, use create(InputStream, StreamFlag...) instead
      Creates a new InputStream, wrapping the specified stream.
      Parameters:
      in - raw input stream
      detectBinary - whether binaries should be detected
      abortIfBinary - throw an IOException if the file is binary
      Since:
      3.3
  • Method Details