--- projects/cms/source/host/java/XMLFormatter.java 2000/12/07 23:22:17 1.3 +++ 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: tdb $ - * @version $Id: XMLFormatter.java,v 1.3 2000/12/07 23:22:17 tdb Exp $ + * @author $Author: ab11 $ + * @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.3 $"; + public final String REVISION = "$Revision: 1.6 $"; //---STATIC METHODS--- @@ -31,6 +32,19 @@ 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, 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(); @@ -48,18 +62,18 @@ class XMLFormatter { hostInfo = null; } - /** - * Public Constructor for the class - * Takes a second parameter containing the root attributes. - */ - public XMLFormatter(String rootInfo, String rootAttributes){ - myStack = new Stack(); - xmlData = new String(); - xmlData = "<"+rootInfo+" "+rootAttributes+">"; - hostInfo = rootInfo; - } - //---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