tn5250j/src/org/tn5250j Session.java,1.15,1.16

"Kenneth J. Pouncey" <[email protected]> Sat, 26 Jun 2004 05:35:49 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12095

Modified Files:
	Session.java 
Log Message:
Add call back scanning functionality

Index: Session.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Session.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Session.java	23 Jan 2004 12:42:29 -0000	1.15
--- Session.java	26 Jun 2004 05:35:47 -0000	1.16
***************
*** 27,30 ****
--- 27,31 ----
  import org.tn5250j.event.SessionListener;
  import org.tn5250j.event.SessionChangeEvent;
+ import org.tn5250j.interfaces.ScanListener;
  
  /**
***************
*** 45,48 ****
--- 46,53 ----
     private boolean heartBeat = false;
  
+    // WVL - LDC : TR.000300 : Callback scenario from 5250
+    private boolean scan; // = false;
+    private ScanListener scanListener; // = null;
+ 
     public Session (Properties props, String configurationResource,
                       String sessionName,
***************
*** 234,237 ****
--- 239,324 ----
     }
  
+    // WVL - LDC : TR.000300 : Callback scenario from 5250
+    protected void setVT(tnvt v)
+    {
+      super.setVT(v);
+ 
+      if (v != null)
+        v.setScanningEnabled(this.scan);
+    }
+ 
+    // WVL - LDC : TR.000300 : Callback scenario from 5250
+    /**
+     * Enables or disables scanning.
+     *
+     * @param scan enables scanning when true; disables otherwise.
+     *
+     * @see tnvt#setCommandScanning(boolean);
+     * @see tnvt#isCommandScanning();
+     * @see tnvt#scan();
+     * @see tnvt#parseCommand();
+     * @see scanned(String,String)
+     */
+    public void setScanningEnabled(boolean scan)
+    {
+      this.scan = scan;
+ 
+      if (this.vt != null)
+        this.vt.setScanningEnabled(scan);
+    }
+ 
+    // WVL - LDC : TR.000300 : Callback scenario from 5250
+    /**
+     * Checks whether scanning is enabled.
+     *
+     * @return true if command scanning is enabled; false otherwise.
+     *
+     * @see tnvt#setCommandScanning(boolean);
+     * @see tnvt#isCommandScanning();
+     * @see tnvt#scan();
+     * @see tnvt#parseCommand();
+     * @see scanned(String,String)
+     */
+    public boolean isScanningEnabled()
+    {
+      if (this.vt != null)
+        return this.vt.isScanningEnabled();
+ 
+      return this.scan;
+    }
+ 
+    // WVL - LDC : TR.000300 : Callback scenario from 5250
+    /**
+     * This is the callback method for the TNVT when sensing the action cmd
+     * screen pattern (!# at position 0,0).
+     *
+     * This is <strong>NOT a threadsafe method</strong> and will be called
+     * from the TNVT read thread!
+     *
+     * @param command discovered in the 5250 stream.
+     * @param remainder are all the other characters on the screen.
+     *
+     * @see tnvt#setCommandScanning(boolean);
+     * @see tnvt#isCommandScanning();
+     * @see tnvt#scan();
+     * @see tnvt#parseCommand();
+     * @see scanned(String,String)
+     */
+   protected void scanned(String command, String remainder)
+   {
+     if (scanListener != null)
+       scanListener.scanned(command, remainder);
+    }
+ 
+    public void addScanListener(ScanListener listener)
+    {
+      scanListener = ScanMulticaster.add(scanListener, listener);
+    }
+ 
+    public void removeScanListener(ScanListener listener)
+    {
+      scanListener = ScanMulticaster.remove(scanListener, listener);
+    }
+ 
     /**
      * Notify all registered listeners of the onSessionChanged event.



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com