FileDocCategorySizeDatePackage
LoggingPrintStream.javaAPI DocAndroid 1.5 API6937Wed May 06 22:41:56 BST 2009com.android.internal.os

LoggingPrintStream

public abstract class LoggingPrintStream extends PrintStream
A print stream which logs output line by line. {@hide}

Fields Summary
private final StringBuilder
builder
private final Formatter
formatter
Constructors Summary
protected LoggingPrintStream()


      
        super(new OutputStream() {
            public void write(int oneByte) throws IOException {
                throw new AssertionError();
            }
        });
    
Methods Summary
public synchronized java.io.PrintStreamappend(char c)

        print(c);
        return this;
    
public synchronized java.io.PrintStreamappend(java.lang.CharSequence csq)

        builder.append(csq);
        flush(false);
        return this;
    
public synchronized java.io.PrintStreamappend(java.lang.CharSequence csq, int start, int end)

        builder.append(csq, start, end);
        flush(false);
        return this;
    
public booleancheckError()
Always returns false.

        return false;
    
public voidclose()
Ignored.

 /* ignored */ 
public synchronized voidflush()

        flush(true);
    
private voidflush(boolean completely)
Searches buffer for line breaks and logs a message for each one.

param
completely true if the ending chars should be treated as a line even though they don't end in a line break

        int length = builder.length();

        int start = 0;
        int nextBreak;

        // Log one line for each line break.
        while (start < length
                && (nextBreak = builder.indexOf("\n", start)) != -1) {
            log(builder.substring(start, nextBreak));
            start = nextBreak + 1;
        }

        if (completely) {
            // Log the remainder of the buffer.
            if (start < length) {
                log(builder.substring(start));
            }
            builder.setLength(0);
        } else {
            // Delete characters leading up to the next starting point.
            builder.delete(0, start);
        }
    
public java.io.PrintStreamformat(java.lang.String format, java.lang.Object args)

        return format(Locale.getDefault(), format, args);
    
public synchronized java.io.PrintStreamformat(java.util.Locale l, java.lang.String format, java.lang.Object args)


    
       
                  
        if (format == null) {
            throw new NullPointerException("format");
        }

        formatter.format(l, format, args);
        flush(false);
        return this;
    
protected abstract voidlog(java.lang.String line)
Logs the given line.

public synchronized voidprint(char[] charArray)

        builder.append(charArray);
        flush(false);
    
public synchronized voidprint(char ch)

        builder.append(ch);
        if (ch == '\n") {
            flush(false);
        }
    
public synchronized voidprint(double dnum)

        builder.append(dnum);
    
public synchronized voidprint(float fnum)

        builder.append(fnum);
    
public synchronized voidprint(int inum)

        builder.append(inum);
    
public synchronized voidprint(long lnum)

        builder.append(lnum);
    
public synchronized voidprint(java.lang.Object obj)

        builder.append(obj);
        flush(false);
    
public synchronized voidprint(java.lang.String str)

        builder.append(str);
        flush(false);
    
public synchronized voidprint(boolean bool)

        builder.append(bool);
    
public java.io.PrintStreamprintf(java.lang.String format, java.lang.Object args)

        return format(format, args);
    
public java.io.PrintStreamprintf(java.util.Locale l, java.lang.String format, java.lang.Object args)

        return format(l, format, args);
    
public synchronized voidprintln()

        flush(true);
    
public synchronized voidprintln(char[] charArray)

        builder.append(charArray);
        flush(true);
    
public synchronized voidprintln(char ch)

        builder.append(ch);
        flush(true);
    
public synchronized voidprintln(double dnum)

        builder.append(dnum);
        flush(true);
    
public synchronized voidprintln(float fnum)

        builder.append(fnum);
        flush(true);
    
public synchronized voidprintln(int inum)

        builder.append(inum);
        flush(true);
    
public synchronized voidprintln(long lnum)

        builder.append(lnum);
        flush(true);
    
public synchronized voidprintln(java.lang.Object obj)

        builder.append(obj);
        flush(true);
    
public synchronized voidprintln(java.lang.String s)

        if (builder.length() == 0) {
            // Optimization for a simple println.
            int length = s.length();

            int start = 0;
            int nextBreak;

            // Log one line for each line break.
            while (start < length
                    && (nextBreak = s.indexOf('\n", start)) != -1) {
                log(s.substring(start, nextBreak));
                start = nextBreak + 1;
            }

            if (start < length) {
                log(s.substring(start));
            }
        } else {
            builder.append(s);
            flush(true);
        }
    
public synchronized voidprintln(boolean bool)

        builder.append(bool);
        flush(true);
    
protected voidsetError()
Ignored.

 /* ignored */ 
public voidwrite(int oneByte)
Ignored.

public voidwrite(byte[] buffer)
Ignored.

public voidwrite(byte[] bytes, int start, int count)
Ignored.