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 booleanisClosedprotected booleanisSourceClosedprotected IntReferenceresourceUsers
-
Constructor Summary
Constructors Constructor Description ASInputStream()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()abstract voidcloseResource()Closes stream resource.static ASInputStreamcreateStreamFromStream(ASInputStream stream)Creates copy of stream.abstract voiddecrementResourceUsers()Method decrements number of resource users.abstract voidincrementResourceUsers()Method increments number of resource users.abstract intread()abstract intread(byte[] buffer, int size)abstract voidreset()abstract intskip(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:
readin 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
reset
public abstract void reset() throws IOException- Overrides:
resetin classInputStream- Throws:
IOException
-
closeResource
public abstract void closeResource() throws IOExceptionCloses 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.
-
-