tn5250j/src/org/tn5250j/framework/tn5250 KeyStrokenizer.java,1.3,1.4 ScreenOIA.java,1.4,1.5 Stream5250.java,1.2,1.3 DataStreamQueue.java,1.2,1.3 ScreenPlanes.java,1.9,1.10 ScreenField.java,1.7,1.8 ScreenFields.java,1.4,1.5 DataStreamProducer.java,1.2,1.3

"Kenneth J. Pouncey" <[email protected]> Thu, 16 Jun 2005 04:41:20 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24279/src/org/tn5250j/framework/tn5250

Modified Files:
	KeyStrokenizer.java ScreenOIA.java Stream5250.java 
	DataStreamQueue.java ScreenPlanes.java ScreenField.java 
	ScreenFields.java DataStreamProducer.java 
Log Message:
the rest of the story

Index: DataStreamProducer.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/DataStreamProducer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DataStreamProducer.java	30 Jul 2004 05:03:57 -0000	1.2
--- DataStreamProducer.java	16 Jun 2005 04:41:18 -0000	1.3
***************
*** 1,360 ****
! package org.tn5250j.framework.tn5250;
! 
! import java.io.*;
! import java.net.*;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.encoding.CodePage;
! 
! public class DataStreamProducer implements Runnable {
! 
!    private BufferedInputStream bin;
!    private ByteArrayOutputStream baosin;
!    private Thread me;
!    private byte[] saveStream;
!    private DataStreamQueue dsq;
!    private tnvt vt;
!    private byte[] abyte2;
!    private FileOutputStream fw;
!    private BufferedOutputStream dw;
!    private boolean dumpBytes = false;
!    private CodePage codePage;
! 
!    private TN5250jLogger  log = TN5250jLogFactory.getLogger (this.getClass());
! 
!    public DataStreamProducer(tnvt vt, BufferedInputStream in, DataStreamQueue queue, byte[] init) {
!       bin = in;
!       this.vt = vt;
!       baosin = new ByteArrayOutputStream();
!       dsq = queue;
!       abyte2 = init;
!    }
! 
!    public void setInputStream(ByteArrayOutputStream is) {
! 
!       baosin = is;
! 
!    }
! 
!    public void setQueue( DataStreamQueue queue) {
! 
!       dsq = queue;
! 
!    }
! 
!    public final void run() {
! 
!       boolean done = false;
! 
!       me = Thread.currentThread();
! 
!       // load the first response screen
!       try {
!          loadStream(abyte2, 0);
!       }
!       catch (IOException ioef) {
!          log.warn(" run() " + ioef.getMessage());
!       }
!       while (!done) {
! 		  try {
! 
! 			  byte[] abyte0 = readIncoming();
! 
! 			  // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK
! 			  // Restructured to the readIncoming() method to return null
! 			  // on TIMING MARK. Don't process in that case (abyte0 == null)!
! 			  if (abyte0 != null)
! 			  {
! 				  // WVL - LDC : 16/07/2003 : TR.000345
! 				  // When the socket has been closed, the reading returns
! 				  // no bytes (an empty byte arrray).
! 				  // But the loadStream fails on this, so we check it here!
! 				  if (abyte0.length > 0)
! 				  {
! 					  loadStream(abyte0, 0);
! 				  }
! 				  // WVL - LDC : 16/07/2003 : TR.000345
! 				  // Returning no bytes means the input buffer has
! 				  // reached end-of-stream, so we do a disconnect!
! 				  else
! 				  {
! 					  done = true;
! 					  vt.disconnect();
! 				  }
! 			  }
! 
!          }
! 
! 		 catch (SocketException se) {
!             log.warn("   DataStreamProducer thread interrupted and stopping " + se.getMessage());
!             done = true;
!          }
! 
!          catch (IOException ioe) {
! 
! 		   log.warn(ioe.getMessage());
!            if (me.isInterrupted())
!               done = true;
! 
!          }
!          catch (Exception ex) {
! 
!            log.warn(ex.getMessage());
!            if (me.isInterrupted())
!               done = true;
! 
!          }
!       }
!     }
! 
!    private final void loadStream(byte abyte0[], int i)
!      throws IOException {
! 
!       int j = 0;
!       int size = 0;
!       if (saveStream == null) {
!          j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff;
!          size = abyte0.length;
!       }
!       else {
!          size = saveStream.length + abyte0.length;
!          byte[] inter = new byte[size];
!          System.arraycopy(saveStream, 0, inter, 0, saveStream.length);
!          System.arraycopy(abyte0, 0, inter, saveStream.length, abyte0.length);
!          abyte0 = new byte[size];
!          System.arraycopy(inter, 0, abyte0, 0, size);
!          saveStream = null;
!          inter = null;
!          j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff;
! 		 log.debug("partial stream found");
!       }
! 
!       if (j > size) {
!          saveStream = new byte[abyte0.length];
!          System.arraycopy(abyte0, 0, saveStream, 0, abyte0.length);
! 		 log.debug("partial stream saved");
!       }
!       else {
!          byte abyte1[];
!          try {
!             abyte1 = new byte[j + 2];
! 
!             System.arraycopy(abyte0, i, abyte1, 0, j + 2);
!             dsq.put(new Stream5250(abyte1));
!             if(abyte0.length > abyte1.length + i)
!                 loadStream(abyte0, i + j + 2);
!          }
!          catch (Exception ex) {
! 
!            log.warn("load stream error " + ex.getMessage());
!    //        ex.printStackTrace();
!    //        dump(abyte0);
! 
!          }
!       }
!    }
! 
!    public final byte[] readIncoming()
!         throws IOException {
! 
!       boolean done = false;
!       boolean negotiate = false;
! 
!       baosin.reset();
!       int j = -1;
!       int i = 0;
! 
!       while(!done) {
!          i = bin.read();
! 
!          // WVL - LDC : 16/07/2003 : TR.000345
!          // The inStream return -1 when end-of-stream is reached. This
!          // happens e.g. when the connection is closed from the AS/400.
!          // So we stop in this case!
!          // ==> an empty byte array is returned from this method.
!          if (i == -1) // nothing read!
!          {
!            done = true;
!             vt.disconnect();
!            continue;
!          }
! 
!          // We use the values instead of the static values IAC and EOR
!          //    because they are defined as bytes.
!          //
!          // The > if(i != 255 || j != 255)  < is a hack for the double FF FF's
!          // that are being returned.  I do not know why this is like this and
!          // can not find any documentation for it.  It is also being returned
!          // on my Client Access tcp dump as well so they are handling it.
!          //
!          // my5250
!          // 0000:  00 50 DA 44 C8 45 42 00 00 00 00 24 08 00 45 00 .P.D.EB....$..E.
!          // 0010:  04 2A BC F9 00 00 40 06 D0 27 C1 A8 33 04 C1 A8 .*....@..'..3...
!          // 0020:  33 58 00 17 04 18 6F A2 83 CB 00 1E D1 BA 50 18 3X....o.......P.
!          // 0030:  20 00 8A 9A 00 00 03 FF FF 12 A0 00 00 04 00 00  ...............
!          // --------------------------- || || -------------------------------------
!          // 0040:  03 04 40 04 11 00 20 01 07 00 00 00 18 00 00 10 ..@... .........
! 
!          if(j == 255 && i == 255) {
!             j = -1;
!             continue;
!          }
!          else {
!             baosin.write(i);
!             // check for end of record EOR and IAC  - FFEF
!             if(j == 255 && i == 239)
!                done = true;
! 
!             // This is to check for the TELNET TIMING MARK OPTION
!             // rfc860 explains this in more detail.  When we receive it
!             // we will negotiate with the server by sending a WONT'T TIMING-MARK
!             // This will let the server know that we processed the information
!             // and are just waiting for the user to enter some data so keep the
!             // socket alive.   This is more or less a AYT (ARE YOU THERE) or not.
!             if(i == 253 && j == 255) {
!                done = true;
!                negotiate = true;
!             }
!             j = i;
!          }
!      }
! 
!      // after the initial negotiation we might get other options such as
!      //    timing marks ??????????????  do we ???????????? look at telnet spec
!      // yes we do. rfc860 explains about timing marks.
! 
!      	 // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK
!      	 //                          to existing device!
!      	 // Handled incorrectly: we cannot continue processing the TIMING MARK DO
!      	 // after we have handled it in the vt.negotiate()
!      	 // We should not return the bytes;
!      	 // ==> restructured to return null after negotiation!
!      	 //     Impacts the run method! Added the null check.
!      	 byte[] rBytes = baosin.toByteArray();
! 
! 		 if (dumpBytes) {
! 			dump(rBytes);
! 		 }
! 
!          if (negotiate) {
!             // get the negotiation option
!             baosin.write(bin.read());
!             vt.negotiate(rBytes);
! 
!             return null;
!          }
!          else
!          {
! 			 return rBytes;
! 		 }
! 	}
! 
!    protected final void toggleDebug (CodePage cp) {
! 
!       if (codePage == null)
!          codePage = cp;
! 
!       dumpBytes = !dumpBytes;
!       if (dumpBytes) {
! 
!          try {
!             if (fw == null) {
!                fw = new FileOutputStream("log.txt");
!                dw = new BufferedOutputStream(fw);
!             }
!          }
!          catch (FileNotFoundException fnfe) {
!             log.warn(fnfe.getMessage());
!          }
! 
!       }
!       else {
! 
!          try {
! 
!             if (dw != null)
!                dw.close();
!             if (fw != null)
!                fw.close();
!             dw = null;
!             fw = null;
!             codePage = null;
!          }
!          catch(IOException ioe) {
! 
!             log.warn(ioe.getMessage());
!          }
!       }
! 
!       log.info("Data Stream output is now " + dumpBytes);
!    }
! 
!    public void dump (byte[] abyte0) {
!       try {
! 
!          log.info("\n Buffer Dump of data from AS400: ");
!          dw.write("\r\n Buffer Dump of data from AS400: ".getBytes());
! 
!          StringBuffer h = new StringBuffer();
!          for (int x = 0; x < abyte0.length; x++) {
!             if (x % 16 == 0) {
!                System.out.println("  " + h.toString());
!                dw.write(("  " + h.toString() + "\r\n").getBytes());
! 
!                h.setLength(0);
!                h.append("+0000");
!                h.setLength(5 - Integer.toHexString(x).length());
!                h.append(Integer.toHexString(x).toUpperCase());
! 
!                System.out.print(h.toString());
!                dw.write(h.toString().getBytes());
! 
!                h.setLength(0);
!             }
!             char ac = codePage.ebcdic2uni(abyte0[x]);
!             if (ac < ' ')
!                h.append('.');
!             else
!                h.append(ac);
!             if (x % 4 == 0) {
!                System.out.print(" ");
!                dw.write((" ").getBytes());
! 
!             }
! 
!             if (Integer.toHexString(abyte0[x] & 0xff).length() == 1){
!                System.out.print("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase());
!                dw.write(("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes());
! 
!             }
!             else {
!                System.out.print(Integer.toHexString(abyte0[x] & 0xff).toUpperCase());
!                dw.write((Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes());
!             }
! 
!          }
!          System.out.println();
!          dw.write("\r\n".getBytes());
! 
!          dw.flush();
!       }
!       catch(EOFException _ex) { }
!       catch(Exception _ex) {
!          log.warn("Cannot dump from host\n\r");
!       }
! 
!    }
! 
! //      public void dumpBytes() {
! //         byte shit[] = bk.buffer;
! //         for (int i = 0;i < shit.length;i++)
! //            System.out.println(i + ">" + shit[i] + "< - ascii - >" + getASCIIChar(shit[i]) + "<");
! //      }
! //
! //      public void dumpHexBytes(byte[] abyte) {
! //         byte shit[] = abyte;
! //         for (int i = 0;i < shit.length;i++)
! //            System.out.println(i + ">" + shit[i] + "< hex >" + Integer.toHexString((shit[i] & 0xff)));
! //      }
! 
  }
\ No newline at end of file
--- 1,360 ----
! package org.tn5250j.framework.tn5250;
! 
! import java.io.*;
! import java.net.*;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.encoding.CodePage;
! 
! public class DataStreamProducer implements Runnable {
! 
!    private BufferedInputStream bin;
!    private ByteArrayOutputStream baosin;
!    private Thread me;
!    private byte[] saveStream;
!    private DataStreamQueue dsq;
!    private tnvt vt;
!    private byte[] abyte2;
!    private FileOutputStream fw;
!    private BufferedOutputStream dw;
!    private boolean dumpBytes = false;
!    private CodePage codePage;
! 
!    private TN5250jLogger  log = TN5250jLogFactory.getLogger (this.getClass());
! 
!    public DataStreamProducer(tnvt vt, BufferedInputStream in, DataStreamQueue queue, byte[] init) {
!       bin = in;
!       this.vt = vt;
!       baosin = new ByteArrayOutputStream();
!       dsq = queue;
!       abyte2 = init;
!    }
! 
!    public void setInputStream(ByteArrayOutputStream is) {
! 
!       baosin = is;
! 
!    }
! 
!    public void setQueue( DataStreamQueue queue) {
! 
!       dsq = queue;
! 
!    }
! 
!    public final void run() {
! 
!       boolean done = false;
! 
!       me = Thread.currentThread();
! 
!       // load the first response screen
!       try {
!          loadStream(abyte2, 0);
!       }
!       catch (IOException ioef) {
!          log.warn(" run() " + ioef.getMessage());
!       }
!       while (!done) {
! 		  try {
! 
! 			  byte[] abyte0 = readIncoming();
! 
! 			  // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK
! 			  // Restructured to the readIncoming() method to return null
! 			  // on TIMING MARK. Don't process in that case (abyte0 == null)!
! 			  if (abyte0 != null)
! 			  {
! 				  // WVL - LDC : 16/07/2003 : TR.000345
! 				  // When the socket has been closed, the reading returns
! 				  // no bytes (an empty byte arrray).
! 				  // But the loadStream fails on this, so we check it here!
! 				  if (abyte0.length > 0)
! 				  {
! 					  loadStream(abyte0, 0);
! 				  }
! 				  // WVL - LDC : 16/07/2003 : TR.000345
! 				  // Returning no bytes means the input buffer has
! 				  // reached end-of-stream, so we do a disconnect!
! 				  else
! 				  {
! 					  done = true;
! 					  vt.disconnect();
! 				  }
! 			  }
! 
!          }
! 
! 		 catch (SocketException se) {
!             log.warn("   DataStreamProducer thread interrupted and stopping " + se.getMessage());
!             done = true;
!          }
! 
!          catch (IOException ioe) {
! 
! 		   log.warn(ioe.getMessage());
!            if (me.isInterrupted())
!               done = true;
! 
!          }
!          catch (Exception ex) {
! 
!            log.warn(ex.getMessage());
!            if (me.isInterrupted())
!               done = true;
! 
!          }
!       }
!     }
! 
!    private final void loadStream(byte abyte0[], int i)
!      throws IOException {
! 
!       int j = 0;
!       int size = 0;
!       if (saveStream == null) {
!          j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff;
!          size = abyte0.length;
!       }
!       else {
!          size = saveStream.length + abyte0.length;
!          byte[] inter = new byte[size];
!          System.arraycopy(saveStream, 0, inter, 0, saveStream.length);
!          System.arraycopy(abyte0, 0, inter, saveStream.length, abyte0.length);
!          abyte0 = new byte[size];
!          System.arraycopy(inter, 0, abyte0, 0, size);
!          saveStream = null;
!          inter = null;
!          j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff;
! 		 log.debug("partial stream found");
!       }
! 
!       if (j > size) {
!          saveStream = new byte[abyte0.length];
!          System.arraycopy(abyte0, 0, saveStream, 0, abyte0.length);
! 		 log.debug("partial stream saved");
!       }
!       else {
!          byte abyte1[];
!          try {
!             abyte1 = new byte[j + 2];
! 
!             System.arraycopy(abyte0, i, abyte1, 0, j + 2);
!             dsq.put(new Stream5250(abyte1));
!             if(abyte0.length > abyte1.length + i)
!                 loadStream(abyte0, i + j + 2);
!          }
!          catch (Exception ex) {
! 
!            log.warn("load stream error " + ex.getMessage());
!    //        ex.printStackTrace();
!    //        dump(abyte0);
! 
!          }
!       }
!    }
! 
!    public final byte[] readIncoming()
!         throws IOException {
! 
!       boolean done = false;
!       boolean negotiate = false;
! 
!       baosin.reset();
!       int j = -1;
!       int i = 0;
! 
!       while(!done) {
!          i = bin.read();
! 
!          // WVL - LDC : 16/07/2003 : TR.000345
!          // The inStream return -1 when end-of-stream is reached. This
!          // happens e.g. when the connection is closed from the AS/400.
!          // So we stop in this case!
!          // ==> an empty byte array is returned from this method.
!          if (i == -1) // nothing read!
!          {
!            done = true;
!             vt.disconnect();
!            continue;
!          }
! 
!          // We use the values instead of the static values IAC and EOR
!          //    because they are defined as bytes.
!          //
!          // The > if(i != 255 || j != 255)  < is a hack for the double FF FF's
!          // that are being returned.  I do not know why this is like this and
!          // can not find any documentation for it.  It is also being returned
!          // on my Client Access tcp dump as well so they are handling it.
!          //
!          // my5250
!          // 0000:  00 50 DA 44 C8 45 42 00 00 00 00 24 08 00 45 00 .P.D.EB....$..E.
!          // 0010:  04 2A BC F9 00 00 40 06 D0 27 C1 A8 33 04 C1 A8 .*....@..'..3...
!          // 0020:  33 58 00 17 04 18 6F A2 83 CB 00 1E D1 BA 50 18 3X....o.......P.
!          // 0030:  20 00 8A 9A 00 00 03 FF FF 12 A0 00 00 04 00 00  ...............
!          // --------------------------- || || -------------------------------------
!          // 0040:  03 04 40 04 11 00 20 01 07 00 00 00 18 00 00 10 ..@... .........
! 
!          if(j == 255 && i == 255) {
!             j = -1;
!             continue;
!          }
!          else {
!             baosin.write(i);
!             // check for end of record EOR and IAC  - FFEF
!             if(j == 255 && i == 239)
!                done = true;
! 
!             // This is to check for the TELNET TIMING MARK OPTION
!             // rfc860 explains this in more detail.  When we receive it
!             // we will negotiate with the server by sending a WONT'T TIMING-MARK
!             // This will let the server know that we processed the information
!             // and are just waiting for the user to enter some data so keep the
!             // socket alive.   This is more or less a AYT (ARE YOU THERE) or not.
!             if(i == 253 && j == 255) {
!                done = true;
!                negotiate = true;
!             }
!             j = i;
!          }
!      }
! 
!      // after the initial negotiation we might get other options such as
!      //    timing marks ??????????????  do we ???????????? look at telnet spec
!      // yes we do. rfc860 explains about timing marks.
! 
!      	 // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK
!      	 //                          to existing device!
!      	 // Handled incorrectly: we cannot continue processing the TIMING MARK DO
!      	 // after we have handled it in the vt.negotiate()
!      	 // We should not return the bytes;
!      	 // ==> restructured to return null after negotiation!
!      	 //     Impacts the run method! Added the null check.
!      	 byte[] rBytes = baosin.toByteArray();
! 
! 		 if (dumpBytes) {
! 			dump(rBytes);
! 		 }
! 
!          if (negotiate) {
!             // get the negotiation option
!             baosin.write(bin.read());
!             vt.negotiate(rBytes);
! 
!             return null;
!          }
!          else
!          {
! 			 return rBytes;
! 		 }
! 	}
! 
!    protected final void toggleDebug (CodePage cp) {
! 
!       if (codePage == null)
!          codePage = cp;
! 
!       dumpBytes = !dumpBytes;
!       if (dumpBytes) {
! 
!          try {
!             if (fw == null) {
!                fw = new FileOutputStream("log.txt");
!                dw = new BufferedOutputStream(fw);
!             }
!          }
!          catch (FileNotFoundException fnfe) {
!             log.warn(fnfe.getMessage());
!          }
! 
!       }
!       else {
! 
!          try {
! 
!             if (dw != null)
!                dw.close();
!             if (fw != null)
!                fw.close();
!             dw = null;
!             fw = null;
!             codePage = null;
!          }
!          catch(IOException ioe) {
! 
!             log.warn(ioe.getMessage());
!          }
!       }
! 
!       log.info("Data Stream output is now " + dumpBytes);
!    }
! 
!    public void dump (byte[] abyte0) {
!       try {
! 
!          log.info("\n Buffer Dump of data from AS400: ");
!          dw.write("\r\n Buffer Dump of data from AS400: ".getBytes());
! 
!          StringBuffer h = new StringBuffer();
!          for (int x = 0; x < abyte0.length; x++) {
!             if (x % 16 == 0) {
!                System.out.println("  " + h.toString());
!                dw.write(("  " + h.toString() + "\r\n").getBytes());
! 
!                h.setLength(0);
!                h.append("+0000");
!                h.setLength(5 - Integer.toHexString(x).length());
!                h.append(Integer.toHexString(x).toUpperCase());
! 
!                System.out.print(h.toString());
!                dw.write(h.toString().getBytes());
! 
!                h.setLength(0);
!             }
!             char ac = codePage.ebcdic2uni(abyte0[x]);
!             if (ac < ' ')
!                h.append('.');
!             else
!                h.append(ac);
!             if (x % 4 == 0) {
!                System.out.print(" ");
!                dw.write((" ").getBytes());
! 
!             }
! 
!             if (Integer.toHexString(abyte0[x] & 0xff).length() == 1){
!                System.out.print("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase());
!                dw.write(("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes());
! 
!             }
!             else {
!                System.out.print(Integer.toHexString(abyte0[x] & 0xff).toUpperCase());
!                dw.write((Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes());
!             }
! 
!          }
!          System.out.println();
!          dw.write("\r\n".getBytes());
! 
!          dw.flush();
!       }
!       catch(EOFException _ex) { }
!       catch(Exception _ex) {
!          log.warn("Cannot dump from host\n\r");
!       }
! 
!    }
! 
! //      public void dumpBytes() {
! //         byte shit[] = bk.buffer;
! //         for (int i = 0;i < shit.length;i++)
! //            System.out.println(i + ">" + shit[i] + "< - ascii - >" + getASCIIChar(shit[i]) + "<");
! //      }
! //
! //      public void dumpHexBytes(byte[] abyte) {
! //         byte shit[] = abyte;
! //         for (int i = 0;i < shit.length;i++)
! //            System.out.println(i + ">" + shit[i] + "< hex >" + Integer.toHexString((shit[i] & 0xff)));
! //      }
! 
  }
\ No newline at end of file

Index: KeyStrokenizer.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** KeyStrokenizer.java	8 Jun 2005 19:45:21 -0000	1.3
--- KeyStrokenizer.java	16 Jun 2005 04:41:17 -0000	1.4
***************
*** 1,162 ****
! /*
!  * @(#)KeyStrokenizer.java
!  * Copyright:    Copyright (c) 2001
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! 
! package org.tn5250j.framework.tn5250;
! 
! import org.tn5250j.tools.logging.*;
! 
! 
! public class KeyStrokenizer {
!    
!    private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
!    
!    public KeyStrokenizer() {
! 
!       sb = new StringBuffer();
!       setKeyStrokes(null);
!    }
! 
!    public void setKeyStrokes (String strokes) {
! 
!       if (strokes != null) {
!          keyStrokes.setLength(0);
! 		 log.debug("set "+ keyStrokes);
!          length = strokes.length();
!       }
!       else {
! 
!          keyStrokes = new StringBuffer();
!          length = 0;
! 
!       }
!       keyStrokes.append(strokes);
!       index = 0;
! 
!    }
! 
!    public boolean hasMoreKeyStrokes() {
!       return length > index;
!    }
! 
!    public String nextKeyStroke() {
! 
!       String s = "";
!       boolean gotOne = false;
!       int start = index;
!       if(length > index) {
!          sb.setLength(0);
! 
!          char c = keyStrokes.charAt(index);
!          switch(c) {
!             case '[':
!                sb.append(c);
!                index++;
! 
!                // we need to throw an error here
!                if(index >= length) {
!                   log.warn(" mnemonic key was incomplete :1 " +
!                                        "at position " + index + " len " + length );
!                }
!                else {
!                   c = keyStrokes.charAt(index);
! 
!                   if(c == '[')
!                        index++;
!                   else {
!                      while(!gotOne) {
! 
!                         if(c == ']') { // did we find an ending
!                            sb.append(c);
!                            index++;
!                            gotOne = true;
!                         }
!                         else {
!                            sb.append(c);
!                            index++;
!                            // we need to throw an error here because we did not
!                            //   find an ending for the potential mnemonic
!                            if(index >= length) {
!                               log.warn(
!                               " mnemonic key was incomplete ending not found :2 " +
!                                           "at position " + index);
!                            }
!                            c = keyStrokes.charAt(index);
!                         }
!                      }
!                   }
!                }
!                break;
! 
!             case ']':
!                index++;
!                if(index >= length) {
!                   log.warn(
!                   " mnemonic key was incomplete ending not found :3 " +
!                               "at position " + index);
!                   sb.append(c);
!                   index++;
! 
!                }
!                else {
!                   c = keyStrokes.charAt(index);
!                   if(c == ']') {
!                      sb.append(c);
!                      index++;
!                   }
!                   else {
!                      log.warn(
!                      " mnemonic key was incomplete beginning not found :4 " +
!                                  "at position " + index);
!                   }
!                }
!                break;
!             default:
!                sb.append(c);
!                index++;
!                break;
!          }
!          if(sb != null) {
!             s = new String(sb);
!          }
! 
!       }
! 	  log.debug("next "+ keyStrokes);
! 
!       return s;
!    }
! 
!    public String getUnprocessedKeyStroked() {
! 
! 
!       if(index >= length)
!          return null;
!       else {
!          return keyStrokes.substring(index);
!       }
! 
!    }
! 
!    private StringBuffer keyStrokes;
!    private StringBuffer sb;
!    private int index;
!    private int length;
! 
  }
\ No newline at end of file
--- 1,162 ----
! /*
!  * @(#)KeyStrokenizer.java
!  * Copyright:    Copyright (c) 2001
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! 
! package org.tn5250j.framework.tn5250;
! 
! import org.tn5250j.tools.logging.*;
! 
! 
! public class KeyStrokenizer {
!    
!    private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
!    
!    public KeyStrokenizer() {
! 
!       sb = new StringBuffer();
!       setKeyStrokes(null);
!    }
! 
!    public void setKeyStrokes (String strokes) {
! 
!       if (strokes != null) {
!          keyStrokes.setLength(0);
! 		 log.debug("set "+ keyStrokes);
!          length = strokes.length();
!       }
!       else {
! 
!          keyStrokes = new StringBuffer();
!          length = 0;
! 
!       }
!       keyStrokes.append(strokes);
!       index = 0;
! 
!    }
! 
!    public boolean hasMoreKeyStrokes() {
!       return length > index;
!    }
! 
!    public String nextKeyStroke() {
! 
!       String s = "";
!       boolean gotOne = false;
!       int start = index;
!       if(length > index) {
!          sb.setLength(0);
! 
!          char c = keyStrokes.charAt(index);
!          switch(c) {
!             case '[':
!                sb.append(c);
!                index++;
! 
!                // we need to throw an error here
!                if(index >= length) {
!                   log.warn(" mnemonic key was incomplete :1 " +
!                                        "at position " + index + " len " + length );
!                }
!                else {
!                   c = keyStrokes.charAt(index);
! 
!                   if(c == '[')
!                        index++;
!                   else {
!                      while(!gotOne) {
! 
!                         if(c == ']') { // did we find an ending
!                            sb.append(c);
!                            index++;
!                            gotOne = true;
!                         }
!                         else {
!                            sb.append(c);
!                            index++;
!                            // we need to throw an error here because we did not
!                            //   find an ending for the potential mnemonic
!                            if(index >= length) {
!                               log.warn(
!                               " mnemonic key was incomplete ending not found :2 " +
!                                           "at position " + index);
!                            }
!                            c = keyStrokes.charAt(index);
!                         }
!                      }
!                   }
!                }
!                break;
! 
!             case ']':
!                index++;
!                if(index >= length) {
!                   log.warn(
!                   " mnemonic key was incomplete ending not found :3 " +
!                               "at position " + index);
!                   sb.append(c);
!                   index++;
! 
!                }
!                else {
!                   c = keyStrokes.charAt(index);
!                   if(c == ']') {
!                      sb.append(c);
!                      index++;
!                   }
!                   else {
!                      log.warn(
!                      " mnemonic key was incomplete beginning not found :4 " +
!                                  "at position " + index);
!                   }
!                }
!                break;
!             default:
!                sb.append(c);
!                index++;
!                break;
!          }
!          if(sb != null) {
!             s = new String(sb);
!          }
! 
!       }
! 	  log.debug("next "+ keyStrokes);
! 
!       return s;
!    }
! 
!    public String getUnprocessedKeyStroked() {
! 
! 
!       if(index >= length)
!          return null;
!       else {
!          return keyStrokes.substring(index);
!       }
! 
!    }
! 
!    private StringBuffer keyStrokes;
!    private StringBuffer sb;
!    private int index;
!    private int length;
! 
  }
\ No newline at end of file

Index: Stream5250.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/Stream5250.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Stream5250.java	30 Jul 2004 05:03:57 -0000	1.2
--- Stream5250.java	16 Jun 2005 04:41:18 -0000	1.3
***************
*** 1,148 ****
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.framework.tn5250;
! 
! public class Stream5250 {
! 
!     public int streamSize;
!     public int opCode;
!     public int dataStart;
!     public int pos;
!     public byte buffer[];
! 
!     public Stream5250(byte abyte0[]) {
!         buffer = abyte0;
!         // size without end of record 0xFF 0xEF
!         streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff;
!         opCode = abyte0[9];
!         dataStart = 6 + abyte0[6];
!         pos = dataStart;
!     }
! 
!     public final int getOpCode() {
!         return opCode;
!     }
! 
!     public final byte getNextByte()
!         throws Exception  {
!         if(pos > buffer.length)
!             throw new Exception("Buffer length exceeded: " + pos);
!         else
!             return buffer[pos++];
!     }
! 
!     public final void setPrevByte()
!         throws Exception {
!         if(pos == 0) {
!             throw new Exception("Index equals zero.");
!         }
!         else {
!             pos--;
!             return;
!       }
!    }
! 
!    /**
!     * Returns where we are in the buffer
!     * @return position in the buffer
!     */
!    public final int getCurrentPos() {
!       return pos;
!    }
! 
!    public final byte getByteOffset(int off)
!         throws Exception  {
! 
!         if((pos + off ) > buffer.length)
!             throw new Exception("Buffer length exceeded: " + pos);
!         else
!             return buffer[pos + off];
! 
!    }
! 
!    public final boolean size() {
!       return pos >= streamSize;
!    }
! 
! 
!    /**
!     * Determines if any more bytes are available in the buffer to be processed.
!     * @return yes or no
!     */
!    public final boolean hasNext() {
! 
! //      return pos >= buffer.length;
!       return pos < streamSize;
!    }
! 
!    /**
!     * This routine will retrieve a segment based on the first two bytes being
!     * the length of the segment.
!     *
!     * @return a new byte array containing the bytes of the segment.
!     * @throws Exception
!     */
!    public final byte[] getSegment() throws Exception {
! 
!       // The first two bytes contain the length of the segment.
!       int length = ((buffer[pos] & 0xff )<< 8 | (buffer[pos+1] & 0xff));
!       // allocate space for it.
!       byte[] segment = new byte[length];
! 
!       getSegment(segment,length,true);
! 
!       return segment;
!    }
! 
! 
!    /**
!     * This routine will retrieve a byte array based on the first two bytes being
!     * the length of the segment.
!     *
!     * @param segment - byte array
!     * @param length - length of segment to return
!     * @param adjustPos - adjust the position of the buffer to the end of the seg
!     *                      ment
!     * @throws Exception
!     */
!    public final void getSegment(byte[] segment, int length, boolean adjustPos)
!                throws Exception {
! 
!       // If the length is larger than what is available throw an exception
!       if((pos + length ) > buffer.length)
!             throw new Exception("Buffer length exceeded: start " + pos
!                                  + " length " + length);
!       // use the system array copy to move the bytes from the buffer
!       //    to the allocated byte array
!       System.arraycopy(buffer,pos,segment,0,length);
! 
!       // update the offset to be after the segment so the next byte can be read
!       if (adjustPos)
!          pos +=length;
! 
!    }
! 
! }
--- 1,148 ----
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.framework.tn5250;
! 
! public class Stream5250 {
! 
!     public int streamSize;
!     public int opCode;
!     public int dataStart;
!     public int pos;
!     public byte buffer[];
! 
!     public Stream5250(byte abyte0[]) {
!         buffer = abyte0;
!         // size without end of record 0xFF 0xEF
!         streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff;
!         opCode = abyte0[9];
!         dataStart = 6 + abyte0[6];
!         pos = dataStart;
!     }
! 
!     public final int getOpCode() {
!         return opCode;
!     }
! 
!     public final byte getNextByte()
!         throws Exception  {
!         if(pos > buffer.length)
!             throw new Exception("Buffer length exceeded: " + pos);
!         else
!             return buffer[pos++];
!     }
! 
!     public final void setPrevByte()
!         throws Exception {
!         if(pos == 0) {
!             throw new Exception("Index equals zero.");
!         }
!         else {
!             pos--;
!             return;
!       }
!    }
! 
!    /**
!     * Returns where we are in the buffer
!     * @return position in the buffer
!     */
!    public final int getCurrentPos() {
!       return pos;
!    }
! 
!    public final byte getByteOffset(int off)
!         throws Exception  {
! 
!         if((pos + off ) > buffer.length)
!             throw new Exception("Buffer length exceeded: " + pos);
!         else
!             return buffer[pos + off];
! 
!    }
! 
!    public final boolean size() {
!       return pos >= streamSize;
!    }
! 
! 
!    /**
!     * Determines if any more bytes are available in the buffer to be processed.
!     * @return yes or no
!     */
!    public final boolean hasNext() {
! 
! //      return pos >= buffer.length;
!       return pos < streamSize;
!    }
! 
!    /**
!     * This routine will retrieve a segment based on the first two bytes being
!     * the length of the segment.
!     *
!     * @return a new byte array containing the bytes of the segment.
!     * @throws Exception
!     */
!    public final byte[] getSegment() throws Exception {
! 
!       // The first two bytes contain the length of the segment.
!       int length = ((buffer[pos] & 0xff )<< 8 | (buffer[pos+1] & 0xff));
!       // allocate space for it.
!       byte[] segment = new byte[length];
! 
!       getSegment(segment,length,true);
! 
!       return segment;
!    }
! 
! 
!    /**
!     * This routine will retrieve a byte array based on the first two bytes being
!     * the length of the segment.
!     *
!     * @param segment - byte array
!     * @param length - length of segment to return
!     * @param adjustPos - adjust the position of the buffer to the end of the seg
!     *                      ment
!     * @throws Exception
!     */
!    public final void getSegment(byte[] segment, int length, boolean adjustPos)
!                throws Exception {
! 
!       // If the length is larger than what is available throw an exception
!       if((pos + length ) > buffer.length)
!             throw new Exception("Buffer length exceeded: start " + pos
!                                  + " length " + length);
!       // use the system array copy to move the bytes from the buffer
!       //    to the allocated byte array
!       System.arraycopy(buffer,pos,segment,0,length);
! 
!       // update the offset to be after the segment so the next byte can be read
!       if (adjustPos)
!          pos +=length;
! 
!    }
! 
! }

Index: DataStreamQueue.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/DataStreamQueue.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DataStreamQueue.java	30 Jul 2004 05:03:57 -0000	1.2
--- DataStreamQueue.java	16 Jun 2005 04:41:18 -0000	1.3
***************
*** 1,106 ****
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.framework.tn5250;
! 
! import java.util.Vector;
! 
! public class DataStreamQueue {
! 
!    private final Object lock = new Object();
!    private final Vector vector;
!    public DataStreamQueue () {
!       vector = new Vector();
!    }
! 
!    /**
!     * @todo redo the throttling of large queues that are backed up
!     *       This is the cause of numerous painting bugs.
!     * @return a datastream object from queue
!     * @throws InterruptedException
!     */
!    public Object get() throws InterruptedException {
!       synchronized (lock) {
!          // wait until there is something to read
!          while (isEmpty()) {
!             lock.wait();
!          }
! 
!          /**
!           * @todo here is the throttling code to look at
!           *
!           * just something here to try.  OK it works but we need to be a little
!           *     more intelligent with the throttling.
!           */
!          if (vector.size() >= 20) {
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
! //            System.out.println(vector.size());
!          }
!             // we have the lock and state we're seeking
!          return vector.remove(0);
!       }
!    }
! 
!    public boolean isEmpty() {
! 
!       return vector.isEmpty();
!    }
! 
!    public void clear() {
! 
!       synchronized (lock) {
!          vector.clear();
!          lock.notifyAll();
!       }
! 
!    }
! 
!    public void put(Object o) {
!       synchronized (lock) {
!          vector.addElement(o);
! //         if (vector.size() > 5)
! //            System.out.println(vector.size());
!          // tell waiting threads to wake up
!          lock.notifyAll();
!       }
!    }
  }
\ No newline at end of file
--- 1,106 ----
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.framework.tn5250;
! 
! import java.util.Vector;
! 
! public class DataStreamQueue {
! 
!    private final Object lock = new Object();
!    private final Vector vector;
!    public DataStreamQueue () {
!       vector = new Vector();
!    }
! 
!    /**
!     * @todo redo the throttling of large queues that are backed up
!     *       This is the cause of numerous painting bugs.
!     * @return a datastream object from queue
!     * @throws InterruptedException
!     */
!    public Object get() throws InterruptedException {
!       synchronized (lock) {
!          // wait until there is something to read
!          while (isEmpty()) {
!             lock.wait();
!          }
! 
!          /**
!           * @todo here is the throttling code to look at
!           *
!           * just something here to try.  OK it works but we need to be a little
!           *     more intelligent with the throttling.
!           */
!          if (vector.size() >= 20) {
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
!             vector.remove(0);
! //            System.out.println(vector.size());
!          }
!             // we have the lock and state we're seeking
!          return vector.remove(0);
!       }
!    }
! 
!    public boolean isEmpty() {
! 
!       return vector.isEmpty();
!    }
! 
!    public void clear() {
! 
!       synchronized (lock) {
!          vector.clear();
!          lock.notifyAll();
!       }
! 
!    }
! 
!    public void put(Object o) {
!       synchronized (lock) {
!          vector.addElement(o);
! //         if (vector.size() > 5)
! //            System.out.println(vector.size());
!          // tell waiting threads to wake up
!          lock.notifyAll();
!       }
!    }
  }
\ No newline at end of file

Index: ScreenField.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenField.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ScreenField.java	8 Jun 2005 19:45:22 -0000	1.7
--- ScreenField.java	16 Jun 2005 04:41:18 -0000	1.8
***************
*** 1,604 ****
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
[...1181 lines suppressed...]
!    protected boolean manditoried;
!    boolean canSend = true;
!    int attr = 0;
!    int length = 0;
!    int ffw1 = 0;
!    int ffw2 = 0;
!    int fcw1 = 0;
!    int fcw2 = 0;
!    int cursorPos = 0;
!    Screen5250 s;
!    int cursorProg = 0;
!    int fieldId = 0;
!    ScreenField next = null;
!    ScreenField prev = null;
!    boolean isSelectionField;
!    int selectionFieldType;
!    int selectionIndex;
!    int selectionPos;
  }
\ No newline at end of file

Index: ScreenPlanes.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenPlanes.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ScreenPlanes.java	8 Jun 2005 19:45:22 -0000	1.9
--- ScreenPlanes.java	16 Jun 2005 04:41:18 -0000	1.10
***************
*** 1,1143 ****
! /**
!  * Title: ScreenPlanes.java
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.5
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
[...2259 lines suppressed...]
! 	   // now lets make sure there are no more than numSuff spaces after option
! 	   while (hs && (++sp < lenScreen && screen[sp] <= ' '
! 	                  || screen[sp] == suff )) {
! 	      if (sp - x >= numSuff || screen[sp] == suff ||
! 	                  screen[sp] == '.' ||
! 	               screen[sp] == '*') {
! 	         hs =false;
! 	         break;
! 	      }
! 	   }
! 	   if (hs && !Character.isLetterOrDigit(screen[sp]))
! 	      hs = false;
! 	   if (hs) {
! 	      return os;
! 	   }
! 	   return -1;
! 	}
! 
  }
\ No newline at end of file

Index: ScreenOIA.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenOIA.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ScreenOIA.java	8 Jun 2005 19:45:22 -0000	1.4
--- ScreenOIA.java	16 Jun 2005 04:41:18 -0000	1.5
***************
*** 1,300 ****
! /**
!  * <p>Title: ScreenOIA.java</p>
!  * <p>Description: Main interface to control Operator information area screen</p>
!  * <p>Copyright: Copyright (c) 2000 - 2002</p>
!  * <p>
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  * </p>
!  * @author Kenneth J. Pouncey
!  * @version 0.5
!  */
! package org.tn5250j.framework.tn5250;
! 
! import java.util.*;
! 
! import org.tn5250j.event.ScreenOIAListener;
! 
! /**
!  * The operator information area of a host session. This area is used to provide
!  * status information regarding the state of the host session and location of
!  * the cursor.  A ScreenOIA object can be obtained using the GetOIA() method on
!  * an instance of Screen5250.
!  *
!  *
!  */
! public class ScreenOIA
!   {
!    // OIA_LEVEL
!    public static final int OIA_LEVEL_INPUT_INHIBITED   =  1;
!    public static final int OIA_LEVEL_NOT_INHIBITED   =  2;
!    public static final int OIA_LEVEL_MESSAGE_LIGHT_ON  =  3;
!    public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF  =  4;
!    public static final int OIA_LEVEL_AUDIBLE_BELL  =  5;
!    public static final int OIA_LEVEL_INSERT_MODE  =  6;
!    public static final int OIA_LEVEL_KEYBOARD  =  7;
!    public static final int OIA_LEVEL_CLEAR_SCREEN  =  8;
!    public static final int OIA_LEVEL_SCREEN_SIZE  =  9;
!    public static final int OIA_LEVEL_INPUT_ERROR   =  10;
!    public static final int OIA_LEVEL_KEYS_BUFFERED   =  11;
!    public static final int OIA_LEVEL_SCRIPT   =  12;
! 
!    // INPUTINHIBITED
!    public static final int INPUTINHIBITED_NOTINHIBITED   =  0;
!    public static final int INPUTINHIBITED_SYSTEM_WAIT   =  1;
!    public static final int INPUTINHIBITED_COMMCHECK   =  2;
!    public static final int INPUTINHIBITED_PROGCHECK   =  3;
!    public static final int INPUTINHIBITED_MACHINECHECK   =  4;
!    public static final int INPUTINHIBITED_OTHER   =  5;
! 
!    public ScreenOIA (Screen5250 screen) {
! 
!       source = screen;
! 
!    }
! 
!    public boolean isInsertMode() {
! 
!       return insertMode;
!    }
! 
!    protected void setInsertMode(boolean mode) {
! 
!       level = OIA_LEVEL_INSERT_MODE;
!       insertMode = mode;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE);
!    }
! 
!    public int getCommCheckCode() {
! 
!       return commCheck;
!    }
! 
!    public int getInputInhibited() {
! 
!       return inputInhibited;
!    }
! 
!    public int getMachineCheckCode() {
! 
!       return machineCheck;
!    }
! 
!    public int getOwner() {
!       return owner;
!    }
! 
!    public int getProgCheckCode() {
!       return 0;
!    }
! 
! 	/**
! 	 * Is the keyboard locked or not
! 	 *
! 	 * @return locked or not
! 	 */
!    public boolean isKeyBoardLocked() {
!       return locked;
!    }
! 
!    public boolean isKeysBuffered() {
!       return keysBuffered;
!    }
! 
!    public void setKeysBuffered(boolean kb) {
!       level = OIA_LEVEL_KEYS_BUFFERED;
!       boolean oldKB = keysBuffered;
!       keysBuffered = kb;
!       if (keysBuffered != oldKB)
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED);
!    }
! 
!    protected void setKeyBoardLocked(boolean lockIt) {
!       level = OIA_LEVEL_KEYBOARD;
!       boolean oldLocked = locked;
!       locked = lockIt;
! 		if (!lockIt) {
! 
! 			if (isKeysBuffered()) {
! 				source.sendKeys("");
! 			}
! 		}
! 
!       if (locked != oldLocked)
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED);
!    }
! 
!    public boolean isMessageWait() {
!       return messageWait;
!    }
! 
!    protected void setMessageLightOn() {
!       level = OIA_LEVEL_MESSAGE_LIGHT_ON;
!       messageWait = true;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
!    }
! 
!    protected void setMessageLightOff() {
!       level = OIA_LEVEL_MESSAGE_LIGHT_OFF;
!       messageWait = false;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
!    }
! 
!    public void setScriptActive(boolean running) {
!       level = OIA_LEVEL_SCRIPT;
!       scriptRunning = running;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT);
!    }
! 
!    public boolean isScriptActive() {
!       return scriptRunning;
!    }
! 
!    public void setAudibleBell() {
!       level = OIA_LEVEL_AUDIBLE_BELL;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL);
!    }
! 
!    protected void clearScreen() {
!       level = OIA_LEVEL_CLEAR_SCREEN;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN);
!    }
! 
!    /**
!     * Add a ScreenOIAListener to the listener list.
!     *
!     * @param listener  The ScreenOIAListener to be added
!     */
!    public void addOIAListener(ScreenOIAListener listener) {
! 
!       if (listeners == null) {
!           listeners = new java.util.Vector(3);
!       }
!       listeners.addElement(listener);
! 
!    }
! 
!    /**
!     * Remove a iOhioSessionListener from the listener list.
!     *
!     * @param listener  The iOhioSessionListener to be removed
!     */
!    public void removeOIAListener(ScreenOIAListener listener) {
! 
!       if (listeners == null) {
!           return;
!       }
!       listeners.removeElement(listener);
!    }
! 
!    // object methods
!    public Screen5250 getSource() {
! 
!       return source;
!    }
! 
! 
!    public void setSource(Screen5250 screen) {
! 
!       source = screen;
! 
!    }
! 
!    public void setOwner(int newOwner) {
! 
!       owner = newOwner;
! 
!    }
! 
!    public int getLevel() {
! 
!       return level;
!    }
! 
!    public String getInhibitedText() {
!       return inhibitedText;
!    }
! 
!    public void setInputInhibited(int inhibit , int whatCode) {
!       setInputInhibited(inhibit, whatCode, null);
!    }
! 
!    public void setInputInhibited(int inhibit , int whatCode, String message) {
! 
!       inputInhibited = inhibit;
!       level = OIA_LEVEL_INPUT_INHIBITED;
!       inhibitedText = message;
! 
! //      if (saveInhibit != inhibit || saveInhibitLevel != whatCode) {
!          switch(inhibit) {
! 
!             case INPUTINHIBITED_COMMCHECK :
!                commCheck = whatCode;
!                break;
!             case INPUTINHIBITED_PROGCHECK :
!                progCheck = whatCode;
!                break;
!             case INPUTINHIBITED_MACHINECHECK :
!                machineCheck = whatCode;
!                break;
!             case INPUTINHIBITED_SYSTEM_WAIT :
!                level = whatCode;
!                break;
!             case INPUTINHIBITED_NOTINHIBITED :
!                level = whatCode;
!                break;
!          }
! 
!          saveInhibit = inhibit;
!          saveInhibitLevel = level;
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED);
! //      }
!    }
! 
!    /**
!     * Notify all registered listeners of the onOIAChanged event.
!     *
!     */
!    private void fireOIAChanged(int change) {
! 
!       if (listeners != null) {
!          int size = listeners.size();
!          for (int i = 0; i < size; i++) {
!             ScreenOIAListener target =
!                     (ScreenOIAListener)listeners.elementAt(i);
!             target.onOIAChanged((ScreenOIA)this, change);
!          }
!       }
!    }
! 
!    Vector listeners = null;
!    private boolean insertMode;
!    private boolean locked;
!    private boolean keysBuffered;
!    private int size = 0;
!    private int owner = 0;
!    private int level = 0;
!    private Screen5250 source = null;
!    private int commCheck = 0;
!    private int progCheck = 0;
!    private int machineCheck = 0;
!    private boolean messageWait;
!    private boolean scriptRunning;
!    private int inputInhibited = INPUTINHIBITED_NOTINHIBITED;
!    private int saveInhibit = -1;
!    private int saveInhibitLevel = -1;
!    private String inhibitedText;
! 
! }
--- 1,300 ----
! /**
!  * <p>Title: ScreenOIA.java</p>
!  * <p>Description: Main interface to control Operator information area screen</p>
!  * <p>Copyright: Copyright (c) 2000 - 2002</p>
!  * <p>
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  * </p>
!  * @author Kenneth J. Pouncey
!  * @version 0.5
!  */
! package org.tn5250j.framework.tn5250;
! 
! import java.util.*;
! 
! import org.tn5250j.event.ScreenOIAListener;
! 
! /**
!  * The operator information area of a host session. This area is used to provide
!  * status information regarding the state of the host session and location of
!  * the cursor.  A ScreenOIA object can be obtained using the GetOIA() method on
!  * an instance of Screen5250.
!  *
!  *
!  */
! public class ScreenOIA
!   {
!    // OIA_LEVEL
!    public static final int OIA_LEVEL_INPUT_INHIBITED   =  1;
!    public static final int OIA_LEVEL_NOT_INHIBITED   =  2;
!    public static final int OIA_LEVEL_MESSAGE_LIGHT_ON  =  3;
!    public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF  =  4;
!    public static final int OIA_LEVEL_AUDIBLE_BELL  =  5;
!    public static final int OIA_LEVEL_INSERT_MODE  =  6;
!    public static final int OIA_LEVEL_KEYBOARD  =  7;
!    public static final int OIA_LEVEL_CLEAR_SCREEN  =  8;
!    public static final int OIA_LEVEL_SCREEN_SIZE  =  9;
!    public static final int OIA_LEVEL_INPUT_ERROR   =  10;
!    public static final int OIA_LEVEL_KEYS_BUFFERED   =  11;
!    public static final int OIA_LEVEL_SCRIPT   =  12;
! 
!    // INPUTINHIBITED
!    public static final int INPUTINHIBITED_NOTINHIBITED   =  0;
!    public static final int INPUTINHIBITED_SYSTEM_WAIT   =  1;
!    public static final int INPUTINHIBITED_COMMCHECK   =  2;
!    public static final int INPUTINHIBITED_PROGCHECK   =  3;
!    public static final int INPUTINHIBITED_MACHINECHECK   =  4;
!    public static final int INPUTINHIBITED_OTHER   =  5;
! 
!    public ScreenOIA (Screen5250 screen) {
! 
!       source = screen;
! 
!    }
! 
!    public boolean isInsertMode() {
! 
!       return insertMode;
!    }
! 
!    protected void setInsertMode(boolean mode) {
! 
!       level = OIA_LEVEL_INSERT_MODE;
!       insertMode = mode;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE);
!    }
! 
!    public int getCommCheckCode() {
! 
!       return commCheck;
!    }
! 
!    public int getInputInhibited() {
! 
!       return inputInhibited;
!    }
! 
!    public int getMachineCheckCode() {
! 
!       return machineCheck;
!    }
! 
!    public int getOwner() {
!       return owner;
!    }
! 
!    public int getProgCheckCode() {
!       return 0;
!    }
! 
! 	/**
! 	 * Is the keyboard locked or not
! 	 *
! 	 * @return locked or not
! 	 */
!    public boolean isKeyBoardLocked() {
!       return locked;
!    }
! 
!    public boolean isKeysBuffered() {
!       return keysBuffered;
!    }
! 
!    public void setKeysBuffered(boolean kb) {
!       level = OIA_LEVEL_KEYS_BUFFERED;
!       boolean oldKB = keysBuffered;
!       keysBuffered = kb;
!       if (keysBuffered != oldKB)
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED);
!    }
! 
!    protected void setKeyBoardLocked(boolean lockIt) {
!       level = OIA_LEVEL_KEYBOARD;
!       boolean oldLocked = locked;
!       locked = lockIt;
! 		if (!lockIt) {
! 
! 			if (isKeysBuffered()) {
! 				source.sendKeys("");
! 			}
! 		}
! 
!       if (locked != oldLocked)
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED);
!    }
! 
!    public boolean isMessageWait() {
!       return messageWait;
!    }
! 
!    protected void setMessageLightOn() {
!       level = OIA_LEVEL_MESSAGE_LIGHT_ON;
!       messageWait = true;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
!    }
! 
!    protected void setMessageLightOff() {
!       level = OIA_LEVEL_MESSAGE_LIGHT_OFF;
!       messageWait = false;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
!    }
! 
!    public void setScriptActive(boolean running) {
!       level = OIA_LEVEL_SCRIPT;
!       scriptRunning = running;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT);
!    }
! 
!    public boolean isScriptActive() {
!       return scriptRunning;
!    }
! 
!    public void setAudibleBell() {
!       level = OIA_LEVEL_AUDIBLE_BELL;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL);
!    }
! 
!    protected void clearScreen() {
!       level = OIA_LEVEL_CLEAR_SCREEN;
!       fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN);
!    }
! 
!    /**
!     * Add a ScreenOIAListener to the listener list.
!     *
!     * @param listener  The ScreenOIAListener to be added
!     */
!    public void addOIAListener(ScreenOIAListener listener) {
! 
!       if (listeners == null) {
!           listeners = new java.util.Vector(3);
!       }
!       listeners.addElement(listener);
! 
!    }
! 
!    /**
!     * Remove a iOhioSessionListener from the listener list.
!     *
!     * @param listener  The iOhioSessionListener to be removed
!     */
!    public void removeOIAListener(ScreenOIAListener listener) {
! 
!       if (listeners == null) {
!           return;
!       }
!       listeners.removeElement(listener);
!    }
! 
!    // object methods
!    public Screen5250 getSource() {
! 
!       return source;
!    }
! 
! 
!    public void setSource(Screen5250 screen) {
! 
!       source = screen;
! 
!    }
! 
!    public void setOwner(int newOwner) {
! 
!       owner = newOwner;
! 
!    }
! 
!    public int getLevel() {
! 
!       return level;
!    }
! 
!    public String getInhibitedText() {
!       return inhibitedText;
!    }
! 
!    public void setInputInhibited(int inhibit , int whatCode) {
!       setInputInhibited(inhibit, whatCode, null);
!    }
! 
!    public void setInputInhibited(int inhibit , int whatCode, String message) {
! 
!       inputInhibited = inhibit;
!       level = OIA_LEVEL_INPUT_INHIBITED;
!       inhibitedText = message;
! 
! //      if (saveInhibit != inhibit || saveInhibitLevel != whatCode) {
!          switch(inhibit) {
! 
!             case INPUTINHIBITED_COMMCHECK :
!                commCheck = whatCode;
!                break;
!             case INPUTINHIBITED_PROGCHECK :
!                progCheck = whatCode;
!                break;
!             case INPUTINHIBITED_MACHINECHECK :
!                machineCheck = whatCode;
!                break;
!             case INPUTINHIBITED_SYSTEM_WAIT :
!                level = whatCode;
!                break;
!             case INPUTINHIBITED_NOTINHIBITED :
!                level = whatCode;
!                break;
!          }
! 
!          saveInhibit = inhibit;
!          saveInhibitLevel = level;
!          fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED);
! //      }
!    }
! 
!    /**
!     * Notify all registered listeners of the onOIAChanged event.
!     *
!     */
!    private void fireOIAChanged(int change) {
! 
!       if (listeners != null) {
!          int size = listeners.size();
!          for (int i = 0; i < size; i++) {
!             ScreenOIAListener target =
!                     (ScreenOIAListener)listeners.elementAt(i);
!             target.onOIAChanged((ScreenOIA)this, change);
!          }
!       }
!    }
! 
!    Vector listeners = null;
!    private boolean insertMode;
!    private boolean locked;
!    private boolean keysBuffered;
!    private int size = 0;
!    private int owner = 0;
!    private int level = 0;
!    private Screen5250 source = null;
!    private int commCheck = 0;
!    private int progCheck = 0;
!    private int machineCheck = 0;
!    private boolean messageWait;
!    private boolean scriptRunning;
!    private int inputInhibited = INPUTINHIBITED_NOTINHIBITED;
!    private int saveInhibit = -1;
!    private int saveInhibitLevel = -1;
!    private String inhibitedText;
! 
! }

Index: ScreenFields.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenFields.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ScreenFields.java	8 Jun 2005 19:45:22 -0000	1.4
--- ScreenFields.java	16 Jun 2005 04:41:18 -0000	1.5
***************
*** 1,721 ****
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.5
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
[...1415 lines suppressed...]
!                               baosp.write(codePage.uni2ebcdic(' '));
!                      }
!                      else {
!                         if (isSigned && k == len3 - 1) {
!                            baosp.write(0xd0 | (0x0f & c));
!                         }
!                         else
!                            baosp.write(codePage.uni2ebcdic(c));
! 
!                      }
!                   }
!                   }
!                }
!             }
!          }
!       }
!    }
! 
  }
\ No newline at end of file



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click