Coverage Report - com.ccg.macros.OutputNull
 
Classes in this File Line Coverage Branch Coverage Complexity
OutputNull
100% 
N/A 
1
 
 1  
 /*----------------------------------------------------------------
 2  
  * $Id: OutputNull.java,v 1.1.1.1 2004/01/26 20:46:18 pkb Exp $
 3  
  * 
 4  
  * (c)2001 - Paul Blankenbaker
 5  
  *
 6  
  * Revision Log
 7  
  * 
 8  
  *  2001-01-22 08:31:59        Paul Blankenbaker 
 9  
  * 
 10  
  *         Created initial version
 11  
  */
 12  
 //----------------------------------------------------------------
 13  
 
 14  
 package com.ccg.macros;
 15  
 
 16  
 import java.io.IOException;
 17  
 
 18  
 //----------------------------------------------------------------
 19  
 /** A "null" {@link Output output device} for {@link Interpreter interpreter} output.
 20  
  * 
 21  
  * <p>At times it is useful to disable output while interpretting
 22  
  * data. If you pass one of these objects to a {@link Interpreter
 23  
  * Interpreter}, then any normal output generated will be discarded. 
 24  
  *
 25  
  * <p>This can be particularily useful when "loading" an interpreter
 26  
  * with some default rules.
 27  
  *
 28  
  * <p>For example, suppose you wanted to load definitions from a file
 29  
  * into a {@link AtMacros} object without producing any output. You
 30  
  * could do this with a method like this:
 31  
  *
 32  
  * <pre>
 33  
  * public static void loadDefinitions({@link AtMacros AtMacros} amacs, File src) 
 34  
  *   throws IOException, InterpretException {
 35  
  **
 36  
  *   {@link Input Input} in = new {@link InputReader#InputReader(File) InputReader(src)};
 37  
  *   amacs.{@link Interpreter#interpret interpret(in,new {@link OutputNull OutputNull}());
 38  
  * 
 39  
  * }
 40  
  * </pre>
 41  
  * 
 42  
  * @version $Revision: 1.1.1.1 $
 43  
  * 
 44  
  * @since 1.0
 45  
  * 
 46  
  * @author $Author: pkb $
 47  
  * 
 48  
  * @see AtMacros */
 49  
 //----------------------------------------------------------------
 50  
 
 51  2
 public final class OutputNull implements Output {
 52  
 
 53  
   //----------------------------------------------------------------
 54  
   /** Writes a set of characters from a buffer to the output.
 55  
    * 
 56  
    * <p>This method is used by macro processors (such as the {@link
 57  
    * AtMacros AtMacros} class) to send a set of characters to the
 58  
    * output device (string, file, etc).  However, since this is a
 59  
    * "null" writer - no output is never done.
 60  
    * 
 61  
    * @param        buf
 62  
    * 
 63  
    *         A character array to take the data from (must not be null)
 64  
    * 
 65  
    * @param        ofs
 66  
    * 
 67  
    *         Offset into the buffer to the first character to start the
 68  
    *         copy from. Should be in the range of [0,buf.length-1].
 69  
    * 
 70  
    * @param        len
 71  
    * 
 72  
    *         How many characters to copy. When added to the offset, the
 73  
    *         resulting value should not exceed the length of the array.
 74  
    * 
 75  
    * @throws        IOException
 76  
    * 
 77  
    *         If a I/O error is encountered (never thrown since we don't do
 78  
    *         anything).
 79  
    * 
 80  
    * @since        1.0 */
 81  
   //----------------------------------------------------------------
 82  
 
 83  
   public void write(char[] buf, int ofs, int len) throws IOException {
 84  
 
 85  2518
   }
 86  
 
 87  
 
 88  
   //----------------------------------------------------------------
 89  
   /** Outputs the {@link java.lang.String string} representation of a {@link java.lang.Object Object}.
 90  
    * 
 91  
    * <p>This method is used by macro processors (such as the {@link
 92  
    * AtMacros AtMacros} class) to cause the {@link java.lang.String
 93  
    * string} representation of a {@link java.lang.Object Object} to be
 94  
    * sent to the output device. However, since this is a "null" writer
 95  
    * - no output is never done.
 96  
    * 
 97  
    * @param        object
 98  
    * 
 99  
    *         The object to write out (the {@link java.lang.Object#toString
 100  
    *         toString()} method is used to write out the string
 101  
    *         representation of the object). You may pass null (in which
 102  
    *         case nothing will be done).
 103  
    * 
 104  
    * @throws        IOException
 105  
    * 
 106  
    *         If a I/O error is encountered (never thrown since we don't do
 107  
    *         anything).
 108  
 y   * 
 109  
    * @since        1.0 */
 110  
   //----------------------------------------------------------------
 111  
 
 112  
   public void write(Object o) throws IOException {
 113  
 
 114  30
   }
 115  
 
 116  
 
 117  
   //----------------------------------------------------------------
 118  
   /** Reference to the single global {@link Output null output} device.
 119  
    * 
 120  
    * <p>Since this object doesn't do anything, a single instance can
 121  
    * be used throughout the JVM. Use this method to get access to it
 122  
    * (this avoid constructing new intances).
 123  
    * 
 124  
    * @return
 125  
    * 
 126  
    *         Non-null reference to the single global instance of the null
 127  
    *         output device.
 128  
    * 
 129  
    * @since        1.0 */
 130  
   //----------------------------------------------------------------
 131  
 
 132  
   public static Output getInstance() {
 133  74
     return _Instance;
 134  
   }
 135  
 
 136  
   //----------------------------------------------------------------  
 137  
   // single instance of the global "null" output device
 138  
   //----------------------------------------------------------------
 139  
 
 140  2
   private static Output _Instance = new OutputNull();
 141  
 
 142  
 }