--- projects/cms/source/host/java/XMLFormatter.java 2000/12/07 18:25:53 1.2 +++ projects/cms/source/host/java/XMLFormatter.java 2001/03/19 17:30:17 1.6 @@ -5,13 +5,14 @@ import java.util.*; /** * Formats data into valid XML - * By calling either addElement() or addNest() you can use this - * class to create valid xml. When all elements have been added - * calling returnXML() will return a string containing the xml. + * By calling either addElement() or addNest() you can use + * this class to create valid xml. When all elements have + * been added calling returnXML() will return a string + * containing the xml. * * * @author $Author: ab11 $ - * @version $Id: XMLFormatter.java,v 1.2 2000/12/07 18:25:53 ab11 Exp $ + * @version $Id: XMLFormatter.java,v 1.6 2001/03/19 17:30:17 ab11 Exp $ */ class XMLFormatter { @@ -20,7 +21,7 @@ class XMLFormatter { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.2 $"; + public final String REVISION = "$Revision: 1.6 $"; //---STATIC METHODS--- @@ -31,10 +32,22 @@ class XMLFormatter { * Takes in one arguement which can contain any valid non xml character ( "<",">" ) * an example for rootInfo would be "Host" */ - public XMLFormatter(String rootInfo){ + public XMLFormatter(String rootInfo, String attributes){ myStack = new Stack(); xmlData = new String(); + xmlData = "<"+rootInfo+" "+attributes+">"; + hostInfo = rootInfo; + } + + /** + * Public Constructor for the class + * Takes in one arguement which can contain any valid non xml character ( "<",">" ) + * an example for rootInfo would be "Host" + */ + public XMLFormatter(String rootInfo){ + myStack = new Stack(); + xmlData = new String(); xmlData = "<"+rootInfo+">"; hostInfo = rootInfo; } @@ -49,8 +62,18 @@ class XMLFormatter { hostInfo = null; } - //---PUBLIC METHODS--- + + /** + * addEement, adds an element to the XML string with attributes + * + */ + public void addElement(String name, String attributes, String value){ + // check that the strings contain valid data first + if (( name.length() != 0 ) && ( value.length() != 0 )){ + xmlData += "<"+name+" "+attributes+">"+value+""; + } + } /** * addEement, adds an element to the XML string