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

Comparing projects/cms/source/util/uk/org/iscream/cms/util/XMLStringParser.java (file contents):
Revision 1.8 by tdb, Sat Mar 10 00:49:39 2001 UTC vs.
Revision 1.9 by tdb, Sat Mar 10 02:03:55 2001 UTC

# Line 34 | Line 34 | public class XMLStringParser extends DefaultHandler {
34       * No-args constructor.  Generally not used.
35       */
36      public XMLStringParser () {
37 <        this.packet = new XMLPacket();
37 >        _packet = new XMLPacket();
38      }
39  
40      /**
41       * Constructor for accepting a reference to an XMLPacket
42       */
43      public XMLStringParser (XMLPacket packet) {
44 <        this.packet = packet;
44 >        _packet = packet;
45      }
46  
47   //---PUBLIC METHODS---
# Line 50 | Line 50 | public class XMLStringParser extends DefaultHandler {
50       * Accessor to the XMLPacket.
51       */
52      public XMLPacket getXMLPacket() {
53 <        return packet;
53 >        return _packet;
54      }
55  
56      //===========================================================
57      // SAX DocumentHandler methods
58      //===========================================================
59  
60 <    public void startDocument () throws SAXException {
61 <        //System.out.println("XMLPacketParser - Starting parse process...");
62 <    }
63 <
64 <    public void endDocument () throws SAXException {
65 <        //System.out.println("XMLPacketParser - I just finished parsing an XML String.");
66 <    }
67 <
68 <    /** Add each tag's attribute to the XMLPacket.
60 >    /**
61 >     * Add each tag's attribute to the XMLPacket.
62       * Note that all attributes within an opening tag are
63       * stored as "someroot.sometag.attributes.attribute_name"
64       * E.g. If <packet> is the root node, then:
# Line 74 | Line 67 | public class XMLStringParser extends DefaultHandler {
67       *     "packet.attributes.machine_name"
68       * within the XMLPacket.
69       */
70 <    public void startElement (String name, Attributes attrs) throws SAXException {
71 <        indentLevel++;
72 <        tagList.add(name);
73 <        if (attrs != null) {
74 <            for (int i = 0; i < attrs.getLength (); i++) {
75 <                packet.addParam(getPath()+".attributes."+attrs.getLocalName(i), attrs.getValue(i));
70 >    public void startElement (String uri, String name, String qName, Attributes atts) {
71 >            _indentLevel++;
72 >        _tagList.add(name);
73 >        if (atts != null) {
74 >            for (int i = 0; i < atts.getLength (); i++) {
75 >                _packet.addParam(getPath()+".attributes."+atts.getLocalName(i), atts.getValue(i));
76              }
77          }
78      }
# Line 89 | Line 82 | public class XMLStringParser extends DefaultHandler {
82       * the tag name from the tagList and decrement the indent
83       * level.
84       */
85 <    public void endElement (String name) throws SAXException {
86 <        tagList.remove(tagList.size()-1);    
87 <        indentLevel--;
85 >    public void endElement (String uri, String name, String qName) {
86 >            _tagList.remove(_tagList.size() - 1);    
87 >        _indentLevel--;
88      }
89  
90 +
91      /**
92       * Any text falling within a pair of terminal tags must
93       * be added to the XMLPacket.  Trim leading and trailing
# Line 102 | Line 96 | public class XMLStringParser extends DefaultHandler {
96       */
97      public void characters (char[] buf, int offset, int len) throws SAXException {
98          String s = new String(buf, offset, len);
99 <        packet.addParam(getPath(), s);
99 >        _packet.addParam(getPath(), s);
100      }
101  
102      /**
# Line 132 | Line 126 | public class XMLStringParser extends DefaultHandler {
126       * in the XMLPacket.
127       */
128      private String getPath () {
129 <        String path = (String)tagList.get(0);
130 <        if (tagList.size() > 0) {
131 <            for (int i = 1 ; i < tagList.size() ; i++) {
132 <                path = path + "." + (String)tagList.get(i);
129 >        String path = (String) _tagList.get(0);
130 >        if (_tagList.size() > 0) {
131 >            for (int i = 1 ; i < _tagList.size() ; i++) {
132 >                path = path + "." + (String) _tagList.get(i);
133              }
134          }
135          return path;
# Line 148 | Line 142 | public class XMLStringParser extends DefaultHandler {
142      /**
143       * To keep track of our identation level
144       */
145 <    private int indentLevel = 0;
145 >    private int _indentLevel = 0;
146      
147      /**
148       * An ArrayList of tags
149       */
150 <    private ArrayList tagList = new ArrayList();
150 >    private ArrayList _tagList = new ArrayList();
151      
152      /**
153       * A reference to the XMLPacket we are making
154       */
155 <    private XMLPacket packet;
155 >    private XMLPacket _packet;
156      
157      /**
158       * This is the friendly identifier of the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines