|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Writer
PIRL.Utilities.Styled_Multiwriter
public class Styled_Multiwriter
A Styled_Multiwriter is a one-to-many Writer, any of which may be a Styled_Writer.
Writers are wrapped in a Suspendable_Styled_Writer before being added to the list of Writers unless they are already a Suspendable_Styled_Writer.
Each write method is repeated on each Writer in the Writers list. Each Writer is used even if a writer throws an exception. Any exceptions thrown are accumulated in a Multiwriter_IOException which associates the exception thrown with the original Writer source of the exception. A Writer that throws an exception is suspended, except in the case of the close method.
N.B.: If the Writers list is empty each write method will do nothing.
Writer,
Styled_Writer,
Suspendable_Styled_Writer| Field Summary | |
|---|---|
boolean |
Add_Enabled
Determines whether a Writer is enabled or disabled when it is added to the Writers list. |
static String |
ID
Class identification name with source code version and date. |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
Styled_Multiwriter()
Construct a Styled_Multiwriter. |
|
| Method Summary | |
|---|---|
boolean |
Add(Writer writer)
Add a Writer to the list of Writers. |
void |
close()
Close the writers. |
boolean |
Contains(Writer writer)
Test if the list of Writers contains a specified Writer. |
Suspendable_Styled_Writer |
Entry_for(Writer writer)
Get the Writers entry for a Writer that was
Added. |
Writer |
Entry_from(Suspendable_Styled_Writer writer)
Get the Writer that was Added from a Writers list entry. |
void |
flush()
Flush the writers. |
boolean |
Is_Empty()
Test if the Writers list is empty. |
void |
Remove_All()
Remove all Writers list entries. |
boolean |
Remove(Writer writer)
Remove a Writer from the list of Writers. |
boolean |
Suspend(Writer writer,
boolean suspend)
Turn output suspension on or off for a Writer. |
boolean |
Suspended(Writer writer)
Test if output for a Writer is 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. |
Vector |
Writers()
Get a reference to the list of Writers. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ID
public volatile boolean Add_Enabled
added to the Writers list.
| Constructor Detail |
|---|
public Styled_Multiwriter()
Writers have yet to be added.
| Method Detail |
|---|
public boolean Add(Writer writer)
Writers.
If the Writer is already in the list it is not added. A Writer that is added to the list is wrapped in a Suspendable_Styled_Writer unless it is already an instance of a Suspendable_Styled_Writer.
The addition of the Writer to the Writers list is synchronized on the Writers list.
writer - The Writer to add.
Suspendable_Styled_Writer,
Remove(Writer)public boolean Remove(Writer writer)
Writers.
The removal of the Writer from the Writers list is synchronized on the Writers list.
writer - The Writer to remove. This is expected to be a
Writer that was Added.
Add(Writer),
Entry_for(Writer)public void Remove_All()
Writers list entries.
The removal of the Writer from the Writers list is synchronized on the Writers list.
N.B.: The Writers entries are not closed.
Add(Writer)
public boolean Suspend(Writer writer,
boolean suspend)
Searching the Writers list for the Writer is synchronized on the Writers list,
writer - The Writer to be affected. This is expected to be a
Writer that was Added.suspend - true if the Writer output is to be suspended; false
if output is to be allowed.
Suspended(Writer),
Entry_for(Writer)public boolean Suspended(Writer writer)
Searching the Writers list for the Writer is synchronized on the Writers list,
writer - The Writer to test. This is expected to be a
Writer that was Added.
contained in the list if the distinction is important.Suspend(Writer, boolean)public boolean Contains(Writer writer)
Searching the Writers list for the Writer is synchronized on the Writers list,
writer - The Writer to test for. This is expected to be a
Writer that was Added.
Entry_for(Writer)public Suspendable_Styled_Writer Entry_for(Writer writer)
Writers entry for a Writer that was
Added.
When a Writer is Added it is wrapped in a
Suspendable_Styled_Writer if it is not already an instance of this
class. This method searches for the Suspendable_Styled_Writer in the
Writers list that is associated with a specified
Writer which may or may not have been wrapped by a
Suspendable_Styled_Writer before being entered into the list.
Searching the Writers list for the Writer is synchronized on the Writers list,
writer - A Writer. This is expected to be one of the Writer
objects that was Added.
Writers
list. This will be null if the writer was not found.public Writer Entry_from(Suspendable_Styled_Writer writer)
Added from a Writers list entry.
When a Writer is Added it is wrapped in a
Suspendable_Styled_Writer if it is not already an instance of this
class. This method searches for the Suspendable_Styled_Writer in the
Writers list that is associated with a specified
Writer which may or may not have been wrapped by a
Suspendable_Styled_Writer before being entered into the list. It then
checks this against the list of Suspendable_Styled_Writer objects that
were added without being wrapped. If this check succeeds then the
Writer that was specified is returned; otherwise the
Writer from this
specified Suspendable_Styled_Writer is returned.
Searching the Writers list is synchronized on the Writers list,
writer - A Suspendable_Styled_Writer from which to determine
the original Writer that was Added.
Added, or null
if the writer is not in the Writers list.public boolean Is_Empty()
public Vector Writers()
The Writers in the list are Suspendable_Styled_Writer
objects. When a Writer is Added it is wrapped in
a Suspendable_Styled_Writer if it is not already an instance of this
class. A Suspendable_Styled_Writer always contains a Writer to which I/O is
deferred.
Add(Writer),
Remove(Writer)
public void write(char[] characters,
int offset,
int amount)
throws Multiwriter_IOException
Iterating over the Writers list is synchronized on the Writers list, and the write to the Writer is synchronized on the Writer.
All Writers are written even if one or more Writers throws an exception.
write in class Writercharacters - 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. If zero nothing is
done.
IndexOutOfBoundsException - If the offset or amount are
negative or the offset plus the amount is greater than the length
of the array.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.Suspended(Writer)
public void write(char[] characters)
throws Multiwriter_IOException
Using this method is the same as using .
write (characters, 0, characters.length)
All Writers are written even if one or more Writers throws an exception.
write in class Writercharacters - The char array containing the characters to be
written. If null or empty nothing is done.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.
public void write(int character)
throws Multiwriter_IOException
Iterating over the Writers list is synchronized on the Writers list, and the write to the Writer is synchronized on the Writer.
All Writers are written even if one or more Writers throws an exception.
write in class Writercharacter - The character to be written in the 16 low-order
bits..
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.
public void write(String string,
int offset,
int amount)
throws Multiwriter_IOException
Using this method is the same as using .
write (string.toCharArray (), offset, amount)
All Writers are written even if one or more Writers throws an exception.
write in class Writerstring - The String containing the characters to be written.
If null or empty nothing is done.offset - String offset from which to start writing characters.amount - The number of characters to write. If zero nothing
is done.
IndexOutOfBoundsException - If the offset or amount are
negative or the offset plus the amount is greater than the length
of the string.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.write(char[], int, int)
public void write(String string)
throws Multiwriter_IOException
Using this method is the same as using .
write (string, 0, string.length ())
All Writers are written even if one or more Writers throws an exception.
write in class Writerstring - The String containing the characters to be written.
If null or empty nothing is done.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.write(String, int, int)
public void flush()
throws Multiwriter_IOException
Iterating over the Writers list is synchronized on the Writers list, and the flush to the Writer is synchronized on the Writer.
All Writers are flushed even if one or more Writers throws an exception.
flush in interface Flushableflush in class WriterMultiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.
public void close()
throws Multiwriter_IOException
Iterating over the Writers list is synchronized on the Writers list, and the close of the Writer is synchronized on the Writer.
close in interface Closeableclose in class WriterMultiwriter_IOException - If any Writer throws an exception.
All Writers are closed even if one or more Writers throws an
exception. The Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added. N.B.: A Writer that
throws an exception is not suspended.
public Styled_Writer Write(String text,
AttributeSet style)
throws Multiwriter_IOException
Iterating over the Writers list is synchronized on the Writers list, and the Write to the Writer is synchronized on the Writer.
All Writers are written even if one or more Writers throws an exception.
Write in interface Styled_Writertext - The text String to be written. If null or empty
nothing is done.style - The AttributeSet to be applied to the text. This
may be null if plain text is to be displayed.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.Suspendable_Styled_Writer.Write(String, AttributeSet),
Styled_Writer.Write(String, AttributeSet)
public Styled_Writer Write(String text)
throws Multiwriter_IOException
This is the same as writing
text with a null style.
All Writers are written even if one or more Writers throws an exception.
Write in interface Styled_Writertext - The text String to be written.
Multiwriter_IOException - If any Writer throws an exception. A
Writer that throws an exception is suspended. The
Writers in the exception's Multiwriter_IOException.Sources list are the original Writers
that were Added.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||