Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.temp.shared.utils;

import java.io.*;

/**
 * A print stream which can be passed to
 * {@link Throwable#printStackTrace(PrintStream)}. Only the minimally necessary
 * methods for this use are implemented.
 */
public class ExceptionStackTracePrintStream extends PrintStream {
    private final StringBuilder mStringBuilder = new StringBuilder();

    public ExceptionStackTracePrintStream() {
        super( OutputStreamStub.INSTANCE );
    }

    @Override
    public void println( Object x ) {
        mStringBuilder.append( x );
        mStringBuilder.append( "\r\n" );
    }

    @Override
    public void println( String x ) {
        mStringBuilder.append( x );
        mStringBuilder.append( "\r\n" );
    }

    @Override
    public String toString() {
        return mStringBuilder.toString();
    }

    private static class OutputStreamStub extends OutputStream {
        public static final OutputStreamStub INSTANCE = new OutputStreamStub();

        private static final String MESSAGE = "FIXME: this method should never be called";

        public void write( int b ) {
            throw new AssertionError( MESSAGE );
        }

        public void write( byte[] b ) {
            throw new AssertionError( MESSAGE );
        }

        public void write( byte[] b, int off, int len ) {
            throw new AssertionError( MESSAGE );
        }

        public void flush() {
            throw new AssertionError( MESSAGE );
        }

        public void close() {
            throw new AssertionError( MESSAGE );
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/ExceptionStackTracePrintStream.java

Diff revisions: vs.
Revision Author Commited Message
948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

626 GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000