home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 2.8 KB | 116 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)ParserThread.java 0.00 09-Jan-95
-
- A thread which runs an instance of pj.io.StoryParser.
-
- Authors:
-
- rphall Rick Hall
-
- Version Ident:
-
- $Header: /PjJavaClient/src/pj/io/ParserThread.java 2 1/21/96 5:27p Rphall $
-
- History:
-
- 09-Jan-95 rphall Initial Creation
-
- ---------------------------------------------------------------------------*/
-
- package pj.io;
-
- import pj.io.Paper;
- import pj.io.PaperSection;
- import pj.io.StoryContainerNotification;
- import pj.io.StoryParser;
-
- import java.io.InputStream;
- import java.lang.Thread;
- import java.util.Observable;
- import java.util.Observer;
-
-
- /*
- * A thread which runs an instance of pj.io.StoryParser.
- * @version 0.00, 09-Jan-95
- * @author Rick Hall
- */
-
- public class ParserThread extends Thread implements Observer
- {
-
-
- // --- Instance variables
-
- private boolean bStayAlive;
- private InputStream isContent;
- private Paper paper;
-
-
-
- // --- Public Constructors
-
- public ParserThread(InputStream is, Paper p)
- {
- bStayAlive = true;
- isContent = is;
- paper = p;
- }
-
-
- // --- Public Operations
-
- public void run()
- {
- // Observe paper
- paper.addObserver(this);
-
- // Create parser and start parsing
- StoryParser parse_obj = new StoryParser(isContent,paper);
- try {
- parse_obj.parse();
- }
- catch(Exception e)
- {
- System.out.println("Debug ParserThread run, exception "
- + e.toString() );
- }
-
- // Hang out until notified of EOT
- while (bStayAlive);
-
- } // run
-
- public synchronized void update(Observable who, Object arg)
- {
- if ( !(arg instanceof StoryContainerNotification) )
- return;
- StoryContainerNotification scn = (StoryContainerNotification) arg;
- if (scn.newState != PaperSection.stateAdded)
- return;
-
- // Kludge: should define PaperNotificationEOT
- if (scn.strSubsect.equals(Paper.idPcolEOT))
- {
- //isContent.flush();
- bStayAlive = false;
- }
-
- } // update
-
-
-
- } // ParserThread
-