Package org.verapdf.io
Class InternalInputStream
java.lang.Object
java.io.InputStream
org.verapdf.as.io.ASInputStream
org.verapdf.io.SeekableInputStream
org.verapdf.io.InternalInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,BaseParserInputStream
ASInputStream for reading data from file.
It contains methods for file closing management.
- Author:
- Timur Kamalov
-
Field Summary
Fields inherited from class org.verapdf.as.io.ASInputStream
isClosed, isSourceClosed, resourceUsers -
Constructor Summary
ConstructorsConstructorDescriptionInternalInputStream(File file) InternalInputStream(File file, boolean isTempFile) InternalInputStream(File file, int numOfFileUsers, boolean isTempFile) InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile) InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile, int bufferSize) InternalInputStream(String fileName) InternalInputStream(String fileName, int numOfFileUsers) -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses stream resource.static InternalInputStreamcreateConcatenated(byte[] alreadyRead, InputStream stream, Integer maxStreamSize) Constructor writes into temp file passed buffer, then passed stream.longlongGets offset of current byte.getSeekableStream(long startOffset, long length) getStream(long startOffset, long length) Gets substream of this stream that starts at given offset and has given length.longGets total length of stream.voidmark(int readlimit) booleanintpeek()Gets next byte without reading it.intread()intread(byte[] buffer, int size) voidreset()voidseek(long offset) Goes to a particular byte in stream.intskip(int size) Methods inherited from class org.verapdf.io.SeekableInputStream
decrementResourceUsers, getSeekableStream, getSeekableStream, incrementResourceUsers, isEOF, readByte, seekFromCurrentPosition, seekFromEnd, unread, unreadMethods inherited from class org.verapdf.as.io.ASInputStream
close, createStreamFromStreamMethods inherited from class java.io.InputStream
available, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.verapdf.parser.BaseParserInputStream
close, read
-
Constructor Details
-
InternalInputStream
- Throws:
IOException
-
InternalInputStream
- Throws:
IOException
-
InternalInputStream
- Throws:
IOException
-
InternalInputStream
- Throws:
IOException
-
InternalInputStream
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile) throws IOException - Throws:
IOException
-
InternalInputStream
public InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile, int bufferSize) throws IOException - Throws:
IOException
-
-
Method Details
-
createConcatenated
public static InternalInputStream createConcatenated(byte[] alreadyRead, InputStream stream, Integer maxStreamSize) throws IOException Constructor writes into temp file passed buffer, then passed stream. After that, InternalInputStream from file is created.- Parameters:
alreadyRead- is byte array of data that was already read from the beginning of stream.stream- is data left in stream.- Throws:
IOException
-
read
- Specified by:
readin interfaceBaseParserInputStream- Specified by:
readin classASInputStream- Throws:
IOException
-
read
- Specified by:
readin classASInputStream- Throws:
IOException
-
skip
- Specified by:
skipin interfaceBaseParserInputStream- Specified by:
skipin classASInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Specified by:
resetin classASInputStream- Throws:
IOException
-
seek
Description copied from class:SeekableInputStreamGoes to a particular byte in stream.- Specified by:
seekin classSeekableInputStream- Parameters:
offset- is offset of a byte to go to.- Throws:
IOException
-
peek
Description copied from class:SeekableInputStreamGets next byte without reading it.- Specified by:
peekin interfaceBaseParserInputStream- Specified by:
peekin classSeekableInputStream- Returns:
- next byte.
- Throws:
IOException
-
getOffset
Description copied from class:SeekableInputStreamGets offset of current byte.- Specified by:
getOffsetin classSeekableInputStream- Returns:
- offset of byte to be read next.
- Throws:
IOException
-
getCurrentOffset
public long getCurrentOffset()- Specified by:
getCurrentOffsetin classSeekableInputStream
-
getStream
Description copied from class:SeekableInputStreamGets substream of this stream that starts at given offset and has given length.- Specified by:
getStreamin classSeekableInputStream- Parameters:
startOffset- is starting offset of substream.length- is length of substream.- Throws:
IOException
-
getSeekableStream
- Specified by:
getSeekableStreamin classSeekableInputStream- Throws:
IOException
-
closeResource
Description copied from class:ASInputStreamCloses 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.- Specified by:
closeResourcein classASInputStream- Throws:
IOException
-
getStreamLength
Description copied from class:SeekableInputStreamGets total length of stream.- Specified by:
getStreamLengthin classSeekableInputStream- Returns:
- length of stream in bytes.
- Throws:
IOException
-