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
AppendableImplementation:
This class implements and upgrades the Simple, Javajava.lang.Appendableinterface, providing additional features and improvements to it. TheAppendableinterace is a viable design-decsion possibility for outputing text-data to a log.
AnAppendableis 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 singleAppendableto 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 aTriAppendablereceives anappend(...)invocation, it sends the character data to all three of its constituent, wrapped, internal-Appendableinstances.
Used in Java-HTML JAR Library:
This class was originally developed for use with the classesOSCommandsandOSReponse(and the suite of classes which implement theseabstract-tools:Shell,MSDOSandGSUTIL).
To see theTriAppendablein action, open the hilited source-code file for classOSCommandsand scroll down two-thirds of the way in that file. Also note that, currently,BiAppendableisn't used, but was written / added anyway, for possible future use.Builds a compositejava.lang.Appendableusing up to three independent input-parameterAppendable's. Character data appended to an instance ofTriAppendablewill, in turn, be appended to any of the input-Appendable'swhich have been provided to this class' constructor and are non-null.
Passing null input-Appendable'swill 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,353 Bytes Line Count: 209 '\n' Characters Found
-
-
Constructor Summary
Constructors Constructor TriAppendable(Appendable a, Appendable b, Appendable c)
-
-
-
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 aNullPointerExceptionb- Anyjava.lang.Appendable. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated aNullPointerExceptionc- 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'sthat were passed to this class' constructor.- Specified by:
appendin interfacejava.lang.Appendable- Parameters:
ch- Any Java Character- Throws:
java.io.IOException- Throws if any of the underlyingAppendable'sthrowIOExceptionupon 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'sthat were passed to this class' constructor.- Specified by:
appendin interfacejava.lang.Appendable- Parameters:
cs- Any JavaCharSequence- Throws:
java.io.IOException- Throws if any of the underlyingAppendable'sthrowIOExceptionupon 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'sthat were passed to this class' constructor.- Specified by:
appendin interfacejava.lang.Appendable- Parameters:
cs- Any JavaCharSequencestart- Position within'cs'of thesubstring'sfirst character to be appendedend- Position within'cs'of thesubstring'slast character to be appended- Throws:
java.io.IOException- Throws if any of the underlyingAppendable'sthrowIOExceptionupon having their correspondingappend()-method invoked.- Code:
- Exact Method Body:
return this.appendable.append(cs, start, end);
-
-