ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/client/javacli/XMLStreamReaderThread.java
Revision: 1.4
Committed: Mon Jun 10 14:10:43 2002 UTC (22 years, 3 months ago) by tdb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 lines
State: FILE REMOVED
Log Message:
Tidy up of files. These are all old things that are not only no longer used
but are also probably useless to anyone other than us. This saves checking
them out all the time, and makes the "cms/source" tree contain only current
stuff. They'll still exist in the attic's though :)

File Contents

# User Rev Content
1 tdb 1.2 /*
2 tdb 1.3 * i-scream central monitoring system
3     * http://www.i-scream.org.uk
4 tdb 1.2 * Copyright (C) 2000-2002 i-scream
5     *
6     * This program is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19     */
20    
21 pjm2 1.1 //---PACKAGE DECLARATION---
22    
23     //---IMPORTS---
24     import java.io.*;
25     import java.net.*;
26     import java.util.ArrayList;
27    
28     import org.xml.sax.*;
29     import javax.xml.parsers.SAXParserFactory;
30     import javax.xml.parsers.ParserConfigurationException;
31     import javax.xml.parsers.SAXParser;
32    
33     /**
34     * XMLStreamReaderThread.
35     *
36 tdb 1.3 * @author $Author: tdb $
37 tdb 1.4 * @version $Id: XMLStreamReaderThread.java,v 1.3 2002/05/21 16:47:11 tdb Exp $
38 pjm2 1.1 */
39     public class XMLStreamReaderThread extends Thread {
40    
41     //---FINAL ATTRIBUTES---
42    
43     /**
44     * The current CVS revision of this class
45     */
46 tdb 1.4 public final String REVISION = "$Revision: 1.3 $";
47 pjm2 1.1
48     //---STATIC METHODS---
49    
50     //---CONSTRUCTORS---
51    
52     // Constructor
53     public XMLStreamReaderThread (String serverName, int serverPort, TerminalScreen screen) {
54     _serverName = serverName;
55     _serverPort = serverPort;
56     _screen = screen;
57     }
58    
59     //---PUBLIC METHODS---
60    
61     public void run() {
62    
63     final int maxPacketSize = 8196;
64     final int startByte = 0;
65     final int endByte = 1;
66    
67     BufferedReader br = null;
68     try {
69     Socket conn = new Socket(_serverName, _serverPort);
70     InputStreamReader isr = new InputStreamReader(conn.getInputStream());
71     br = new BufferedReader(isr);
72    
73     }
74     catch(Exception e) {
75     _screen.clear();
76     System.out.println("Cannot connect to "+_serverName+":"+_serverPort);
77     System.exit(1);
78     }
79    
80     DataLayout layout = new DataLayout(_screen, JavaCLIParameters.showData);
81    
82     // Use the default (non-validating) parser
83     SAXParserFactory factory = SAXParserFactory.newInstance();
84     while (1 == 1) {
85     try {
86     String xml = br.readLine();
87    
88     // Parse the input
89     XMLPacket packet = new XMLPacket();
90     SAXParser saxParser = factory.newSAXParser();
91     saxParser.parse(new InputSource(new StringReader(xml)), new XMLStreamParser(packet));
92    
93    
94     // For out information
95     //_screen.gotoxy(4, 5);
96     //_screen.print(packet.printAll(), TerminalScreen.RED);
97    
98     layout.updateScreen(packet);
99    
100     }
101     catch (IOException e) {
102     System.out.println("Connection to server broken.");
103     break;
104     }
105     catch (Exception e) {
106     System.out.println("Error caught in the Thread: "+e);
107     break;
108     }
109     }
110    
111     _screen.clear();
112    
113     }
114    
115    
116     //---PRIVATE METHODS---
117    
118     //---ACCESSOR/MUTATOR METHODS---
119    
120     //---ATTRIBUTES---
121    
122     private String _serverName;
123     private int _serverPort;
124     private TerminalScreen _screen;
125    
126     //---STATIC ATTRIBUTES---
127    
128     }