Package Torello.Java.Additional
Class TriAppendable
- java.lang.Object
-
- Torello.Java.Additional.TriAppendable
-
- All Implemented Interfaces:
java.lang.Appendable
public class TriAppendable extends java.lang.Object implements java.lang.Appendable
Appendable
Implementation:
This class implements and upgrades the Simple, Javajava.lang.Appendable
interface, providing additional features and improvements to it. TheAppendable
interace is a viable design-decsion possibility for outputing text-data to a log.
AnAppendable
is both blindingly easy, and highly customizable to use for third-party developers who may not be familiar with the internals of another developer's source-code.
This Class' Primary Addition toAppendable
:
This class is a simple way of allowing a singleAppendable
to actually send output text, automatically, to three differentAppendable
-log instances, simultaneously (at the same time) - without adding any extra-code or doing any extra-work. When aTriAppendable
receives anappend(...)
invocation, it sends the character data to all three of its constituent, wrapped, internal-Appendable
instances.
Used in Java-HTML JAR Library:
This class was originally developed for use with the classesOSCommands
andOSReponse
(and the suite of classes which implement theseabstract
-tools:Shell
,MSDOS
andGSUTIL
).
To see theTriAppendable
in action, open the hilited source-code file for classOSCommands
and scroll down two-thirds of the way in that file. Also note that, currently,BiAppendable
isn't used, but was written / added anyway, for possible future use.Builds a compositejava.lang.Appendable
using up to three independent input-parameterAppendable's
. Character data appended to an instance ofTriAppendable
will, in turn, be appended to any of the input-Appendable's
which have been provided to this class' constructor and are non-null.
Passing null input-Appendable's
will not cause this class to fail, and will not generateNullPointerException's
. One of the primary values of this class is that the chunk of code that tests for a "Null Log" is done inside this class.
The meaning of a "Null Log" is just that a user has decided against logging a tool or utility's output to any logger, and has passed 'null' to one of the log references in his code.- See Also:
OSCommands
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/TriAppendable.java
- Open New Browser-Tab: Torello/Java/Additional/TriAppendable.java
File Size: 9,341 Bytes Line Count: 209 '\n' Characters Found
-
-
Constructor Summary
Constructors Constructor Description TriAppendable(Appendable a, Appendable b, Appendable c)
Creates an instance of this class, using up to three inputAppendable's
.
-
-
-
Constructor Detail
-
TriAppendable
public TriAppendable(java.lang.Appendable a, java.lang.Appendable b, java.lang.Appendable c)
Creates an instance of this class, using up to three inputAppendable's
.- Parameters:
a
- Anyjava.lang.Appendable
. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated aNullPointerException
b
- Anyjava.lang.Appendable
. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated aNullPointerException
c
- Anyjava.lang.Appendable
. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated aNullPointerException
-
-
Method Detail
-
append
public java.lang.Appendable append(char ch) throws java.io.IOException
Logs achar
(input-parameter'ch'
) to any / all non-nullAppendable's
that were passed to this class' constructor.- Specified by:
append
in interfacejava.lang.Appendable
- Parameters:
ch
- Any Java Character- Throws:
java.io.IOException
- Throws if any of the underlyingAppendable's
throwIOException
upon having their correspondingappend()
-method invoked.- Code:
- Exact Method Body:
return this.appendable.append(ch);
-
append
public java.lang.Appendable append(java.lang.CharSequence cs) throws java.io.IOException
Logs aCharSequence
(input-parameter'cs'
) to any / all non-nullAppendable's
that were passed to this class' constructor.- Specified by:
append
in interfacejava.lang.Appendable
- Parameters:
cs
- Any JavaCharSequence
- Throws:
java.io.IOException
- Throws if any of the underlyingAppendable's
throwIOException
upon having their correspondingappend()
-method invoked.- Code:
- Exact Method Body:
return this.appendable.append(cs);
-
append
public java.lang.Appendable append(java.lang.CharSequence cs, int start, int end) throws java.io.IOException
Logs a partial / substringCharSequence
(input-parameter'cs'
) to any / all non-nullAppendable's
that were passed to this class' constructor.- Specified by:
append
in interfacejava.lang.Appendable
- Parameters:
cs
- Any JavaCharSequence
start
- Position within'cs'
of thesubstring's
first character to be appendedend
- Position within'cs'
of thesubstring's
last character to be appended- Throws:
java.io.IOException
- Throws if any of the underlyingAppendable's
throwIOException
upon having their correspondingappend()
-method invoked.- Code:
- Exact Method Body:
return this.appendable.append(cs, start, end);
-
-