Class ASInputStream

java.lang.Object
java.io.InputStream
org.verapdf.as.io.ASInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
ASConcatenatedInputStream, ASInFilter, ASInputStreamWrapper, SeekableInputStream

public abstract class ASInputStream extends InputStream
Base class for stream hierarchy. Has methods for resource management. Please don't forget to close all the opened streams.
Author:
Timur Kamalov
  • Field Details

    • isClosed

      protected boolean isClosed
    • isSourceClosed

      protected boolean isSourceClosed
    • resourceUsers

      protected IntReference resourceUsers
  • Constructor Details

    • ASInputStream

      public ASInputStream()
  • Method Details

    • read

      public abstract int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public abstract int read(byte[] buffer, int size) throws IOException
      Throws:
      IOException
    • skip

      public abstract int skip(int size) throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • reset

      public abstract void reset() throws IOException
      Overrides:
      reset in class InputStream
      Throws:
      IOException
    • closeResource

      public abstract void closeResource() throws IOException
      Closes stream resource. There is a difference between closing stream and closing it's resource. Several streams may have the same resource (e. g. the same file stream) and resource should be closed only after all streams using it are closed.
      Throws:
      IOException
    • incrementResourceUsers

      public abstract void incrementResourceUsers()
      Method increments number of resource users.
    • decrementResourceUsers

      public abstract void decrementResourceUsers()
      Method decrements number of resource users.
    • createStreamFromStream

      public static ASInputStream createStreamFromStream(ASInputStream stream)
      Creates copy of stream. The two streams can be closed separately.