Package com.storedobject.common
Class TranslatedReader
java.lang.Object
java.io.Reader
java.io.FilterReader
com.storedobject.common.TranslatedReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Direct Known Subclasses:
StringFillerReader
A
FilterReader that translates its stream on-the-fly.- Author:
- Syam
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReaderThe underlyingReaderproviding the original input stream before translation.protected final BufferedWriterABufferedWriterused to write the translated output of the input stream processed by thisTranslatedReader. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new translated reader. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidTranslation should be done here.Methods inherited from class java.io.FilterReader
close, mark, markSupported, read, read, ready, reset, skipMethods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Field Details
-
in
The underlyingReaderproviding the original input stream before translation. This reader is used as the source for processing in the translation logic defined in thetranslate()method. -
out
ABufferedWriterused to write the translated output of the input stream processed by thisTranslatedReader. This writer acts as the destination for the translated data after applying the custom translation logic defined in thetranslate()method. It is initialized to output to an underlying stream managed by this class.
-
-
Constructor Details
-
TranslatedReader
Creates a new translated reader.- Parameters:
in- Reader object providing the underlying stream.
-
-
Method Details
-
translate
Translation should be done here. Original reader is available in the variableinand the translated output should be written to theBufferedWriter(variableout).- Throws:
Exception- Throws any exception so that the ultimate reading program will get it.
-