public class Suspendable_Styled_Writer extends Writer implements Styled_Writer
All output methods are forwarded to the backing Writer. However, output may be suspended, in which case no output will occur until the suspension has been lifted.
The Styled_Writer interface is also implemented such that if the backing Writer implements Styled_Writer that interface is used, otherwise the usual Writer API is used instead in which case no style information will be forwarded.
Writer
,
Styled_Writer
Modifier and Type | Field and Description |
---|---|
boolean |
Active
The suspension state of the Writer.
|
static String |
ID
Class identification name with source code version and date.
|
Constructor and Description |
---|
Suspendable_Styled_Writer(Writer writer)
Construct a Suspendable_Styled_Writer.
|
Suspendable_Styled_Writer(Writer writer,
boolean active)
Construct a Suspendable_Styled_Writer with suspension specified.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the writer.
|
void |
flush()
Flush the writer.
|
void |
Suspend(boolean suspend)
Turn output suspension on or off.
|
boolean |
Suspended()
Test if output has been suspended.
|
void |
write(char[] characters)
Write an array of characters.
|
void |
write(char[] characters,
int offset,
int amount)
Write a portion of an array of characters.
|
void |
write(int character)
Write a character.
|
void |
write(String string)
Write a String.
|
Styled_Writer |
Write(String text)
Write plain text.
|
Styled_Writer |
Write(String text,
AttributeSet style)
Write styled text.
|
void |
write(String string,
int offset,
int amount)
Write a portion of a String.
|
Writer |
Writer()
Get the Writer to which all Write methods are forwarded.
|
public static final String ID
public volatile boolean Active
When Active is true all output methods will forward to the Writer
on which the object was constructed.
public Suspendable_Styled_Writer(Writer writer)
The intial state of the Writer is determined by the flag
.
writer
- The Writer to use for all write operations.IllegalArgumentException
- If the writer is null.public Suspendable_Styled_Writer(Writer writer, boolean active)
writer
- The Writer to use for all write operations.active
- The initial state of the Writer. If true writes
will occure; if false writes are suspended.IllegalArgumentException
- If the writer is null.public Writer Writer()
public boolean Suspended()
Suspend(boolean)
public void Suspend(boolean suspend)
suspend
- If true subsequent output will be suspended; if
false output will occur.public void write(char[] characters, int offset, int amount) throws IOException
Nothing is done if the Writer is suspended
.
write
in class Writer
characters
- The char array containing the characters to be
written. If null or empty nothing is done.offset
- Array offset from which to start writing characters.amount
- The number of characters to write.IOException
- If the Writer
throws an exception.public void write(char[] characters) throws IOException
Nothing is done if the Writer is suspended
.
write
in class Writer
characters
- The char array containing the characters to be
written.IOException
- If the Writer
throws an exception.public void write(int character) throws IOException
Nothing is done if the Writer is suspended
.
write
in class Writer
character
- The character to be written in the 16 low-order
bits..IOException
- If the Writer
throws an exception.public void write(String string, int offset, int amount) throws IOException
Nothing is done if the Writer is suspended
.
write
in class Writer
string
- The String containing the characters to be written.offset
- String offset from which to start writing characters.amount
- The number of characters to write.IOException
- If the Writer
throws an exception.public void write(String string) throws IOException
Nothing is done if the Writer is suspended
.
write
in class Writer
string
- The String containing the characters to be written.
If null or empty nothing is done.IOException
- If the Writer
throws an exception.public void flush() throws IOException
Nothing is done if the Writer is suspended
.
public void close() throws IOException
N.B.: The Writer
will be closed regardless
of whether writing has been suspended
or not.
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
- If the Writer
throws an exception.public Styled_Writer Write(String text, AttributeSet style) throws IOException
Write
in interface Styled_Writer
text
- The text String to be written.style
- The AttributeSet to be applied to the text. This
may be null if plain text is to be displayed.IOException
- If the Writer
throws an exception.Styled_Writer.Write(String, AttributeSet)
public Styled_Writer Write(String text) throws IOException
This is the same as writing
text with a null style.
Write
in interface Styled_Writer
text
- The text String to be written.IOException
- If the Writer
throws an exception.