Class ComparatorInputStream

java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.eclipse.tycho.artifactcomparator.ComparatorInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class ComparatorInputStream extends ByteArrayInputStream
Input stream to carry some important information for comparison and allows direct access to the underlying buffer.
Author:
christoph
  • Constructor Details

    • ComparatorInputStream

      public ComparatorInputStream(InputStream stream) throws IOException
      Throws:
      IOException
    • ComparatorInputStream

      public ComparatorInputStream(byte[] content)
  • Method Details

    • size

      public int size()
      Returns:
      the total number of bytes of this stream
    • asNewStream

      public InputStream asNewStream()
      Returns:
      a new stream backed by this stream data that could be read independently
    • asString

      public String asString(Charset charset)
      Parameters:
      charset -
      Returns:
      the content of this stream as a string with the given charset
    • asBytes

      public byte[] asBytes()
    • compare

      public ArtifactDelta compare(ComparatorInputStream other)
      Compares this stream directly to another stream on a by-by-byte basis, this is independent of the state of the streams, e.g number of bytes read, closing or mark state.
      Parameters:
      other -
      Returns:
      ArtifactDelta.DEFAULT if there is any difference or null otherwise.