Package com.adobe.internal.io.stream
Class StreamManager
- java.lang.Object
-
- com.adobe.internal.io.stream.StreamManager
-
public final class StreamManager extends java.lang.ObjectOnly for internal engineering use. This api can change without notice. The source for allInputByteStreamandOutputByteStreaminstances.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close thisStreamManager.voidclose(boolean ignoreMaster)Close thisStreamManager.ByteWritergetByteWriter(ByteWriterFactory.Fixed fixed, long size)Create aByteWriter.InputByteStreamgetInputByteStream(byte[] b)Only for internal engineering use.InputByteStreamgetInputByteStream(ByteReader byteReader)Only for internal engineering use.InputByteStreamgetInputByteStream(ByteReader byteReader, long startOffset, long length)Only for internal engineering use.InputByteStreamgetInputByteStream(InputByteStream[] byteStreams)Only for internal engineering use.OutputByteStreamgetOutputByteStream(ByteWriter byteWriter)Only for internal engineering use.OutputByteStreamgetOutputByteStream(ByteWriterFactory.Longevity longevity, ByteWriterFactory.EncryptionStatus encryption, ByteWriterFactory.Fixed fixed, long size, boolean fast)Create anOutputByteStreamfor use within the PDF toolkit.OutputByteStreamgetOutputByteStreamClearDocument(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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand the data to be stored is not encrypted nor is it decrypted.OutputByteStreamgetOutputByteStreamClearTemp(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 anOutputByteStreamwhose duration is temporary (lasting the duration of a single method) and the data to be stored is not encrypted nor is it decrypted.OutputByteStreamgetOutputByteStreamDecryptedDocument(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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand the data to be stored is decrypted.OutputByteStreamgetOutputByteStreamDecryptedTemp(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 anOutputByteStreamwhose duration is temporary (lasting the duration of a single method) and the data to be stored is decrypted.OutputByteStreamgetOutputByteStreamEncryptedDocument(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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand the data to be stored is encrypted.OutputByteStreamgetOutputByteStreamEncryptedTemp(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 anOutputByteStreamwhose duration is temporary (lasting the duration of a single method) and the data to be stored is encrypted.OutputByteStreamgetUnregisteredOutputByteStream(ByteWriter byteWriter)Only for internal engineering use.OutputByteStreamgetUnregisteredOutputByteStream(ByteWriterFactory.Fixed fixed, int size)Create anOutputByteStreamfor use within the COS layer of the PDF toolkit.static StreamManagernewInstance(ByteWriterFactory byteWriterFactory, ByteReader masterByteReader)Creates a new instance of theStreamManager.voidresetMasterByteReader(ByteReader masterByteReader)Reset the masterByteReaderand close it and allInputByteStreaminstances made from it.
-
-
-
Method Detail
-
newInstance
public static StreamManager newInstance(ByteWriterFactory byteWriterFactory, ByteReader masterByteReader)
Creates a new instance of theStreamManager. TheByteWriterFactoryis used as the source of all new data sinks that are created. The "master"ByteReaderis the mainByteReaderused in the document processing. It is the backing store for the document. This will be closed and so will allInputByteStreaminstances made from it when theStreamManageris closed or the masterByteReaderis reset.- Parameters:
byteWriterFactory- factory to use for creating newOutputByteStreaminstancesmasterByteReader- the "master" byte reader, can be null if there is no master- Returns:
- a newly created
StreamManager
-
resetMasterByteReader
public void resetMasterByteReader(ByteReader masterByteReader) throws java.io.IOException
Reset the masterByteReaderand close it and allInputByteStreaminstances made from it.- Parameters:
masterByteReader- the new masterByteReader, can be null- Throws:
java.io.IOException
-
getInputByteStream
public InputByteStream getInputByteStream(ByteReader byteReader) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStreamfrom aByteReader.- Parameters:
byteReader- AByteReaderto be used for creating theInputByteStream.- Returns:
- An
InputByteStream. - Throws:
java.io.IOException
-
getInputByteStream
public InputByteStream getInputByteStream(ByteReader byteReader, long startOffset, long length) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStreamfrom aByteReader.- Parameters:
byteReader- AByteReaderto be used for creating theInputByteStream.- Returns:
- An
InputByteStream. - Throws:
java.io.IOException
-
getInputByteStream
public InputByteStream getInputByteStream(byte[] b) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anInputByteStreamfrom a byte array.- Parameters:
b- An array of bytes to be used for creating theInputByteStream.- Returns:
- An
InputByteStream. - Throws:
java.io.IOException
-
getInputByteStream
public InputByteStream getInputByteStream(InputByteStream[] byteStreams) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStream. This creates anOutputByteStreamthat wraps multipleOutputByteStreamobjects and makes them appear as one largeOutputByteStream. TheOutputByteStreamobjects that are passed must not be modified in any way until the wrappingOutputByteStreamreturned from this method is no longer in use.- Parameters:
byteStreams- An array ofOutputByteStreamobjects.- Returns:
- An
OutputByteStream. - Throws:
java.io.IOException
-
getOutputByteStream
public OutputByteStream getOutputByteStream(ByteWriter byteWriter) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStreamfrom aByteWriter.- Parameters:
byteWriter- AByteWriterto be used for creating theOutputByteStream.- Returns:
- An
OutputByteStream. - Throws:
java.io.IOException
-
getUnregisteredOutputByteStream
public OutputByteStream getUnregisteredOutputByteStream(ByteWriter byteWriter) throws java.io.IOException
Only for internal engineering use. This api can change without notice. Create anOutputByteStreamfrom aByteWriter. The returnedOutputByteStreamis unregistered and so will not be managed by the stream manager. It is the responsibility of the caller to ensure that theByteWriterand theOutputByteStreamare properly closed.- Parameters:
byteWriter- AByteWriterto be used for creating theOutputByteStream.- Returns:
- An
OutputByteStream. - Throws:
java.io.IOException
-
getOutputByteStreamClearTemp
public OutputByteStream getOutputByteStreamClearTemp(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose 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:
java.io.IOException
-
getOutputByteStreamEncryptedTemp
public OutputByteStream getOutputByteStreamEncryptedTemp(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose 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:
java.io.IOException
-
getOutputByteStreamDecryptedTemp
public OutputByteStream getOutputByteStreamDecryptedTemp(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose 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:
java.io.IOException
-
getOutputByteStreamClearDocument
public OutputByteStream getOutputByteStreamClearDocument(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand 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:
java.io.IOException
-
getOutputByteStreamEncryptedDocument
public OutputByteStream getOutputByteStreamEncryptedDocument(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand 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:
java.io.IOException
-
getOutputByteStreamDecryptedDocument
public OutputByteStream getOutputByteStreamDecryptedDocument(ByteWriterFactory.Fixed fixed, long size) throws java.io.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 anOutputByteStreamwhose expected duration of existence is of similar length to that of thePDFDocumentand 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:
java.io.IOException
-
getUnregisteredOutputByteStream
public OutputByteStream getUnregisteredOutputByteStream(ByteWriterFactory.Fixed fixed, int size) throws java.io.IOException
Create anOutputByteStreamfor use within the COS layer of the PDF toolkit. ThisOutputByteStreamwill 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 theOutputByteStreaminto anInputByteStreamthis can be done by using theOutputByteStream.closeAndConvert()method.- Parameters:
fixed- is theOutputByteStreamof a fixed size or notsize- the actual size of a fixedOutputByteStreamor an estimate of a growable one- Returns:
- a stream for writing data to
- Throws:
java.io.IOException
-
getOutputByteStream
public OutputByteStream getOutputByteStream(ByteWriterFactory.Longevity longevity, ByteWriterFactory.EncryptionStatus encryption, ByteWriterFactory.Fixed fixed, long size, boolean fast) throws java.io.IOException
Create anOutputByteStreamfor use within the PDF toolkit. ThisOutputByteStreamwill be kept track of through an internal registry and will need to be properly closed by the caller. If it is desired to turn theOutputByteStreaminto anInputByteStreamthis can be done by using theOutputByteStream.closeAndConvert()method.- Parameters:
longevity- an estimate of how long theOutputByteStreamwill remain in useencryption- the encryption status of the contents of theOutputByteStreamfixed- is theOutputByteStreamof a fixed size or notsize- the actual size of a fixedOutputByteStreamor an estimate of a growable onefast- a request for a fasterOutputByteStreamwhich is only a suggestion- Returns:
- a stream for writing data to
- Throws:
java.io.IOException
-
getByteWriter
public ByteWriter getByteWriter(ByteWriterFactory.Fixed fixed, long size) throws java.io.IOException
Create aByteWriter. ThisByteWriteris 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 theOutputByteStreamof a fixed size or notsize- the actual size of a fixedOutputByteStreamor an estimate of a growable one- Returns:
- a stream for writing data to
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionClose thisStreamManager. This closes all openByteReaderinstances and anyInputByteStreaminstances made from. TheByteWriterFactorygiven during construction is also closed. In the future if there are openByteReaderinstances this will be considered an error state and an exception will be thrown.- Throws:
java.io.IOException
-
close
public void close(boolean ignoreMaster) throws java.io.IOExceptionClose thisStreamManager. This closes all openByteReaderinstances and anyInputByteStreaminstances made from. TheByteWriterFactorygiven during construction is also closed. In the future if there are openByteReaderinstances this will be considered an error state and an exception will be thrown.- Parameters:
ignoreMaster- iftruethe master ByteReader is ignored for closing and it will be the responsibility of the caller to close it- Throws:
java.io.IOException
-
-