Package org.daiitech.naftah.utils.script
Class NaftahOutputTransformer
java.lang.Object
java.io.OutputStream
org.daiitech.naftah.utils.script.NaftahOutputTransformer
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An
OutputStream wrapper that transforms text for proper visual display
when printed to an output stream (e.g., console or file).
If text is detected and reshaping is enabled, the text will be reshaped before being written. Otherwise, the original content is passed through.
Note: The methods shouldReshape(), containsArabic(String),
and shape(String) are assumed to be implemented elsewhere.
- Author:
- Chakib Daii
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OutputStreamThe original output stream to which the transformed or raw output will be written. -
Constructor Summary
ConstructorsConstructorDescriptionNaftahOutputTransformer(OutputStream original) Constructs a newNaftahOutputTransformerwrapping the specified output stream. -
Method Summary
Modifier and TypeMethodDescriptionstatic PrintStreamgetPrintStream(OutputStream original) Returns aPrintStreamthat wraps the provided output stream and applies text transformation.voidwrite(byte[] b, int off, int len) Writes a portion of a byte array to the output stream.voidwrite(int b) Writes a single byte to the original output stream.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Field Details
-
original
The original output stream to which the transformed or raw output will be written.
-
-
Constructor Details
-
NaftahOutputTransformer
Constructs a newNaftahOutputTransformerwrapping the specified output stream.- Parameters:
original- the original output stream
-
-
Method Details
-
getPrintStream
Returns aPrintStreamthat wraps the provided output stream and applies text transformation.- Parameters:
original- the original output stream to wrap- Returns:
- a
PrintStreamusingNaftahOutputTransformer
-
write
Writes a single byte to the original output stream. This method serves as a fallback when writing raw byte data.- Specified by:
writein classOutputStream- Parameters:
b- the byte to write- Throws:
IOException- if an I/O error occurs
-
write
Writes a portion of a byte array to the output stream. If the content contains text and reshaping is enabled, it reshapes the text before writing. Otherwise, writes the original byte sequence.- Overrides:
writein classOutputStream- Parameters:
b- the byte array containing the dataoff- the start offset in the arraylen- the number of bytes to write- Throws:
IOException- if an I/O error occurs
-