001package de.cuioss.test.generator.internal.net.java.quickcheck;
002
003import java.io.Writer;
004
005/**
006 * This {@link Writer} writes all data to the famous <b>/dev/null</b>.
007 * <p>
008 * This <code>Writer</code> has no destination (file/socket etc.) and all
009 * characters written to it are ignored and lost.
010 *
011 * @author https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/output/NullWriter.java
012 *
013 */
014public class NullWriter extends Writer {
015
016    /**
017     * A singleton.
018     */
019    public static final NullWriter NULL_WRITER = new NullWriter();
020
021    /**
022     * Constructs a new NullWriter.
023     */
024    public NullWriter() {
025        // Intentionally not calling super
026    }
027
028    /**
029     * Does nothing - output to <code>/dev/null</code>.
030     *
031     * @param c The character to write
032     * @return this writer
033     */
034    @Override
035    public Writer append(final char c) {
036        // to /dev/null
037        return this;
038    }
039
040    /**
041     * Does nothing - output to <code>/dev/null</code>.
042     *
043     * @param csq The character sequence to write
044     * @param start The index of the first character to write
045     * @param end The index of the first character to write (exclusive)
046     * @return this writer
047     */
048    @Override
049    public Writer append(final CharSequence csq, final int start, final int end) {
050        // to /dev/null
051        return this;
052    }
053
054    /**
055     * Does nothing - output to <code>/dev/null</code>.
056     *
057     * @param csq The character sequence to write
058     * @return this writer
059     */
060    @Override
061    public Writer append(final CharSequence csq) {
062        // to /dev/null
063        return this;
064    }
065
066    /**
067     * Does nothing - output to <code>/dev/null</code>.
068     *
069     * @param idx The character to write
070     */
071    @Override
072    public void write(final int idx) {
073        // to /dev/null
074    }
075
076    /**
077     * Does nothing - output to <code>/dev/null</code>.
078     *
079     * @param chr The characters to write
080     */
081    @Override
082    public void write(final char[] chr) {
083        // to /dev/null
084    }
085
086    /**
087     * Does nothing - output to <code>/dev/null</code>.
088     *
089     * @param chr The characters to write
090     * @param st The start offset
091     * @param end The number of characters to write
092     */
093    @Override
094    public void write(final char[] chr, final int st, final int end) {
095        // to /dev/null
096    }
097
098    /**
099     * Does nothing - output to <code>/dev/null</code>.
100     *
101     * @param str The string to write
102     */
103    @Override
104    public void write(final String str) {
105        // to /dev/null
106    }
107
108    /**
109     * Does nothing - output to <code>/dev/null</code>.
110     *
111     * @param str The string to write
112     * @param st The start offset
113     * @param end The number of characters to write
114     */
115    @Override
116    public void write(final String str, final int st, final int end) {
117        // to /dev/null
118    }
119
120    /** @see java.io.Writer#flush() */
121    @Override
122    public void flush() {
123        // to /dev/null
124    }
125
126    /** @see java.io.Writer#close() */
127    @Override
128    public void close() {
129        // to /dev/null
130    }
131
132}