Package com.storedobject.common
Class TranslatedWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
com.storedobject.common.TranslatedWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
- Direct Known Subclasses:
StringFillerWriter
A
FilterWriter that translates its stream on-the-fly while writing.- Author:
- Syam
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BufferedReaderABufferedReaderused to read input data for translation.protected final WriterThe writer object to which the translated output is written. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTranslatedWriter(Writer out) Creates a new translated writer. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidTranslation should be done here.
-
Field Details
-
in
ABufferedReaderused to read input data for translation. This stream serves as the source for data that needs to be processed and written to the output writer. It reads the raw input from the underlying input-output stream and is used in conjunction with thetranslate()method to perform on-the-fly translation of the input content. The lifecycle of this reader is managed internally, and it is expected to be closed automatically once the translation process is complete. -
out
The writer object to which the translated output is written. This writer acts as the destination for the processed content after being translated by thetranslate()method. The lifecycle and closure of this writer are managed internally within theTranslatedWriterclass to ensure resources are properly released after the translation process is completed. The translation process involves reading data from theBufferedReader(variablein), processing it, and then writing the resulting output to this writer.
-
-
Constructor Details
-
TranslatedWriter
Creates a new translated writer.- Parameters:
out- Writer object providing the underlying stream.
-
-
Method Details
-
translate
Translation should be done here. Original writer is available in the variableoutand the translated output should be written to it by reading theBufferedReader(variablein) and translating it (i.e., read from 'in', translate and write to 'out')- Throws:
Exception- Throws any exception so that the ultimate reading program will get it.
-