--- projects/cms/source/util/uk/org/iscream/cms/util/XMLStringParser.java 2001/03/10 00:49:39 1.8 +++ projects/cms/source/util/uk/org/iscream/cms/util/XMLStringParser.java 2001/03/10 02:03:55 1.9 @@ -15,7 +15,7 @@ import javax.xml.parsers.SAXParser; * XMLStringParser - Used to assist in creating XMLPacket objects. * * @author $Author: tdb $ - * @version $Id: XMLStringParser.java,v 1.8 2001/03/10 00:49:39 tdb Exp $ + * @version $Id: XMLStringParser.java,v 1.9 2001/03/10 02:03:55 tdb Exp $ */ public class XMLStringParser extends DefaultHandler { @@ -24,7 +24,7 @@ public class XMLStringParser extends DefaultHandler { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.8 $"; + public final String REVISION = "$Revision: 1.9 $"; //---STATIC METHODS--- @@ -34,14 +34,14 @@ public class XMLStringParser extends DefaultHandler { * No-args constructor. Generally not used. */ public XMLStringParser () { - this.packet = new XMLPacket(); + _packet = new XMLPacket(); } /** * Constructor for accepting a reference to an XMLPacket */ public XMLStringParser (XMLPacket packet) { - this.packet = packet; + _packet = packet; } //---PUBLIC METHODS--- @@ -50,22 +50,15 @@ public class XMLStringParser extends DefaultHandler { * Accessor to the XMLPacket. */ public XMLPacket getXMLPacket() { - return packet; + return _packet; } //=========================================================== // SAX DocumentHandler methods //=========================================================== - public void startDocument () throws SAXException { - //System.out.println("XMLPacketParser - Starting parse process..."); - } - - public void endDocument () throws SAXException { - //System.out.println("XMLPacketParser - I just finished parsing an XML String."); - } - - /** Add each tag's attribute to the XMLPacket. + /** + * Add each tag's attribute to the XMLPacket. * Note that all attributes within an opening tag are * stored as "someroot.sometag.attributes.attribute_name" * E.g. If is the root node, then: @@ -74,12 +67,12 @@ public class XMLStringParser extends DefaultHandler { * "packet.attributes.machine_name" * within the XMLPacket. */ - public void startElement (String name, Attributes attrs) throws SAXException { - indentLevel++; - tagList.add(name); - if (attrs != null) { - for (int i = 0; i < attrs.getLength (); i++) { - packet.addParam(getPath()+".attributes."+attrs.getLocalName(i), attrs.getValue(i)); + public void startElement (String uri, String name, String qName, Attributes atts) { + _indentLevel++; + _tagList.add(name); + if (atts != null) { + for (int i = 0; i < atts.getLength (); i++) { + _packet.addParam(getPath()+".attributes."+atts.getLocalName(i), atts.getValue(i)); } } } @@ -89,11 +82,12 @@ public class XMLStringParser extends DefaultHandler { * the tag name from the tagList and decrement the indent * level. */ - public void endElement (String name) throws SAXException { - tagList.remove(tagList.size()-1); - indentLevel--; + public void endElement (String uri, String name, String qName) { + _tagList.remove(_tagList.size() - 1); + _indentLevel--; } + /** * Any text falling within a pair of terminal tags must * be added to the XMLPacket. Trim leading and trailing @@ -102,7 +96,7 @@ public class XMLStringParser extends DefaultHandler { */ public void characters (char[] buf, int offset, int len) throws SAXException { String s = new String(buf, offset, len); - packet.addParam(getPath(), s); + _packet.addParam(getPath(), s); } /** @@ -132,10 +126,10 @@ public class XMLStringParser extends DefaultHandler { * in the XMLPacket. */ private String getPath () { - String path = (String)tagList.get(0); - if (tagList.size() > 0) { - for (int i = 1 ; i < tagList.size() ; i++) { - path = path + "." + (String)tagList.get(i); + String path = (String) _tagList.get(0); + if (_tagList.size() > 0) { + for (int i = 1 ; i < _tagList.size() ; i++) { + path = path + "." + (String) _tagList.get(i); } } return path; @@ -148,17 +142,17 @@ public class XMLStringParser extends DefaultHandler { /** * To keep track of our identation level */ - private int indentLevel = 0; + private int _indentLevel = 0; /** * An ArrayList of tags */ - private ArrayList tagList = new ArrayList(); + private ArrayList _tagList = new ArrayList(); /** * A reference to the XMLPacket we are making */ - private XMLPacket packet; + private XMLPacket _packet; /** * This is the friendly identifier of the