All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cosium.code.format.git.AutoCRLFObjectStream Maven / Gradle / Ivy

The newest version!
package com.cosium.code.format.git;

import static java.util.Objects.requireNonNull;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jgit.lib.CoreConfig.EolStreamType;
import org.eclipse.jgit.lib.ObjectStream;
import org.eclipse.jgit.util.io.EolStreamTypeUtil;

/**
 * @author Réda Housni Alaoui
 */
public class AutoCRLFObjectStream extends ObjectStream {

  private final ObjectStream delegate;
  private final InputStream autoCRLFInputStream;

  public AutoCRLFObjectStream(ObjectStream delegate, EolStreamType eolStreamType) {
    this.delegate = requireNonNull(delegate);
    this.autoCRLFInputStream =
        requireNonNull(EolStreamTypeUtil.wrapInputStream(delegate, eolStreamType));
  }

  @Override
  public int getType() {
    return delegate.getType();
  }

  @Override
  public long getSize() {
    return delegate.getSize();
  }

  @Override
  public int read() throws IOException {
    return autoCRLFInputStream.read();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy