All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.printStackTrace_ Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package ceylon.language;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Arrays;

import com.redhat.ceylon.compiler.java.language.AbstractCallable;
import com.redhat.ceylon.compiler.java.metadata.Ceylon;
import com.redhat.ceylon.compiler.java.metadata.Defaulted;
import com.redhat.ceylon.compiler.java.metadata.FunctionalParameter;
import com.redhat.ceylon.compiler.java.metadata.Ignore;
import com.redhat.ceylon.compiler.java.metadata.Method;
import com.redhat.ceylon.compiler.java.metadata.Name;
import com.redhat.ceylon.compiler.java.metadata.TypeInfo;
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor;

@Ceylon(major = 8)
@Method
public final class printStackTrace_
{
    public static void printStackTrace(
            @TypeInfo("ceylon.language::Throwable")
            @Name("exception") final java.lang.Throwable throwable,
            @TypeInfo("ceylon.language::Callable>")
            @Defaulted @Name("write") @FunctionalParameter("!(string)")
            final Callable write) {
        PrintWriter writer = new PrintWriter(new Writer() {
            @Override
            public void write(char[] cbuf, int off, int len) throws IOException {
                write.$call$(String.instance(new java.lang.String(Arrays.copyOfRange(cbuf, off, off+len))));
            }
            @Override
            public void flush() throws IOException {}
            @Override
            public void close() throws IOException {}
        });
        throwable.printStackTrace(writer);
        writer.flush();
    }
    
    @Ignore
    public static void printStackTrace(final java.lang.Throwable throwable) {
        printStackTrace(throwable, printStackTrace$writeLine());
    }
    
    @Ignore
    public static Callable printStackTrace$writeLine() {
        return new AbstractCallable(Anything.$TypeDescriptor$, 
                TypeDescriptor.klass(Tuple.class, String.$TypeDescriptor$, String.$TypeDescriptor$, Empty.$TypeDescriptor$),
                "write", (short)-1) {
            @Override
            public java.lang.Object $call$(java.lang.Object arg) {
                System.err.print(arg);
                return null;
            }
        };
    }
    
    private printStackTrace_(){}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy