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  
  */
 28  0
 public class NullWriter extends Writer {
 29  
 
 30  
     /**
 31  
      * A singleton.
 32  
      */
 33  3
     public static final NullWriter NULL_WRITER = new NullWriter();
 34  
 
 35  
     /**
 36  
      * Constructs a new NullWriter.
 37  
      */
 38  8
     public NullWriter() {
 39  8
     }
 40  
 
 41  
     /**
 42  
      * Does nothing - output to <code>/dev/null</code>.
 43  
      * @param c The character to write
 44  
      * @return this writer
 45  
      * @since 2.0
 46  
      */
 47  
     @Override
 48  
     public Writer append(final char c) {
 49  
         //to /dev/null
 50  0
         return this;
 51  
     }
 52  
 
 53  
     /**
 54  
      * Does nothing - output to <code>/dev/null</code>.
 55  
      * @param csq The character sequence to write
 56  
      * @param start The index of the first character to write
 57  
      * @param end  The index of the first character to write (exclusive)
 58  
      * @return this writer
 59  
      * @since 2.0
 60  
      */
 61  
     @Override
 62  
     public Writer append(final CharSequence csq, final int start, final int end) {
 63  
         //to /dev/null
 64  0
         return this;
 65  
     }
 66  
 
 67  
     /**
 68  
      * Does nothing - output to <code>/dev/null</code>.
 69  
      * @param csq The character sequence to write
 70  
      * @return this writer
 71  
      * @since 2.0
 72  
      */
 73  
     @Override
 74  
     public Writer append(final CharSequence csq) {
 75  
         //to /dev/null
 76  1
         return this;
 77  
     }
 78  
 
 79  
     /**
 80  
      * Does nothing - output to <code>/dev/null</code>.
 81  
      * @param idx The character to write
 82  
      */
 83  
     @Override
 84  
     public void write(final int idx) {
 85  
         //to /dev/null
 86  1
     }
 87  
 
 88  
     /**
 89  
      * Does nothing - output to <code>/dev/null</code>.
 90  
      * @param chr The characters to write
 91  
      */
 92  
     @Override
 93  
     public void write(final char[] chr) {
 94  
         //to /dev/null
 95  2
     }
 96  
 
 97  
     /**
 98  
      * Does nothing - output to <code>/dev/null</code>.
 99  
      * @param chr The characters to write
 100  
      * @param st The start offset
 101  
      * @param end The number of characters to write
 102  
      */
 103  
     @Override
 104  
     public void write(final char[] chr, final int st, final int end) {
 105  
         //to /dev/null
 106  1048578
     }
 107  
 
 108  
     /**
 109  
      * Does nothing - output to <code>/dev/null</code>.
 110  
      * @param str The string to write
 111  
      */
 112  
     @Override
 113  
     public void write(final String str) {
 114  
         //to /dev/null
 115  2
     }
 116  
 
 117  
     /**
 118  
      * Does nothing - output to <code>/dev/null</code>.
 119  
      * @param str The string to write
 120  
      * @param st The start offset
 121  
      * @param end The number of characters to write
 122  
      */
 123  
     @Override
 124  
     public void write(final String str, final int st, final int end) {
 125  
         //to /dev/null
 126  2
     }
 127  
 
 128  
     /** @see java.io.Writer#flush() */
 129  
     @Override
 130  
     public void flush() {
 131  
         //to /dev/null
 132  1
     }
 133  
 
 134  
     /** @see java.io.Writer#close() */
 135  
     @Override
 136  
     public void close() {
 137  
         //to /dev/null
 138  4
     }
 139  
 
 140  
 }