ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/UDPReaderThread.java
Revision: 1.3
Committed: Fri Nov 17 14:45:56 2000 UTC (23 years, 11 months ago) by pjm2
Branch: MAIN
Changes since 1.2: +5 -2 lines
Log Message:
Fixed a major parsing problem by wrapping the XML in an InputSource object
and removing null characters from the input.  Also modified the XMLSender
class so that it no longer sent "null" when the last line of an input file
is reached.

File Contents

# User Rev Content
1 pjm2 1.1 import java.io.*;
2     import java.net.*;
3     import java.util.*;
4    
5     public class UDPReaderThread extends Thread{
6    
7     public UDPReaderThread(DatagramPacket packet){
8     try {
9 pjm2 1.3 rawPacket = packet.getData();
10 pjm2 1.1 }
11     catch (Exception e) {
12     System.out.println("An exception occured while attempting to return an XMLPacket!");
13     e.printStackTrace();
14     }
15     }
16    
17     public void run(){
18 pjm2 1.2
19 pjm2 1.3 String xml = new String(rawPacket);
20     xml = xml.substring(0, xml.indexOf(0));
21    
22 pjm2 1.2 System.out.println("UDPReaderThread - Received the following raw stuff: "+xml);
23    
24 pjm2 1.1 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
25     XMLPacket packet = xmlPacketMaker.createXMLPacket();
26 pjm2 1.2
27     if (packet == null){
28     System.out.println("UDPReaderThread - A null XMLPacket was returned, I think I'll ignore it!");
29     return;
30     }
31     System.out.println("UDPReaderThread - An XML Packet was read sucessfully: -");
32     packet.printAll();
33     // Now do something with this XMLPacket!!!
34     // ....
35 pjm2 1.1 }
36    
37 pjm2 1.3 byte[] rawPacket;
38 pjm2 1.1 }