ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/FilterThread.java
Revision: 1.2
Committed: Wed Nov 22 09:33:52 2000 UTC (23 years, 5 months ago) by tdb
Branch: MAIN
Changes since 1.1: +13 -3 lines
Log Message:
Added parent filter passing, so the packet can be passed on. Also had to make
a quick fix because a null pointer exception was being thrown on the substring()
part. I think this was because when a message came in over CORBA rather than UDP
it didn't have the 0 (byte 0 that is) at the end.

File Contents

# Content
1 import java.io.*;
2 import java.net.*;
3 import java.util.*;
4 import uk.ac.ukc.iscream.filter.*;
5
6 public class FilterThread extends Thread{
7
8 public FilterThread(Filter parent){
9 this.parent = parent;
10 // no-args constructor.
11 }
12
13 public void run(DatagramPacket packet){
14 rawPacket = packet.getData();
15 start();
16 }
17
18 public void run(String xml){
19 rawPacket = xml.getBytes();
20 start();
21 }
22
23 public void run(){
24
25 // Get a string without any null characters in it.
26 String xml = new String(rawPacket);
27 if(xml.indexOf(0)!=-1) {
28 xml = xml.substring(0, xml.indexOf(0));
29 }
30 else {
31 xml = xml.substring(0, xml.length());
32 }
33 System.out.println(xml);
34
35 // USe my XMLPacketMaker to make an XMLPacket object.
36 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
37 XMLPacket packet = xmlPacketMaker.createXMLPacket();
38
39 if (packet == null){
40 System.out.println("UDPReaderThread - A null XMLPacket was returned, I think I'll ignore it!");
41 return;
42 }
43 System.out.println("UDPReaderThread - An XML Packet was read sucessfully: -");
44 packet.printAll();
45 // Now do something with this XMLPacket!!!
46 // .... but what? ;-)
47 parent.receiveXML(xml);
48
49 }
50
51 Filter parent;
52 byte[] rawPacket;
53 }