Package org.verapdf.as.io
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 Summary
Fields Modifier and Type Field Description protected boolean
isClosed
protected boolean
isSourceClosed
protected IntReference
resourceUsers
-
Constructor Summary
Constructors Constructor Description ASInputStream()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
abstract void
closeResource()
Closes stream resource.static ASInputStream
createStreamFromStream(ASInputStream stream)
Creates copy of stream.abstract void
decrementResourceUsers()
Method decrements number of resource users.abstract void
incrementResourceUsers()
Method increments number of resource users.abstract int
read()
abstract int
read(byte[] buffer, int size)
abstract void
reset()
abstract int
skip(int size)
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
-
-
-
-
Field Detail
-
isClosed
protected boolean isClosed
-
isSourceClosed
protected boolean isSourceClosed
-
resourceUsers
protected IntReference resourceUsers
-
-
Method Detail
-
read
public abstract int read() throws IOException
- Specified by:
read
in classInputStream
- 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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
reset
public abstract void reset() throws IOException
- Overrides:
reset
in classInputStream
- 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. {@see closeResource}
-
decrementResourceUsers
public abstract void decrementResourceUsers()
Method decrements number of resource users. {@see closeResource}
-
createStreamFromStream
public static ASInputStream createStreamFromStream(ASInputStream stream)
Creates copy of stream. The two streams can be closed separately.
-
-