home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / Notes.jar / lotus / notes / internal / AgentOutputStream.class (.txt) next >
Encoding:
Java Class File  |  1998-11-15  |  2.4 KB  |  80 lines

  1. package lotus.notes.internal;
  2.  
  3. import java.io.BufferedOutputStream;
  4. import java.io.IOException;
  5. import java.io.OutputStream;
  6. import java.io.OutputStreamWriter;
  7. import java.io.PrintStream;
  8. import java.io.PrintWriter;
  9. import java.io.UnsupportedEncodingException;
  10.  
  11. public class AgentOutputStream extends OutputStream {
  12.    private long javaDoc;
  13.    private int msg;
  14.    static final int JA_CMSG_MSGBOX = 1;
  15.    static final int JA_CMSG_PRINT = 2;
  16.    static final int JA_CMSG_ERROR = 3;
  17.    static final int JA_CMSG_COMPILE_OUT = 4;
  18.    private static boolean init_called;
  19.  
  20.    AgentOutputStream(long var1, int var3) {
  21.       this.javaDoc = var1;
  22.       this.msg = var3;
  23.    }
  24.  
  25.    private native void writeBytes(long var1, int var3, byte[] var4, int var5, int var6) throws IOException;
  26.  
  27.    public synchronized void write(int var1) throws IOException {
  28.       byte[] var2 = new byte[]{(byte)var1};
  29.       this.writeBytes(this.javaDoc, this.msg, var2, 0, 1);
  30.    }
  31.  
  32.    public synchronized void write(byte[] var1) throws IOException {
  33.       this.writeBytes(this.javaDoc, this.msg, var1, 0, var1.length);
  34.    }
  35.  
  36.    public synchronized void write(byte[] var1, int var2, int var3) throws IOException {
  37.       this.writeBytes(this.javaDoc, this.msg, var1, var2, var3);
  38.    }
  39.  
  40.    static void init() {
  41.       String var0 = System.getProperty("file.encoding");
  42.  
  43.       try {
  44.          System.getProperties().put("file.encoding", "UTF8");
  45.          AgentOutputStream var1 = new AgentOutputStream(0L, 2);
  46.          AgentOutputStream var2 = new AgentOutputStream(0L, 3);
  47.          System.setOut(new PrintStream(new BufferedOutputStream(var1, 1024), true));
  48.          System.setErr(new PrintStream(new BufferedOutputStream(var2, 1024), true));
  49.       } catch (Throwable var3) {
  50.          System.err.println("Exception in AgentOutputStream.init(): " + var3);
  51.          var3.printStackTrace(System.err);
  52.       }
  53.  
  54.       System.getProperties().put("file.encoding", var0);
  55.       init_called = true;
  56.    }
  57.  
  58.    public static PrintWriter getAgentOutput(boolean var0, long var1) {
  59.       OutputStreamWriter var3;
  60.       if (init_called) {
  61.          Object var4;
  62.          if (var0 && var1 != 0L) {
  63.             var4 = new BufferedOutputStream(new AgentOutputStream(var1, 2), 1024);
  64.          } else {
  65.             var4 = System.out;
  66.          }
  67.  
  68.          try {
  69.             var3 = new OutputStreamWriter((OutputStream)var4, "UTF8");
  70.          } catch (UnsupportedEncodingException var5) {
  71.             var3 = new OutputStreamWriter((OutputStream)var4);
  72.          }
  73.       } else {
  74.          var3 = new OutputStreamWriter(System.out);
  75.       }
  76.  
  77.       return new PrintWriter(var3, true);
  78.    }
  79. }
  80.