Package org.eclipse.birt.core.archive
Class RAFolderInputStream
java.lang.Object
java.io.InputStream
org.eclipse.birt.core.archive.RAInputStream
org.eclipse.birt.core.archive.RAFolderInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
RAInputStream implementation for folder based report archive
-
Constructor Summary
ConstructorsConstructorDescriptionRAFolderInputStream(File file) RAFolderInputStream(HashSet<RAFolderInputStream> manager, File file) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read (or skipped over) from this random access input stream without blocking by the next caller of a method for this input stream.voidclose()Close the streamgetName()longlonglonglength()intread()The same behavior as InputStream.read().
Reads the next byte of data from the input stream.intread(byte[] b, int off, int len) The same behavior as InputStream.read(byte b[], int off, int len ).
Reads up to len bytes of data from the input stream into an array of bytes.final voidreadFully(byte[] b, int off, int len) The same behavior as RandomAccessFile.readFully(byte b[], int off, int len) Reads exactlylenbytes from this file into the byte array, starting at the current file pointer.intreadInt()Instead of calling randomAccessFile.readInt, we implement it in a better way (much better performace.) The external behavior is the same as RandomAccessFile.readInt().longreadLong()Reads a signed 64-bit integer from this file.voidrefresh()voidseek(long localPos) Move the file pointer to the new location in the streamMethods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
RAFolderInputStream
- Throws:
IOException
-
RAFolderInputStream
- Parameters:
file- - a regular file (i.e. stream) in the folder- Throws:
FileNotFoundExceptionIOException
-
-
Method Details
-
getName
-
refresh
- Specified by:
refreshin classRAInputStream- Throws:
IOException
-
read
The same behavior as InputStream.read().
Reads the next byte of data from the input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.A subclass must provide an implementation of this method.
- Specified by:
readin classInputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if an I/O error occurs.
-
read
The same behavior as InputStream.read(byte b[], int off, int len ).
Reads up to len bytes of data from the input stream into an array of bytes. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.A subclass must provide an implementation of this method.
- Overrides:
readin classInputStream- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached - Throws:
IOException- if an I/O error occurs.
-
readInt
Instead of calling randomAccessFile.readInt, we implement it in a better way (much better performace.) The external behavior is the same as RandomAccessFile.readInt().
Reads a signed 32-bit integer from this file. This method reads 4 bytes from the file, starting at the current file pointer. If the bytes read, in order, areb1,b2,b3, andb4, where0 <= b1, b2, b3, b4 <= 255, then the result is equal to:(b1 << 24) | (b2 << 16) + (b3 << 8) + b4
This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.
- Specified by:
readIntin classRAInputStream- Returns:
- the next four bytes of this stream, interpreted as an
int. - Throws:
EOFException- if this stream reaches the end before reading four bytes.IOException- if an I/O error occurs.
-
readLong
Reads a signed 64-bit integer from this file. This method reads eight bytes from the file, starting at the current file pointer. If the bytes read, in order, areb1,b2,b3,b4,b5,b6,b7, andb8,where:0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,then the result is equal to:
((long) b1 << 56) + ((long) b2 << 48) + ((long) b3 << 40) + ((long) b4 << 32) + ((long) b5 << 24) + ((long) b6 << 16) + ((long) b7 << 8) + b8This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.
- Specified by:
readLongin classRAInputStream- Returns:
- the next eight bytes of this file, interpreted as a
long. - Throws:
EOFException- if this file reaches the end before reading eight bytes.IOException- if an I/O error occurs.
-
readFully
The same behavior as RandomAccessFile.readFully(byte b[], int off, int len) Reads exactlylenbytes from this file into the byte array, starting at the current file pointer. This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.- Specified by:
readFullyin classRAInputStream- Parameters:
b- the buffer into which the data is read.off- the start offset of the data.len- the number of bytes to read.- Throws:
EOFException- if this file reaches the end before reading all the bytes.IOException- if an I/O error occurs.
-
getStreamLength
- Returns:
- the length of the stream
- Throws:
IOException
-
seek
Move the file pointer to the new location in the stream- Specified by:
seekin classRAInputStream- Parameters:
localPos- - the new local postion in the stream. The localPos starts from 0.- Throws:
IOException
-
getOffset
- Specified by:
getOffsetin classRAInputStream- Throws:
IOException
-
length
- Specified by:
lengthin classRAInputStream- Throws:
IOException
-
close
Close the stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
available
Description copied from class:RAInputStreamReturns the number of bytes that can be read (or skipped over) from this random access input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread.This abstract class is extended by
RAFolderInputStreamandRAFileInputStreamThe
availablemethod returns-1when no more data because the end of the stream has been reached.and returns
Integer.MAX_VALUEwhen bytes of data is larger then Integer.MAX_VALUE.- Specified by:
availablein classRAInputStream- Throws:
IOException
-