public class CachedInputStream extends FileStream
The primary role of this class is to allow unpacked or serialized streams (from jars, or other sources) to
support mark() / restore() operations.
Secondly, if the stream is traversed multiple time, the cache component is a performance improvement.
FileStream.BOMStream.PrintMode| Modifier and Type | Field and Description |
|---|---|
private long |
len
The initial full size of the stream.
|
(package private) java.io.InputStream |
srcStream
The input stream used to populate internal memory buffer.
|
baseDirectoryName, binaryBuffer, decoder, file, fileName, lobDirectoryName, MAPPED_BUF_SZ_convert, binary, convert, convertCached, CR, CRLF, DELIM, doneIn, doneOut, EOF, increment, internalCp, isWindows, LF, mapEntryProtermcap, MODE_EXPORT, MODE_PUT_CONTROL, MODE_PUT_NORMAL, MODE_PUT_UNFORMATTED, NEW_LINES, NEWLINE, NEWLINE_LEN, noMap, PAGED_DEFAULT, PIPE_BROKEN_MESSAGE, SET_PAGED_DEFAULT, sourceCharset, sourceCp, streamCp, targetCharset, targetCp, UNKNOWN_VALUE| Constructor and Description |
|---|
CachedInputStream(byte[] ba)
Default constructor.
|
CachedInputStream(java.io.InputStream stream)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
assign(Stream stream)
Assigns the internal stream reference to the given reference.
|
void |
close()
Closes both the input and output streams and releases OS resources associated with it.
|
void |
closeIn()
Closes the input stream and releases OS resources associated with it.
|
void |
closeOut()
Closes the output stream and releases OS resources associated with it.
|
long |
getLen()
The length of the stream in bytes.
|
protected void |
initBinaryBuffer(long start,
long size)
Initialize the binary buffer storage with content of the file or steam to be read depending on class
implementation..
|
boolean |
isIn()
State of the input side of the stream.
|
boolean |
isOut()
State of the output side of the stream.
|
void |
setLen(long len)
Truncates or extends the stream to the specified length if this stream supports such an operation.
|
protected void |
unmap()
Clear/release the memory mapped buffer.
|
void |
write(byte[] data)
Write the given byte array to the output stream.
|
void |
write(byte[] data,
int off,
int len)
Write the specified range of bytes from the given byte array to the output stream.
|
void |
write(java.lang.String data)
Write the given string to the output stream.
|
void |
writeByte(byte b)
Write the given byte to the output stream.
|
void |
writeCh(char ch)
Write the given character to the output stream.
|
available, decode, decode, flush, flushData, getPos, getPosition, isFileResource, map, peekCh, readBOM, readByte, readBytes, readCh, readLn, setConvertSource, setInvalidBytesMapping, setLobDirectory, setPos, setPosition, writeBlob, writeClobadvancePage, afterWrite, assignDatum, cleanup, deleted, deregisterFooter, deregisterHeader, endOutput, endOutput, export, finished, flushControlled, forcePageBreak, forcePageBreak, generateStringFormat, getAvailableLines, getControl, getConvert, getDelimiter, getDisplayMode, getEcho, getEffectivePageSize, getLength, getName, getNextLineNum, getPageNum, getPageSize, getPendingRowCount, getPulseOnClose, getUnformatted, hasPageHeadersFooters, indexOfNewLine, isContiguous, isFreshPage, isKeepMessages, isNewLine, isSilent, isSuppressFormFeed, isTerm, isUnbuffered, isUnnamed, isValid, iterate, needsHeadersOutput, needsPageBreak, needsPageBreak, processFooters, processHeaders, processHeadersInt, processHeadersUncond, protectReads, protectWrites, pulseOutput, put, putControl, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putLineEnd, putLineEnd, putNull, putNull, putSpace, putSpace, putUnformatted, putWorker, rawGetNextLineNum, rawGetPageNum, rawGetPageSize, rawIncrementNextLineNum, rawIncrementPageNum, rawNextLineNum, rawPageSize, rawResetNextLineNum, rawSetPageSize, readBlock, readBlockRemote, readBlockWorker, readChar, readChar, readChunk, readField, readField, readField, readField, readFieldWorker, readLine, readLine, readLine, readLine, readLineCleanup, registerAdvanceListener, registerCloseListener, registerFlushListener, registerFooter, registerHeader, registerPageBreakListener, resetCurrentLine, retry, setAppend, setBinary, setContiguous, setControl, setConvert, setConvertSource, setConvertTarget, setConvertTarget, setDelimiter, setDelimiter, setEcho, setFlushBeforePut, setFont, setFont, setKeepMessages, setLandscape, setLobDirectory, setMap, setName, setNoMap, setPageSize, setPageSize, setPageSize, setPendingRowCount, setPortrait, setPosition, setPulseOnClose, setUnbuffered, setUnformatted, setUnnamed, skipField, skipLoneHyphenInput, startOutput, writeBlock, writeControlled, writeControlledSpecial, writeField, writeField, writeField, writeField, writeFieldclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitentry, initFailure, weightprivate final long len
java.io.InputStream srcStream
public CachedInputStream(java.io.InputStream stream)
throws java.io.IOException
InputStream as source for data.stream - The stream to be cached.java.io.IOException - if the stream's size cannot be queried or the stream cannot be read.public CachedInputStream(byte[] ba)
byte array as source for data.
For performance reasons, the data in parameter is NOT copied locally, but it is guaranteed, the byte array is not exposed externally and not otherwise modified.
ba - The data to be cached.public long getLen()
throws java.io.IOException
getLen in class FileStreamjava.io.IOException - In the event of an error while getting the length of the stream.public void setLen(long len)
throws java.lang.UnsupportedOperationException
setLen in class FileStreamlen - The new length of the file.java.lang.UnsupportedOperationException - Always.public void writeCh(char ch)
throws java.lang.UnsupportedOperationException
writeCh in class FileStreamch - The character to be written.java.lang.UnsupportedOperationException - Always.public void writeByte(byte b)
throws java.lang.UnsupportedOperationException
writeByte in class FileStreamb - The byte to be written.java.lang.UnsupportedOperationException - Always.public void write(java.lang.String data)
throws java.lang.UnsupportedOperationException
write in class FileStreamdata - The data to be written.java.lang.UnsupportedOperationException - Always.public void write(byte[] data)
throws java.lang.UnsupportedOperationException
write in class FileStreamdata - The data to be written.java.lang.UnsupportedOperationException - Always.public void write(byte[] data,
int off,
int len)
throws java.lang.UnsupportedOperationException
write in class FileStreamdata - The data to be written.off - Starting offset in data from which to read bytes to be written. Must be non-negative and
< data.length.len - Length of data to be written. Must be non-negative and <= (data.length - offset).java.lang.UnsupportedOperationException - Always.public void closeIn()
closeIn in class FileStreampublic void closeOut()
closeOut in class FileStreampublic void close()
close in class FileStreampublic boolean isIn()
isIn in class FileStreamtrue if the input side of the stream is active.public boolean isOut()
isOut in class FileStreamtrue if the output side of the stream is active.public void assign(Stream stream) throws java.lang.UnsupportedOperationException
assign in class FileStreamstream - The new internal stream reference to use for all operations.java.lang.UnsupportedOperationException - Always.protected void initBinaryBuffer(long start,
long size)
throws java.io.IOException
initBinaryBuffer in class FileStreamstart - The starting position inside source buffer. Not used in this class implementation.size - The size of the binary buffer to re-allocate.java.io.IOException - In the event of an error when decoding the bytes.protected void unmap()
unmap in class FileStream