ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/DataReader.java
Revision: 1.8
Committed: Wed Jan 24 03:21:25 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.7: +3 -3 lines
Log Message:
changes for SwingClient.java -> Conient.java

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2 ajm 1.7 package uk.ac.ukc.iscream.conient;
3 ajm 1.1
4     //---IMPORTS---
5     import java.io.*;
6 ajm 1.5 import uk.ac.ukc.iscream.util.*;
7 ajm 1.1
8     /**
9 ajm 1.7 * The class reads in data from a BufferedReader,
10     * it then converts it to an XMLPacket and adds
11     * it to its Queue for anything that wants it.
12 ajm 1.1 *
13 ajm 1.2 * @author $Author: ajm4 $
14 ajm 1.8 * @version $Id: DataReader.java,v 1.7 2001/01/24 03:09:45 ajm4 Exp $
15 ajm 1.1 */
16     public class DataReader extends Thread {
17    
18     //---FINAL ATTRIBUTES---
19    
20     /**
21     * The current CVS revision of this class
22     */
23 ajm 1.8 public final String REVISION = "$Revision: 1.7 $";
24 ajm 1.1
25     //---STATIC METHODS---
26    
27     //---CONSTRUCTORS---
28    
29 ajm 1.7 /**
30     * Constructs a new data reader, giving it its BufferedReader
31     * and Queue.
32     *
33     * @param inBound the BufferedReader this class should use
34     * @param dataQueue the queue new data should be placed on
35     */
36 ajm 1.5 public DataReader(BufferedReader inBound, Queue dataQueue) {
37 ajm 1.1 _inBound = inBound;
38 ajm 1.5 _dataQueue = dataQueue;
39 ajm 1.1 }
40    
41     //---PUBLIC METHODS---
42    
43 ajm 1.7 /**
44     * This thread reads data from the BufferedReader.
45     * It does this until either there is a problem
46     * or it is told to stop.
47     *
48     * Any data it reads it converts to XML and then
49     * adds to its queue.
50     */
51 ajm 1.1 public void run() {
52 ajm 1.3 try {
53 ajm 1.7 String line;
54    
55     // continue until we are told to stop
56 ajm 1.6 while (_running) {
57 ajm 1.7 line = _inBound.readLine();
58     _dataQueue.add(line);
59 ajm 1.6 }
60    
61 ajm 1.7 // close the BufferedReader
62 ajm 1.6 _inBound.close();
63    
64 ajm 1.3 } catch (IOException e) {
65 ajm 1.8 Conient.addMessage("Data Channel Shutdown: reason - "+e);
66 ajm 1.7 _running = false;
67 ajm 1.1 }
68     }
69    
70 ajm 1.7 /**
71     * This method allows other classes
72     * to shutdown this data reader.
73     */
74     public void shutdown() {
75     _running = false;
76     }
77    
78 ajm 1.1 //---PRIVATE METHODS---
79    
80     //---ACCESSOR/MUTATOR METHODS---
81    
82     //---ATTRIBUTES---
83    
84 ajm 1.7 /**
85     * The reader we are reading from.
86     */
87 ajm 1.1 BufferedReader _inBound;
88 ajm 1.7
89     /**
90     * The Queue we place data on.
91     */
92 ajm 1.5 Queue _dataQueue;
93 ajm 1.7
94     /**
95     * The state of this thread.
96     */
97     boolean _running = true;
98    
99 ajm 1.1 //---STATIC ATTRIBUTES---
100    
101     }