Package com.adobe.internal.io.stream
Class StreamManager
- java.lang.Object
-
- com.adobe.internal.io.stream.StreamManager
-
public final class StreamManager extends Object
Only for internal engineering use. This api can change without notice. The source for allInputByteStream
andOutputByteStream
instances.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close thisStreamManager
.void
close(boolean ignoreMaster)
Close thisStreamManager
.ByteWriter
getByteWriter(ByteWriterFactory.Fixed fixed, long size)
Create aByteWriter
.InputByteStream
getInputByteStream(byte[] b)
Only for internal engineering use.InputByteStream
getInputByteStream(ByteReader byteReader)
Only for internal engineering use.InputByteStream
getInputByteStream(ByteReader byteReader, long startOffset, long length)
Only for internal engineering use.InputByteStream
getInputByteStream(InputByteStream[] byteStreams)
Only for internal engineering use.OutputByteStream
getOutputByteStream(ByteWriter byteWriter)
Only for internal engineering use.OutputByteStream
getOutputByteStream(ByteWriterFactory.Longevity longevity, ByteWriterFactory.EncryptionStatus encryption, ByteWriterFactory.Fixed fixed, long size, boolean fast)
Create anOutputByteStream
for use within the PDF toolkit.OutputByteStream
getOutputByteStreamClearDocument(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.CLEAR This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is not encrypted nor is it decrypted.OutputByteStream
getOutputByteStreamClearTemp(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.CLEAR This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is not encrypted nor is it decrypted.OutputByteStream
getOutputByteStreamDecryptedDocument(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.DECRYPTED This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is decrypted.OutputByteStream
getOutputByteStreamDecryptedTemp(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.DECRYPTED This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is decrypted.OutputByteStream
getOutputByteStreamEncryptedDocument(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.ENCRYPTED This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is encrypted.OutputByteStream
getOutputByteStreamEncryptedTemp(ByteWriterFactory.Fixed fixed, long size)
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.ENCRYPTED This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is encrypted.OutputByteStream
getUnregisteredOutputByteStream(ByteWriter byteWriter)
Only for internal engineering use.OutputByteStream
getUnregisteredOutputByteStream(ByteWriterFactory.Fixed fixed, int size)
Create anOutputByteStream
for use within the COS layer of the PDF toolkit.static StreamManager
newInstance(ByteWriterFactory byteWriterFactory, ByteReader masterByteReader)
Creates a new instance of theStreamManager
.void
resetMasterByteReader(ByteReader masterByteReader)
Reset the masterByteReader
and close it and allInputByteStream
instances made from it.
-
-
-
Method Detail
-
newInstance
public static StreamManager newInstance(ByteWriterFactory byteWriterFactory, ByteReader masterByteReader)
Creates a new instance of theStreamManager
. TheByteWriterFactory
is used as the source of all new data sinks that are created. The "master"ByteReader
is the mainByteReader
used in the document processing. It is the backing store for the document. This will be closed and so will allInputByteStream
instances made from it when theStreamManager
is closed or the masterByteReader
is reset.- Parameters:
byteWriterFactory
- factory to use for creating newOutputByteStream
instancesmasterByteReader
- the "master" byte reader, can be null if there is no master- Returns:
- a newly created
StreamManager
-
resetMasterByteReader
public void resetMasterByteReader(ByteReader masterByteReader) throws IOException
Reset the masterByteReader
and close it and allInputByteStream
instances made from it.- Parameters:
masterByteReader
- the new masterByteReader
, can be null- Throws:
IOException
-
getInputByteStream
public InputByteStream getInputByteStream(ByteReader byteReader) throws IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStream
from aByteReader
.- Parameters:
byteReader
- AByteReader
to be used for creating theInputByteStream
.- Returns:
- An
InputByteStream
. - Throws:
IOException
-
getInputByteStream
public InputByteStream getInputByteStream(ByteReader byteReader, long startOffset, long length) throws IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStream
from aByteReader
.- Parameters:
byteReader
- AByteReader
to be used for creating theInputByteStream
.- Returns:
- An
InputByteStream
. - Throws:
IOException
-
getInputByteStream
public InputByteStream getInputByteStream(byte[] b) throws IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStream
from a byte array.- Parameters:
b
- An array of bytes to be used for creating theInputByteStream
.- Returns:
- An
InputByteStream
. - Throws:
IOException
-
getInputByteStream
public InputByteStream getInputByteStream(InputByteStream[] byteStreams) throws IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStream
. This creates anOutputByteStream
that wraps multipleOutputByteStream
objects and makes them appear as one largeOutputByteStream
. TheOutputByteStream
objects that are passed must not be modified in any way until the wrappingOutputByteStream
returned from this method is no longer in use.- Parameters:
byteStreams
- An array ofOutputByteStream
objects.- Returns:
- An
OutputByteStream
. - Throws:
IOException
-
getOutputByteStream
public OutputByteStream getOutputByteStream(ByteWriter byteWriter) throws IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStream
from aByteWriter
.- Parameters:
byteWriter
- AByteWriter
to be used for creating theOutputByteStream
.- Returns:
- An
OutputByteStream
. - Throws:
IOException
-
getUnregisteredOutputByteStream
public OutputByteStream getUnregisteredOutputByteStream(ByteWriter byteWriter) throws IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStream
from aByteWriter
. The returnedOutputByteStream
is unregistered and so will not be managed by the stream manager. It is the responsibility of the caller to ensure that theByteWriter
and theOutputByteStream
are properly closed.- Parameters:
byteWriter
- AByteWriter
to be used for creating theOutputByteStream
.- Returns:
- An
OutputByteStream
. - Throws:
IOException
-
getOutputByteStreamClearTemp
public OutputByteStream getOutputByteStreamClearTemp(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.CLEAR This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is not encrypted nor is it decrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getOutputByteStreamEncryptedTemp
public OutputByteStream getOutputByteStreamEncryptedTemp(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.ENCRYPTED This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is encrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getOutputByteStreamDecryptedTemp
public OutputByteStream getOutputByteStreamDecryptedTemp(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.TEMPORARY
EncryptionStatus - EncryptionStatus.DECRYPTED This is intended to create anOutputByteStream
whose duration is temporary (lasting the duration of a single method) and the data to be stored is decrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getOutputByteStreamClearDocument
public OutputByteStream getOutputByteStreamClearDocument(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.CLEAR This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is not encrypted nor is it decrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getOutputByteStreamEncryptedDocument
public OutputByteStream getOutputByteStreamEncryptedDocument(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.ENCRYPTED This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is encrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getOutputByteStreamDecryptedDocument
public OutputByteStream getOutputByteStreamDecryptedDocument(ByteWriterFactory.Fixed fixed, long size) throws IOException
A utility function that callsgetOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
with the following parameters:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.DECRYPTED This is intended to create anOutputByteStream
whose expected duration of existence is of similar length to that of thePDFDocument
and the data to be stored is decrypted.- Parameters:
fixed
- whether the memory size is fixed or growablesize
- the number of bytes forOutputByteStream
- Returns:
- the newly created
OutputByteStream
- Throws:
IOException
-
getUnregisteredOutputByteStream
public OutputByteStream getUnregisteredOutputByteStream(ByteWriterFactory.Fixed fixed, int size) throws IOException
Create anOutputByteStream
for use within the COS layer of the PDF toolkit. ThisOutputByteStream
will not be kept track of through an internal registry and if not used correctly and carefully can lead to problems. This is not to be used outside of the COS layer. If it is desired to turn theOutputByteStream
into anInputByteStream
this can be done by using theOutputByteStream.closeAndConvert()
method.- Parameters:
fixed
- is theOutputByteStream
of a fixed size or notsize
- the actual size of a fixedOutputByteStream
or an estimate of a growable one- Returns:
- a stream for writing data to
- Throws:
IOException
-
getOutputByteStream
public OutputByteStream getOutputByteStream(ByteWriterFactory.Longevity longevity, ByteWriterFactory.EncryptionStatus encryption, ByteWriterFactory.Fixed fixed, long size, boolean fast) throws IOException
Create anOutputByteStream
for use within the PDF toolkit. ThisOutputByteStream
will be kept track of through an internal registry and will need to be properly closed by the caller. If it is desired to turn theOutputByteStream
into anInputByteStream
this can be done by using theOutputByteStream.closeAndConvert()
method.- Parameters:
longevity
- an estimate of how long theOutputByteStream
will remain in useencryption
- the encryption status of the contents of theOutputByteStream
fixed
- is theOutputByteStream
of a fixed size or notsize
- the actual size of a fixedOutputByteStream
or an estimate of a growable onefast
- a request for a fasterOutputByteStream
which is only a suggestion- Returns:
- a stream for writing data to
- Throws:
IOException
-
getByteWriter
public ByteWriter getByteWriter(ByteWriterFactory.Fixed fixed, long size) throws IOException
Create aByteWriter
. ThisByteWriter
is not kept track of and will need to be properly closed by the caller. This is a potentially large resource leak if used improperly. Be extremely careful. This method is only in place for one place within the code that will soon be rewritten. Do not use for new code.This method has similar parameters as
getOutputByteStream(Longevity, EncryptionStatus, Fixed, long, boolean)
but makes the following default choices:
Longevity - Longevity.LONG
EncryptionStatus - EncryptionStatus.CLEAR- Parameters:
fixed
- is theOutputByteStream
of a fixed size or notsize
- the actual size of a fixedOutputByteStream
or an estimate of a growable one- Returns:
- a stream for writing data to
- Throws:
IOException
-
close
public void close() throws IOException
Close thisStreamManager
. This closes all openByteReader
instances and anyInputByteStream
instances made from. TheByteWriterFactory
given during construction is also closed. In the future if there are openByteReader
instances this will be considered an error state and an exception will be thrown.- Throws:
IOException
-
close
public void close(boolean ignoreMaster) throws IOException
Close thisStreamManager
. This closes all openByteReader
instances and anyInputByteStream
instances made from. TheByteWriterFactory
given during construction is also closed. In the future if there are openByteReader
instances this will be considered an error state and an exception will be thrown.- Parameters:
ignoreMaster
- iftrue
the master ByteReader is ignored for closing and it will be the responsibility of the caller to close it- Throws:
IOException
-
-