Coverage Report - org.apache.commons.io.output.NullWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
NullWriter
78%
11/14
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.io.output;
 18  
 
 19  
 import java.io.Writer;
 20  
 
 21  
 /**
 22  
  * This {@link Writer} writes all data to the famous <b>/dev/null</b>.
 23  
  * <p>
 24  
  * This <code>Writer</code> has no destination (file/socket etc.) and all
 25  
  * characters written to it are ignored and lost.
 26  
  *
 27  
  * @version $Id: NullWriter.java 1471767 2013-04-24 23:24:19Z sebb $
 28  
  */
 29  0
 public class NullWriter extends Writer {
 30  
 
 31  
     /**
 32  
      * A singleton.
 33  
      */
 34  6
     public static final NullWriter NULL_WRITER = new NullWriter();
 35  
 
 36  
     /**
 37  
      * Constructs a new NullWriter.
 38  
      */
 39  16
     public NullWriter() {
 40  16
     }
 41  
 
 42  
     /**
 43  
      * Does nothing - output to <code>/dev/null</code>.
 44  
      * @param c The character to write
 45  
      * @return this writer
 46  
      * @since 2.0
 47  
      */
 48  
     @Override
 49  
     public Writer append(final char c) {
 50  
         //to /dev/null
 51  0
         return this;
 52  
     }
 53  
 
 54  
     /**
 55  
      * Does nothing - output to <code>/dev/null</code>.
 56  
      * @param csq The character sequence to write
 57  
      * @param start The index of the first character to write
 58  
      * @param end  The index of the first character to write (exclusive)
 59  
      * @return this writer
 60  
      * @since 2.0
 61  
      */
 62  
     @Override
 63  
     public Writer append(final CharSequence csq, final int start, final int end) {
 64  
         //to /dev/null
 65  0
         return this;
 66  
     }
 67  
 
 68  
     /**
 69  
      * Does nothing - output to <code>/dev/null</code>.
 70  
      * @param csq The character sequence to write
 71  
      * @return this writer
 72  
      * @since 2.0
 73  
      */
 74  
     @Override
 75  
     public Writer append(final CharSequence csq) {
 76  
         //to /dev/null
 77  2
         return this;
 78  
     }
 79  
 
 80  
     /**
 81  
      * Does nothing - output to <code>/dev/null</code>.
 82  
      * @param idx The character to write
 83  
      */
 84  
     @Override
 85  
     public void write(final int idx) {
 86  
         //to /dev/null
 87  2
     }
 88  
 
 89  
     /**
 90  
      * Does nothing - output to <code>/dev/null</code>.
 91  
      * @param chr The characters to write
 92  
      */
 93  
     @Override
 94  
     public void write(final char[] chr) {
 95  
         //to /dev/null
 96  4
     }
 97  
 
 98  
     /**
 99  
      * Does nothing - output to <code>/dev/null</code>.
 100  
      * @param chr The characters to write
 101  
      * @param st The start offset
 102  
      * @param end The number of characters to write
 103  
      */
 104  
     @Override
 105  
     public void write(final char[] chr, final int st, final int end) {
 106  
         //to /dev/null
 107  2097156
     }
 108  
 
 109  
     /**
 110  
      * Does nothing - output to <code>/dev/null</code>.
 111  
      * @param str The string to write
 112  
      */
 113  
     @Override
 114  
     public void write(final String str) {
 115  
         //to /dev/null
 116  4
     }
 117  
 
 118  
     /**
 119  
      * Does nothing - output to <code>/dev/null</code>.
 120  
      * @param str The string to write
 121  
      * @param st The start offset
 122  
      * @param end The number of characters to write
 123  
      */
 124  
     @Override
 125  
     public void write(final String str, final int st, final int end) {
 126  
         //to /dev/null
 127  4
     }
 128  
 
 129  
     /** @see java.io.Writer#flush() */
 130  
     @Override
 131  
     public void flush() {
 132  
         //to /dev/null
 133  2
     }
 134  
 
 135  
     /** @see java.io.Writer#close() */
 136  
     @Override
 137  
     public void close() {
 138  
         //to /dev/null
 139  8
     }
 140  
 
 141  
 }