Class 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, Java java.lang.Appendable interface, providing additional features and improvements to it. The Appendable interace is a viable design-decsion possibility for outputing text-data to a log.

    An Appendable 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 to Appendable:
    This class is a simple way of allowing a single Appendable to actually send output text, automatically, to three different Appendable-log instances, simultaneously (at the same time) - without adding any extra-code or doing any extra-work. When a TriAppendable receives an append(...) 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 classes OSCommands and OSReponse (and the suite of classes which implement these abstract-tools: Shell, MSDOS and GSUTIL).

    To see the TriAppendable in action, open the hilited source-code file for class OSCommands 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 composite java.lang.Appendable using up to three independent input-parameter Appendable's. Character data appended to an instance of TriAppendable 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 generate NullPointerException'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


    • Constructor Summary

      Constructors 
      Constructor Description
      TriAppendable​(Appendable a, Appendable b, Appendable c)
      Creates an instance of this class, using up to three input Appendable's.
    • Method Summary

       
      Methods: interface java.lang.Appendable
      Modifier and Type Method
      Appendable append​(char ch)
      Appendable append​(CharSequence cs)
      Appendable append​(CharSequence cs, int start, int end)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 input Appendable's.
        Parameters:
        a - Any java.lang.Appendable. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated a NullPointerException
        b - Any java.lang.Appendable. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated a NullPointerException
        c - Any java.lang.Appendable. This parameter may be null, and if it is it will be ignored. Passing null here, will not generated a NullPointerException
    • Method Detail

      • append

        🡅  🡇     🗕  🗗  🗖
        public java.lang.Appendable append​(char ch)
                                    throws java.io.IOException
        Logs a char (input-parameter 'ch') to any / all non-null Appendable's that were passed to this class' constructor.
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        ch - Any Java Character
        Throws:
        java.io.IOException - Throws if any of the underlying Appendable's throw IOException upon having their corresponding append()-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 a CharSequence (input-parameter 'cs') to any / all non-null Appendable's that were passed to this class' constructor.
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        cs - Any Java CharSequence
        Throws:
        java.io.IOException - Throws if any of the underlying Appendable's throw IOException upon having their corresponding append()-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 / substring CharSequence (input-parameter 'cs') to any / all non-null Appendable's that were passed to this class' constructor.
        Specified by:
        append in interface java.lang.Appendable
        Parameters:
        cs - Any Java CharSequence
        start - Position within 'cs' of the substring's first character to be appended
        end - Position within 'cs' of the substring's last character to be appended
        Throws:
        java.io.IOException - Throws if any of the underlying Appendable's throw IOException upon having their corresponding append()-method invoked.
        Code:
        Exact Method Body:
         return this.appendable.append(cs, start, end);