Class ExtendedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.filenet.api.util.ExtendedInputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable
public abstract class ExtendedInputStream extends java.io.InputStreamAnExtendedInputStreamis an input stream that can retrieve content at arbitrary positions within the stream. TheExtendedInputStreamclass includes methods that can read a certain number of bytes from the stream or read an unspecified number of bytes. The stream keeps track of the last byte position that was read. You can specify a position in the input stream to get to a later or earlier position within the stream.Although
ExtendedInputStreamsupports all types of storage devices, the ability to efficiently seek within a content stream is limited to the capabilities of the underlying media, and might not be appropriate for some types of storage devices. For example, theFileStorageArea,CmAdvancedStorageAreafile system storage device and content that has been cached in the content cache are optimized to do native re-positioning of the input stream and, therefore, can efficiently seek within a content stream.
-
-
Constructor Summary
Constructors Constructor and Description ExtendedInputStream()
-
Method Summary
Methods Modifier and Type Method and Description abstract longposition()Returns the current position in this stream.abstract voidposition(long newPosition)Sets this input stream's position.intread()The standardjava.io.InputStream.read()method.intread(byte[] buffer)The standardjava.io.InputStream.read(byte[] b)method.intreadAt(long position, byte[] b, int offset, int len)Sets the input stream to the specified position, then reads up tolenbytes of data from the input stream into an array of bytes.abstract longsize()Returns the total size of the underlying content.abstract booleansizeSupported()Returnstrueif this input stream can return the total size of the underlying content.
-
-
-
Method Detail
-
position
public abstract long position() throws java.io.IOExceptionReturns the current position in this stream. The position is a non-negative integer counting the number of bytes from the beginning of the stream to the current position- Throws:
java.io.IOException
-
position
public abstract void position(long newPosition) throws java.io.IOExceptionSets this input stream's position. The next read operation begins reading from the input stream at this position. You can set the position to a value that is greater than the current size, but doing so does not change the size of the entity. A later attempt to read bytes at such a position will immediately return an end-of-file indication. If you set the position to a value of less than zero (0), this method throws an exception.- Parameters:
newPosition- Alongthat specifies the offset into the stream (from the beginning of the streamed data) at which to set the position.- Throws:
java.io.IOException- If an I/O error occurs.EngineRuntimeException- Throws EngineRuntimeException withExceptionCode.API_EXTENDED_STREAM_INVALID_POSITIONif the position specified is less than zero (0).
-
read
public int read() throws java.io.IOExceptionThe standardjava.io.InputStream.read()method. Refer to the Java Platform Standard Edition documentation for details about the use of this method.- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer) throws java.io.IOExceptionThe standardjava.io.InputStream.read(byte[] b)method. Refer to the Java Platform Standard Edition documentation for details about the use of this method.- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
readAt
public int readAt(long position, byte[] b, int offset, int len) throws java.io.IOExceptionSets the input stream to the specified position, then reads up tolenbytes of data from the input stream into an array of bytes. This method attempts to read as many aslenbytes, but a smaller number might be read. The number of bytes read is returned as an integer.This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. This method does not close the embedded stream when the end of the file is reached.
If
lenis zero (0), then no bytes are read and this method returns 0; otherwise, this method attempts to read at least one byte. If no byte is available because the stream is at end of file, this method returns -1; otherwise, this method reads at least one byte and stores the value intob.The first byte read is stored into element b[offset], the next one into b[offset+1], and so on. The number of bytes read is, at most, equal to
len. Let k be the number of bytes actually read; these bytes will be stored in elements b[offset] through b[offset+k-1], leaving elements b[offset+k] through b[offset+len-1] unaffected.In every case, elements b[0] through b[offset] and elements b[offset+len] through b[b.length-1] are unaffected.
- Parameters:
position- Alongthat specifies the position from which to begin reading the input stream.b- An array of bytes that is the buffer into which the data is read. When this method returns, the buffer contains the specified byte array with the values between offset and (offset+len-1) replaced by the bytes read from the current source.offset- The byte offset in arraybat which to begin writing the data read from the current input stream.len- The maximum number of bytes to read from the current stream.- Returns:
- The total number of bytes read into the buffer, or -1 if the end of the stream is
reached. Returns zero (0) if
lenis zero. - Throws:
java.io.IOException- If an I/O error occurs.
-
sizeSupported
public abstract boolean sizeSupported()
Returnstrueif this input stream can return the total size of the underlying content.
-
size
public abstract long size() throws java.io.IOExceptionReturns the total size of the underlying content. Call thesizeSupported()method before callingsize()to determine whether the input stream supports returning a size.- Throws:
java.io.IOException- If an I/O error occurs.EngineRuntimeException- Throws EngineRuntimeException withExceptionCode.API_EXTENDED_STREAM_SIZE_UNAVAILABLEif this input stream does not support returning a size (sizeSupportedreturnsfalse).
-
-