home *** CD-ROM | disk | FTP | other *** search
- package lotus.notes.internal;
-
- import java.io.BufferedOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.io.OutputStreamWriter;
- import java.io.PrintStream;
- import java.io.PrintWriter;
- import java.io.UnsupportedEncodingException;
-
- public class AgentOutputStream extends OutputStream {
- private long javaDoc;
- private int msg;
- static final int JA_CMSG_MSGBOX = 1;
- static final int JA_CMSG_PRINT = 2;
- static final int JA_CMSG_ERROR = 3;
- static final int JA_CMSG_COMPILE_OUT = 4;
- private static boolean init_called;
-
- AgentOutputStream(long var1, int var3) {
- this.javaDoc = var1;
- this.msg = var3;
- }
-
- private native void writeBytes(long var1, int var3, byte[] var4, int var5, int var6) throws IOException;
-
- public synchronized void write(int var1) throws IOException {
- byte[] var2 = new byte[]{(byte)var1};
- this.writeBytes(this.javaDoc, this.msg, var2, 0, 1);
- }
-
- public synchronized void write(byte[] var1) throws IOException {
- this.writeBytes(this.javaDoc, this.msg, var1, 0, var1.length);
- }
-
- public synchronized void write(byte[] var1, int var2, int var3) throws IOException {
- this.writeBytes(this.javaDoc, this.msg, var1, var2, var3);
- }
-
- static void init() {
- String var0 = System.getProperty("file.encoding");
-
- try {
- System.getProperties().put("file.encoding", "UTF8");
- AgentOutputStream var1 = new AgentOutputStream(0L, 2);
- AgentOutputStream var2 = new AgentOutputStream(0L, 3);
- System.setOut(new PrintStream(new BufferedOutputStream(var1, 1024), true));
- System.setErr(new PrintStream(new BufferedOutputStream(var2, 1024), true));
- } catch (Throwable var3) {
- System.err.println("Exception in AgentOutputStream.init(): " + var3);
- var3.printStackTrace(System.err);
- }
-
- System.getProperties().put("file.encoding", var0);
- init_called = true;
- }
-
- public static PrintWriter getAgentOutput(boolean var0, long var1) {
- OutputStreamWriter var3;
- if (init_called) {
- Object var4;
- if (var0 && var1 != 0L) {
- var4 = new BufferedOutputStream(new AgentOutputStream(var1, 2), 1024);
- } else {
- var4 = System.out;
- }
-
- try {
- var3 = new OutputStreamWriter((OutputStream)var4, "UTF8");
- } catch (UnsupportedEncodingException var5) {
- var3 = new OutputStreamWriter((OutputStream)var4);
- }
- } else {
- var3 = new OutputStreamWriter(System.out);
- }
-
- return new PrintWriter(var3, true);
- }
- }
-