Package com.storedobject.common
Class TranslatedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.storedobject.common.TranslatedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A
FilterInputStream that translates its stream on-the-fly.- Author:
- Syam
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InputStreamThe input stream containing the original data to be translated.protected final BufferedOutputStreamThe buffered output stream used to hold the translated output data. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new translated input stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidTranslation should be done here.Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
in
The input stream containing the original data to be translated. This stream serves as the source for translation operations performed by thetranslate()method.- It is provided as a parameter during the construction of the containing class.
- Ensures the availability of unmodified input data before translation.
- Typically wrapped by a
FilterInputStreamfor further processing.
protectedto allow access in subclasses andfinalto ensure its reference cannot be changed. -
out
The buffered output stream used to hold the translated output data. This stream serves as the target for translation operations performed by thetranslate()method.- It is a
BufferedOutputStreamto optimize write operations. - The data written to this stream reflects the translated content
based on the original input stream
in. - Declared as
protectedto allow subclasses to access this stream for customized translation behavior. - Declared as
finalto ensure its reference cannot be modified after initialization.
- It is a
-
-
Constructor Details
-
TranslatedInputStream
Creates a new translated input stream.- Parameters:
in- a InputStream object providing the underlying stream.
-
-
Method Details
-
translate
Translation should be done here. Original input stream is available in the variableinand the translated output should be written to theBufferedOutputStream(variableout).- Throws:
Exception- Throws any exception so that the ultimate reading program will get it.
-