ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/util/uk/org/iscream/cms/util/XMLPacketMaker.java
(Generate patch)

Comparing projects/cms/source/util/uk/org/iscream/cms/util/XMLPacketMaker.java (file contents):
Revision 1.1 by pjm2, Wed Nov 22 08:40:53 2000 UTC vs.
Revision 1.4 by tdb, Thu Nov 30 02:04:18 2000 UTC

# Line 1 | Line 1
1 + //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.xml;
3 +
4 + //---IMPORTS---
5   import java.io.*;
6   import java.util.ArrayList;
7  
8   import org.xml.sax.*;
5
9   import javax.xml.parsers.SAXParserFactory;
10   import javax.xml.parsers.ParserConfigurationException;
11   import javax.xml.parsers.SAXParser;
12  
13 < // Paul Mutton, pjm2@ukc.ac.uk
13 > import uk.ac.ukc.iscream.core.*;
14 > import uk.ac.ukc.iscream.refman.*;
15  
16 < // XMLPacketMaker - Creates an XMLPacket object.
16 > /**
17 > * XMLPacketMaker - Creates an XMLPacket object.
18 > *
19 > * @author  $Author$
20 > * @version $Id$
21 > */
22   public class XMLPacketMaker extends HandlerBase {
23  
24 <    // No-args constructor.  Generally not used.
16 <    public XMLPacketMaker () {
17 <        this.xml = "<packet></packet>";
18 <    }
24 > //---FINAL ATTRIBUTES---
25  
26 +    /**
27 +     * The current CVS revision of this class
28 +     */
29 +    public final String REVISION = "$Revision$";
30 +    
31 + //---STATIC METHODS---
32 +
33 + //---CONSTRUCTORS---
34 +
35      // Constructor for accepting XML input.
36      public XMLPacketMaker (String xml) {
37 <        this.xml = xml;
37 >        _xml = xml;
38      }
39  
40 + //---PUBLIC METHODS---
41 +
42      public XMLPacket createXMLPacket() {
43  
44          // Create the XMLPacket to store values in.
# Line 32 | Line 49 | public class XMLPacketMaker extends HandlerBase {
49          try {
50  
51              // Parse the input
52 <            InputSource inputSource = new InputSource(new StringReader(xml));
52 >            InputSource inputSource = new InputSource(new StringReader(_xml));
53              SAXParser saxParser = factory.newSAXParser();
54              saxParser.parse(inputSource, new XMLStringParser(packet));
55  
56          }
57          catch (Exception e) {
58 <            System.out.println("XMLPacketMaker - I just received an XML packet that did not contain valid XML.");
42 <            //t.printStackTrace();
58 >            _logger.write(this.toString(), Logger.WARNING, "An invalid XML UDP packet has been detected: "+packet.printAll());
59              return null;
60          }
61          
62          return packet;
63      }
64 <    
65 <    String xml;
66 < }
64 >
65 >    /**
66 >     * Overrides the {@link java.lang.Object#toString() Object.toString()}
67 >     * method to provide clean logging (every class should have this).
68 >     *
69 >     * @return the name of this class and its CVS revision
70 >     */
71 >    public String toString() {
72 >        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
73 >    }
74 >
75 > //---PRIVATE METHODS---
76 >
77 > //---ACCESSOR/MUTATOR METHODS---
78 >
79 > //---ATTRIBUTES---
80 >
81 >    String _xml;
82 >    Logger _logger = ReferenceManager.getInstance().getLogger();
83 >
84 > //---STATIC ATTRIBUTES---
85 >
86 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines